diff --git a/src/sdl/texture.cpp b/src/sdl/texture.cpp index 67488290b348..3f8a7a482ce0 100644 --- a/src/sdl/texture.cpp +++ b/src/sdl/texture.cpp @@ -40,6 +40,9 @@ ttexture::ttexture(SDL_Renderer& renderer, , smooth_scaling_(false) , flip_(SDL_FLIP_NONE) , clip_(create_rect(0, 0, w, h)) + , mod_r_(0) + , mod_g_(0) + , mod_b_(0) , source_surface_(NULL) { if(!texture_) { @@ -58,6 +61,9 @@ ttexture::ttexture(SDL_Renderer& renderer, , smooth_scaling_(false) , flip_(SDL_FLIP_NONE) , clip_() + , mod_r_(0) + , mod_g_(0) + , mod_b_(0) , source_surface_(IMG_Load(file.c_str())) { if(source_surface_ == NULL) { @@ -77,6 +83,9 @@ ttexture::ttexture() , smooth_scaling_(false) , flip_(SDL_FLIP_NONE) , clip_() + , mod_r_(0) + , mod_g_(0) + , mod_b_(0) , source_surface_(NULL) {} @@ -105,6 +114,9 @@ ttexture::ttexture(const ttexture& texture) , smooth_scaling_(texture.smooth_scaling_) , flip_(texture.flip_) , clip_(texture.clip_) + , mod_r_(texture.mod_r_) + , mod_g_(texture.mod_g_) + , mod_b_(texture.mod_b_) , source_surface_(texture.source_surface_) { assert(reference_count_); @@ -125,6 +137,9 @@ ttexture::ttexture(SDL_Renderer& renderer, , smooth_scaling_(false) , flip_(SDL_FLIP_NONE) , clip_() + , mod_r_(0) + , mod_g_(0) + , mod_b_(0) , source_surface_(source_surface__) { if(source_surface_ == NULL) { @@ -147,6 +162,9 @@ ttexture::ttexture(SDL_Renderer& renderer, , smooth_scaling_(false) , flip_(SDL_FLIP_NONE) , clip_() + , mod_r_(0) + , mod_g_(0) + , mod_b_(0) , source_surface_( SDL_ConvertSurface(surface, surface->format, surface->flags)) { @@ -325,6 +343,28 @@ SDL_BlendMode ttexture::blend_mode() const return res; } +void ttexture::set_color_mod(Uint8 r, Uint8 g, Uint8 b) +{ + mod_r_ = r; + mod_g_ = g; + mod_b_ = b; +} + +Uint8 ttexture::red_mod() const +{ + return mod_r_; +} + +Uint8 ttexture::green_mod() const +{ + return mod_g_; +} + +Uint8 ttexture::blue_mod() const +{ + return mod_b_; +} + void ttexture::update_pixels(SDL_Surface *surf) { const int retcode = SDL_UpdateTexture(texture_, diff --git a/src/sdl/texture.hpp b/src/sdl/texture.hpp index 84bed8a66814..3791f780b6d9 100644 --- a/src/sdl/texture.hpp +++ b/src/sdl/texture.hpp @@ -271,6 +271,30 @@ class ttexture */ SDL_BlendMode blend_mode() const; + /** + * Sets the color modulation of the texture. + * + * @param r Red modulation. + * @param g Green modulation. + * @param b Blue modulation. + */ + void set_color_mod(Uint8 r, Uint8 g, Uint8 b); + + /** + * Returns the red modulation of the texture. + */ + Uint8 red_mod() const; + + /** + * Returns the green modulation of the texture. + */ + Uint8 green_mod() const; + + /** + * Returns the blue modulation of the texture. + */ + Uint8 blue_mod() const; + /***** ***** ***** Other. ***** ***** *****/ /** @@ -318,6 +342,9 @@ class ttexture /** What should actually be displayed of the texture. */ SDL_Rect clip_; + /** Color modulation. */ + Uint8 mod_r_, mod_g_, mod_b_; + /** * The SDL_Surface source of the @ref texture_. *