From 4b6ae7afe6716c4fe977321e9e25e0708a8f21f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 16 May 2014 23:46:37 +0200 Subject: [PATCH] Support for EXT_texture_sRGB_decode. --- doc/opengl-mapping.dox | 2 +- doc/opengl-support.dox | 1 + src/Magnum/AbstractTexture.cpp | 5 ++ src/Magnum/AbstractTexture.h | 1 + src/Magnum/Context.cpp | 2 + src/Magnum/CubeMapTexture.h | 6 +++ src/Magnum/CubeMapTextureArray.h | 6 +++ src/Magnum/Extensions.h | 2 + src/Magnum/RectangleTexture.h | 17 ++++++ src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 14 +++++ src/Magnum/Test/CubeMapTextureGLTest.cpp | 16 ++++++ src/Magnum/Test/RectangleTextureGLTest.cpp | 14 +++++ src/Magnum/Test/TextureArrayGLTest.cpp | 36 +++++++++++++ src/Magnum/Test/TextureGLTest.cpp | 52 +++++++++++++++++++ src/Magnum/Texture.h | 20 +++++++ src/Magnum/TextureArray.h | 6 +++ 16 files changed, 199 insertions(+), 1 deletion(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index dae5de8ee..9b06599c0 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -232,7 +232,7 @@ OpenGL function | Matching API @fn_gl{TexBuffer}, \n @fn_gl_extension{TextureBuffer,EXT,direct_state_access}, \n @fn_gl{TexBufferRange}, \n @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} | @ref BufferTexture::setBuffer() @fn_gl{TexImage1D}, \n @fn_gl_extension{TextureImage1D,EXT,direct_state_access} \n @fn_gl{TexImage2D}, \n @fn_gl_extension{TextureImage2D,EXT,direct_state_access}, \n @fn_gl{TexImage3D}, \n @fn_gl_extension{TextureImage3D,EXT,direct_state_access} | @ref Texture::setImage(), \n @ref TextureArray::setImage(), \n @ref CubeMapTexture::setImage(), \n @ref CubeMapTextureArray::setImage(), \n @ref RectangleTexture::setImage() @fn_gl{TexImage2DMultisample}, \n @fn_gl{TexImage3DMultisample} | @ref MultisampleTexture::setStorage() -@fn_gl{TexParameter}, \n @fn_gl_extension{TextureParameter,EXT,direct_state_access} | @ref Texture::setBaseLevel() "*Texture::setBaseLevel()", \n @ref Texture::setMaxLevel() "*Texture::setMaxLevel()", \n @ref Texture::setMinificationFilter() "*Texture::setMinificationFilter()", \n @ref Texture::setMagnificationFilter() "*Texture::setMagnificationFilter()", \n @ref Texture::setMinLod() "*Texture::setMinLod()", \n @ref Texture::setMaxLod() "*Texture::setMaxLod()", \n @ref Texture::setLodBias() "*Texture::setLodBias()", \n @ref Texture::setWrapping() "*Texture::setWrapping()", \n @ref Texture::setBorderColor() "*Texture::setBorderColor()", \n @ref Texture::setMaxAnisotropy() "*Texture::setMaxAnisotropy()", \n @ref Texture::setSwizzle() "*Texture::setSwizzle()", \n @ref Texture::setCompareMode() "*Texture::setCompareMode()", \n @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", \n @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" +@fn_gl{TexParameter}, \n @fn_gl_extension{TextureParameter,EXT,direct_state_access} | @ref Texture::setBaseLevel() "*Texture::setBaseLevel()", \n @ref Texture::setMaxLevel() "*Texture::setMaxLevel()", \n @ref Texture::setMinificationFilter() "*Texture::setMinificationFilter()", \n @ref Texture::setMagnificationFilter() "*Texture::setMagnificationFilter()", \n @ref Texture::setMinLod() "*Texture::setMinLod()", \n @ref Texture::setMaxLod() "*Texture::setMaxLod()", \n @ref Texture::setLodBias() "*Texture::setLodBias()", \n @ref Texture::setWrapping() "*Texture::setWrapping()", \n @ref Texture::setBorderColor() "*Texture::setBorderColor()", \n @ref Texture::setMaxAnisotropy() "*Texture::setMaxAnisotropy()", \n @ref Texture::setSRGBDecode() "*Texture::setSRGBDecode()", \n @ref Texture::setSwizzle() "*Texture::setSwizzle()", \n @ref Texture::setCompareMode() "*Texture::setCompareMode()", \n @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", \n @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" @fn_gl{TexStorage1D}, \n @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}, \n @fn_gl{TexStorage2D}, \n @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, \n @fn_gl{TexStorage3D}, \n @fn_gl_extension{TextureStorage3D,EXT,direct_state_access} | @ref Texture::setStorage(), \n @ref TextureArray::setStorage(), \n @ref CubeMapTexture::setStorage(), \n @ref CubeMapTextureArray::setStorage(), \n @ref RectangleTexture::setStorage() @fn_gl{TexStorage2DMultisample}, \n @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}, \n @fn_gl{TexStorage3DMultisample}, \n @fn_gl_extension{TextureStorage3DMultisample,EXT,direct_state_access} | @ref MultisampleTexture::setStorage() @fn_gl{TexSubImage1D}, \n @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{TexSubImage2D}, \n @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{TexSubImage3D}, \n @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} | @ref Texture::setSubImage(), \n @ref TextureArray::setSubImage(), \n @ref CubeMapTexture::setSubImage(), \n @ref CubeMapTextureArray::setSubImage(), \n @ref RectangleTexture::setSubImage() diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index c6d91e1bf..3e71f098f 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -222,6 +222,7 @@ following: @extension{EXT,texture_filter_anisotropic} (also in ES) | done @extension{EXT,texture_mirror_clamp} | only GL 4.4 subset @extension{EXT,direct_state_access} | done for implemented functionality +@extension{EXT,texture_sRGB_decode} (also in ES) | done @extension{EXT,shader_integer_mix} (also in ES) | done (shading language only) @extension2{EXT,debug_label} (also in ES) | missing pipeline, transform feedback and sampler label @extension2{EXT,debug_marker} (also in ES) | missing marker groups diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 56b005e64..b28a3b928 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -287,6 +287,11 @@ void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); } +void AbstractTexture::setSRGBDecode(bool decode) { + (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, + decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT); +} + #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 68e377828..58032d5aa 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -309,6 +309,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void setBorderColor(const Vector4ui& color); #endif void setMaxAnisotropy(Float anisotropy); + void setSRGBDecode(bool decode); #ifndef MAGNUM_TARGET_GLES2 template void setSwizzle() { diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index ad57fa6be..c8e077396 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -66,6 +66,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,texture_filter_anisotropic), _extension(GL,EXT,texture_mirror_clamp), _extension(GL,EXT,direct_state_access), + _extension(GL,EXT,texture_sRGB_decode), _extension(GL,EXT,shader_integer_mix), _extension(GL,EXT,debug_label), _extension(GL,EXT,debug_marker), @@ -199,6 +200,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,debug_label), _extension(GL,EXT,debug_marker), _extension(GL,EXT,disjoint_timer_query), + _extension(GL,EXT,texture_sRGB_decode), _extension(GL,EXT,separate_shader_objects), _extension(GL,EXT,sRGB), _extension(GL,EXT,multisampled_render_to_texture), diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 45372823f..59d7ad2e6 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -188,6 +188,12 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { return *this; } + /** @copydoc Texture::setSRGBDecode() */ + CubeMapTexture& setSRGBDecode(bool decode) { + AbstractTexture::setSRGBDecode(decode); + return *this; + } + #ifndef MAGNUM_TARGET_GLES2 /** @copydoc Texture::setSwizzle() */ template CubeMapTexture& setSwizzle() { diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index ab24ca357..7349f1d8e 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -218,6 +218,12 @@ class CubeMapTextureArray: public AbstractTexture { return *this; } + /** @copydoc RectangleTexture::setSRGBDecode() */ + CubeMapTextureArray& setSRGBDecode(bool decode) { + AbstractTexture::setSRGBDecode(decode); + return *this; + } + /** * @copybrief Texture::setSwizzle() * @return Reference to self (for method chaining) diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 3e967f931..d5257f838 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -187,6 +187,7 @@ namespace GL { _extension(GL,EXT,transform_feedback, GL210, GL300) // #352 _extension(GL,EXT,direct_state_access, GL210, None) // #353 _extension(GL,EXT,texture_snorm, GL300, GL310) // #365 + _extension(GL,EXT,texture_sRGB_decode, GL210, None) // #402 _extension(GL,EXT,shader_integer_mix, GL300, None) // #437 _extension(GL,EXT,debug_label, GL210, None) // #439 _extension(GL,EXT,debug_marker, GL210, None) // #440 @@ -259,6 +260,7 @@ namespace GL { _extension(GL,EXT,map_buffer_range, GLES200, GLES300) // #121 #endif _extension(GL,EXT,disjoint_timer_query, GLES200, None) // #150 + _extension(GL,EXT,texture_sRGB_decode, GLES200, None) // #152 #ifdef MAGNUM_TARGET_GLES2 _extension(GL,EXT,instanced_arrays, GLES200, GLES300) // #156 _extension(GL,EXT,draw_instanced, GLES200, GLES300) // #157 diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 3b5e4c5f9..02c1aa0a5 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -190,6 +190,23 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { return *this; } + /** + * @brief Set sRGB decoding + * @return Reference to self (for method chaining) + * + * Disables or reenables decoding of sRGB values. Initial value is + * `true`. + * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and + * @fn_gl{TexParameter} or + * @fn_gl_extension{TextureParameter,EXT,direct_state_access} with + * @def_gl{TEXTURE_SRGB_DECODE_EXT} + * @requires_extension %Extension @extension{EXT,texture_sRGB_decode} + */ + RectangleTexture& setSRGBDecode(bool decode) { + AbstractTexture::setSRGBDecode(decode); + return *this; + } + /** * @copybrief Texture::setSwizzle() * @return Reference to self (for method chaining) diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 5fadb807a..1a3272d81 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -43,6 +43,7 @@ class CubeMapTextureArrayGLTest: public AbstractOpenGLTester { void bind(); void sampling(); + void samplingSRGBDecode(); void samplingBorderInteger(); void samplingSwizzle(); void samplingDepthStencilMode(); @@ -65,6 +66,7 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { &CubeMapTextureArrayGLTest::bind, &CubeMapTextureArrayGLTest::sampling, + &CubeMapTextureArrayGLTest::samplingSRGBDecode, &CubeMapTextureArrayGLTest::samplingBorderInteger, &CubeMapTextureArrayGLTest::samplingSwizzle, &CubeMapTextureArrayGLTest::samplingDepthStencilMode, @@ -141,6 +143,18 @@ void CubeMapTextureArrayGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +void CubeMapTextureArrayGLTest::samplingSRGBDecode() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + CubeMapTextureArray texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + void CubeMapTextureArrayGLTest::samplingBorderInteger() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 2dd8454dc..7428b0e10 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -46,6 +46,7 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester { void bind(); void sampling(); + void samplingSRGBDecode(); #ifndef MAGNUM_TARGET_GLES2 void samplingSwizzle(); #else @@ -80,6 +81,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { &CubeMapTextureGLTest::bind, &CubeMapTextureGLTest::sampling, + &CubeMapTextureGLTest::samplingSRGBDecode, #ifndef MAGNUM_TARGET_GLES2 &CubeMapTextureGLTest::samplingSwizzle, #else @@ -169,6 +171,20 @@ void CubeMapTextureGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +void CubeMapTextureGLTest::samplingSRGBDecode() { + #ifdef MAGNUM_TARGET_GLES2 + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); + #endif + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + CubeMapTexture texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::samplingSwizzle() { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index 7a925626f..8bc4a3994 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -44,6 +44,7 @@ class RectangleTextureGLTest: public AbstractOpenGLTester { void bind(); void sampling(); + void samplingSRGBDecode(); void samplingBorderInteger(); void samplingSwizzle(); void samplingDepthStencilMode(); @@ -64,6 +65,7 @@ RectangleTextureGLTest::RectangleTextureGLTest() { &RectangleTextureGLTest::bind, &RectangleTextureGLTest::sampling, + &RectangleTextureGLTest::samplingSRGBDecode, &RectangleTextureGLTest::samplingBorderInteger, &RectangleTextureGLTest::samplingSwizzle, &RectangleTextureGLTest::samplingDepthStencilMode, @@ -137,6 +139,18 @@ void RectangleTextureGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +void RectangleTextureGLTest::samplingSRGBDecode() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + RectangleTexture texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + void RectangleTextureGLTest::samplingBorderInteger() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 495bcc392..9ba943824 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -55,6 +55,11 @@ class TextureArrayGLTest: public AbstractOpenGLTester { #endif void sampling2D(); + #ifndef MAGNUM_TARGET_GLES + void samplingSRGBDecode1D(); + #endif + void samplingSRGBDecode2D(); + #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES void samplingSwizzle1D(); @@ -128,6 +133,11 @@ TextureArrayGLTest::TextureArrayGLTest() { #endif &TextureArrayGLTest::sampling2D, + #ifndef MAGNUM_TARGET_GLES + &TextureArrayGLTest::samplingSRGBDecode1D, + #endif + &TextureArrayGLTest::samplingSRGBDecode2D, + #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES &TextureArrayGLTest::samplingSwizzle1D, @@ -292,6 +302,18 @@ void TextureArrayGLTest::sampling1D() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureArrayGLTest::samplingSRGBDecode1D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + Texture1DArray texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + void TextureArrayGLTest::samplingSwizzle1D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); @@ -361,6 +383,20 @@ void TextureArrayGLTest::sampling2D() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureArrayGLTest::samplingSRGBDecode2D() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); + #endif + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + Texture2DArray texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + #ifndef MAGNUM_TARGET_GLES2 void TextureArrayGLTest::samplingSwizzle2D() { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 8f6b6fead..fcbe09c4f 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -60,6 +60,12 @@ class TextureGLTest: public AbstractOpenGLTester { void sampling2D(); void sampling3D(); + #ifndef MAGNUM_TARGET_GLES + void samplingSRGBDecode1D(); + #endif + void samplingSRGBDecode2D(); + void samplingSRGBDecode3D(); + #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES void samplingSwizzle1D(); @@ -156,6 +162,12 @@ TextureGLTest::TextureGLTest() { &TextureGLTest::sampling2D, &TextureGLTest::sampling3D, + #ifndef MAGNUM_TARGET_GLES + &TextureGLTest::samplingSRGBDecode1D, + #endif + &TextureGLTest::samplingSRGBDecode2D, + &TextureGLTest::samplingSRGBDecode3D, + #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES &TextureGLTest::samplingSwizzle1D, @@ -367,6 +379,16 @@ void TextureGLTest::sampling1D() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureGLTest::samplingSRGBDecode1D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + Texture1D texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + void TextureGLTest::samplingSwizzle1D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); @@ -414,6 +436,20 @@ void TextureGLTest::sampling2D() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureGLTest::samplingSRGBDecode2D() { + #ifdef MAGNUM_TARGET_GLES2 + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); + #endif + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + Texture2D texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingSwizzle2D() { #ifndef MAGNUM_TARGET_GLES @@ -515,6 +551,22 @@ void TextureGLTest::sampling3D() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureGLTest::samplingSRGBDecode3D() { + #ifdef MAGNUM_TARGET_GLES2 + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); + #endif + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); + + Texture3D texture; + texture.setSRGBDecode(false); + + MAGNUM_VERIFY_NO_ERROR(); +} + #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingSwizzle3D() { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 0a13ad6e2..864669fe6 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -442,6 +442,26 @@ template class Texture: public AbstractTexture { return *this; } + /** + * @brief Set sRGB decoding + * @return Reference to self (for method chaining) + * + * Disables or reenables decoding of sRGB values. Initial value is + * `true`. + * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and + * @fn_gl{TexParameter} or + * @fn_gl_extension{TextureParameter,EXT,direct_state_access} with + * @def_gl{TEXTURE_SRGB_DECODE_EXT} + * @requires_extension %Extension @extension{EXT,texture_sRGB_decode} + * @requires_es_extension OpenGL ES 3.0 or extension + * @es_extension{EXT,sRGB} and + * @es_extension2{EXT,texture_sRGB_decode,texture_sRGB_decode} + */ + Texture& setSRGBDecode(bool decode) { + AbstractTexture::setSRGBDecode(decode); + return *this; + } + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Set component swizzle diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 0a671dbd7..bf4d8e94b 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -196,6 +196,12 @@ template class TextureArray: public AbstractTexture { return *this; } + /** @copydoc Texture::setSRGBDecode() */ + TextureArray& setSRGBDecode(bool decode) { + AbstractTexture::setSRGBDecode(decode); + return *this; + } + #ifndef MAGNUM_TARGET_GLES2 /** @copydoc Texture::setSwizzle() */ template TextureArray& setSwizzle() {