blatantly ganked from T2D; adds rotation as an option for drawbitmap

demonstrates a bit of usage in guibitmapctrl. (do note, gui elements may need followup via altering thier clip rect depending on how folks want to end up using this)
This commit is contained in:
AzaezelX 2021-10-25 23:16:41 -05:00
parent 14ebeaf3eb
commit d07d113246
4 changed files with 55 additions and 27 deletions

View file

@ -58,6 +58,7 @@ ConsoleDocClass( GuiBitmapCtrl,
GuiBitmapCtrl::GuiBitmapCtrl(void)
: mStartPoint( 0, 0 ),
mColor(ColorI::WHITE),
mRotation(0),
mWrap( false )
{
INIT_ASSET(Bitmap);
@ -83,6 +84,8 @@ void GuiBitmapCtrl::initPersistFields()
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl),"color mul");
addField( "wrap", TypeBool, Offset( mWrap, GuiBitmapCtrl ),
"If true, the bitmap is tiled inside the control rather than stretched to fit." );
addField("rotation", TypeF32, Offset(mRotation, GuiBitmapCtrl), "rotation");
endGroup( "Bitmap" );
@ -187,14 +190,14 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
((texture->mBitmapSize.y*y)+offset.y)-yshift,
texture->mBitmapSize.x,
texture->mBitmapSize.y);
GFX->getDrawUtil()->drawBitmapStretchSR(texture,dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear);
GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear, mRotation);
}
}
else
{
RectI rect(offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false);
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect, GFXBitmapFlip_None, GFXTextureFilterLinear, false, mRotation);
}
}