Add texture alpha blending

This commit is contained in:
2021-03-07 13:18:58 +01:00
parent fbc1fdd6f7
commit c7ec12584c
4 changed files with 19 additions and 1 deletions
+10 -1
View File
@@ -12,7 +12,7 @@ void RenderObject::render() {
polygon->render( *renderer );
if ( texture != NULL ) {
SDL_Rect *src = NULL;
if(!entireTexture())
if ( !entireTexture() )
src = &src_rect;
SDL_RenderCopy( renderer->getRendererPtr(),
texture->getTexturePtr(), src, &rect );
@@ -186,4 +186,13 @@ void RenderObject::copyTo( std::shared_ptr< RenderObject > other ) {
}
other->colidedWith.clear();
}
void RenderObject::setTextureAlpha( uint8_t alpha ) {
texture->setAlpha( alpha );
}
void RenderObject::setTextureSourceRect( SDL_Rect source_rect ) {
src_rect = source_rect;
}
void RenderObject::setTextureSourceRect( int x, int y, int w, int h ) {
setTextureSourceRect( { x, y, w, h } );
}
} // namespace SDLPP