Add texture alpha blending
This commit is contained in:
parent
fbc1fdd6f7
commit
c7ec12584c
@ -186,4 +186,13 @@ void RenderObject::copyTo( std::shared_ptr< RenderObject > other ) {
|
|||||||
}
|
}
|
||||||
other->colidedWith.clear();
|
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
|
} // namespace SDLPP
|
||||||
|
@ -86,6 +86,9 @@ public:
|
|||||||
bool isStatic();
|
bool isStatic();
|
||||||
void setStatic( bool stat = true );
|
void setStatic( bool stat = true );
|
||||||
std::shared_ptr< Renderer > getRenderer() const;
|
std::shared_ptr< Renderer > getRenderer() const;
|
||||||
|
void setTextureAlpha( uint8_t alpha );
|
||||||
|
void setTextureSourceRect( SDL_Rect source_rect );
|
||||||
|
void setTextureSourceRect( int x, int y, int w, int h );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
||||||
|
@ -73,4 +73,9 @@ void Texture::setTextureFromSurface( std::shared_ptr< Renderer > &renderer,
|
|||||||
}
|
}
|
||||||
SDL_FreeSurface( surface );
|
SDL_FreeSurface( surface );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::setAlpha( uint8_t alpha ) {
|
||||||
|
SDL_SetTextureBlendMode( texture, SDL_BLENDMODE_BLEND );
|
||||||
|
SDL_SetTextureAlphaMod( texture, alpha );
|
||||||
|
}
|
||||||
} // namespace SDLPP
|
} // namespace SDLPP
|
||||||
|
@ -22,6 +22,7 @@ public:
|
|||||||
const int outline_size = -1 );
|
const int outline_size = -1 );
|
||||||
virtual ~Texture();
|
virtual ~Texture();
|
||||||
SDL_Texture *getTexturePtr();
|
SDL_Texture *getTexturePtr();
|
||||||
|
void setAlpha( uint8_t alpha );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setTextureFromSurface( std::shared_ptr< Renderer > &renderer,
|
void setTextureFromSurface( std::shared_ptr< Renderer > &renderer,
|
||||||
|
Loading…
Reference in New Issue
Block a user