mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 02:45:57 -04:00
Added Color support for Texture
This commit is contained in:
parent
b1cc4d5711
commit
daab479c0f
@ -157,6 +157,10 @@ Texture& Texture::SetColorMod(Uint8 r, Uint8 g, Uint8 b) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Texture& Texture::SetColorAndAlphaMod(const Color color) {
|
||||||
|
return SetColorMod(color.r, color.g, color.b).SetAlphaMod(color.a);
|
||||||
|
}
|
||||||
|
|
||||||
Texture::LockHandle Texture::Lock(const Optional<Rect>& rect) {
|
Texture::LockHandle Texture::Lock(const Optional<Rect>& rect) {
|
||||||
return LockHandle(this, rect);
|
return LockHandle(this, rect);
|
||||||
}
|
}
|
||||||
@ -215,4 +219,11 @@ void Texture::GetColorMod(Uint8& r, Uint8& g, Uint8& b) const {
|
|||||||
throw Exception("SDL_GetTextureColorMod");
|
throw Exception("SDL_GetTextureColorMod");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color Texture::GetColorAndAlphaMod() const {
|
||||||
|
Color color;
|
||||||
|
GetColorMod(color.r, color.g, color.b);
|
||||||
|
color.SetAlpha(GetAlphaMod());
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SDL2pp/Rect.hh>
|
#include <SDL2pp/Rect.hh>
|
||||||
#include <SDL2pp/Config.hh>
|
#include <SDL2pp/Config.hh>
|
||||||
#include <SDL2pp/Export.hh>
|
#include <SDL2pp/Export.hh>
|
||||||
|
#include <SDL2pp/Color.hh>
|
||||||
|
|
||||||
struct SDL_Texture;
|
struct SDL_Texture;
|
||||||
|
|
||||||
@ -421,6 +422,20 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Texture& SetColorMod(Uint8 r = 255, Uint8 g = 255, Uint8 b = 255);
|
Texture& SetColorMod(Uint8 r = 255, Uint8 g = 255, Uint8 b = 255);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Set an additional color value multiplied into render copy operations
|
||||||
|
///
|
||||||
|
/// \param[in] color Color to be used when multiplied into render copy operations
|
||||||
|
///
|
||||||
|
/// \returns Reference to self
|
||||||
|
///
|
||||||
|
/// \throws SDL2pp::Exception
|
||||||
|
///
|
||||||
|
/// \see http://wiki.libsdl.org/SDL_SetTextureColorMod
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Texture& SetColorAndAlphaMod(const Color color = Color{255, 255, 255, 255});
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Lock texture for write-only pixel access
|
/// \brief Lock texture for write-only pixel access
|
||||||
///
|
///
|
||||||
@ -536,6 +551,18 @@ public:
|
|||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void GetColorMod(Uint8& r, Uint8& g, Uint8 &b) const;
|
void GetColorMod(Uint8& r, Uint8& g, Uint8 &b) const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the additional color value multiplied into render copy operations
|
||||||
|
///
|
||||||
|
/// \return Color object with the values used to do render copy operations
|
||||||
|
///
|
||||||
|
/// \throws SDL2pp::Exception
|
||||||
|
///
|
||||||
|
/// \see http://wiki.libsdl.org/SDL_GetTextureColorMod
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Color GetColorAndAlphaMod() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user