From 784b20038f49e474d7e85c471d623b3c5fdb519b Mon Sep 17 00:00:00 2001 From: Alec Iverson Date: Fri, 12 Aug 2016 15:43:15 -0700 Subject: [PATCH] Added sRGB support to sfTexture. --- include/SFML/Graphics/Texture.h | 35 +++++++++++++++++++++++++++++++++ src/SFML/Graphics/Texture.cpp | 14 +++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/SFML/Graphics/Texture.h b/include/SFML/Graphics/Texture.h index 4f4f094..052bf1a 100644 --- a/include/SFML/Graphics/Texture.h +++ b/include/SFML/Graphics/Texture.h @@ -196,6 +196,41 @@ CSFML_GRAPHICS_API void sfTexture_setSmooth(sfTexture* texture, sfBool smooth); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfTexture_isSmooth(const sfTexture* texture); +//////////////////////////////////////////////////////////// +/// \brief Enable or disable conversion from sRGB +/// +/// When providing texture data from an image file or memory, it can +/// either be stored in a linear color space or an sRGB color space. +/// Most digital images account for gamma correction already, so they +/// would need to be "uncorrected" back to linear color space before +/// being processed by the hardware. The hardware can automatically +/// convert it from the sRGB color space to a linear color space when +/// it gets sampled. When the rendered image gets output to the final +/// framebuffer, it gets converted back to sRGB. +/// +/// After enabling or disabling sRGB conversion, make sure to reload +/// the texture data in order for the setting to take effect. +/// +/// This option is only useful in conjunction with an sRGB capable +/// framebuffer. This can be requested during window creation. +/// +/// \param sRgb True to enable sRGB conversion, false to disable it +/// +/// \see sfTexture_isSrgb +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfTexture_setSrgb(sfTexture* texture, sfBool sRgb); + +//////////////////////////////////////////////////////////// +/// \brief Tell whether the texture source is converted from sRGB or not +/// +/// \return True if the texture source is converted from sRGB, false if not +/// +/// \see sfTexture_setSrgb +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfTexture_isSrgb(const sfTexture* texture); + //////////////////////////////////////////////////////////// /// \brief Enable or disable repeating for a texture /// diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index efe328f..ef440bb 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -225,6 +225,20 @@ sfBool sfTexture_isSmooth(const sfTexture* texture) } +//////////////////////////////////////////////////////////// +void sfTexture_setSrgb(sfTexture* texture, sfBool sRgb) +{ + CSFML_CALL_PTR(texture, setSrgb(sRgb == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +sfBool sfTexture_isSrgb(const sfTexture* texture) +{ + CSFML_CALL_PTR_RETURN(texture, isSrgb(), sfFalse); +} + + //////////////////////////////////////////////////////////// void sfTexture_setRepeated(sfTexture* texture, sfBool repeated) {