From 8a98ab06756a77a10b93e51e208900c6950f9f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 10 Apr 2014 19:27:54 +0200 Subject: [PATCH] Implementation of ARB_stencil_texturing. --- doc/opengl-mapping.dox | 2 +- doc/opengl-support.dox | 2 +- src/Magnum/AbstractTexture.cpp | 6 ++++ src/Magnum/AbstractTexture.h | 3 ++ src/Magnum/CubeMapTexture.h | 8 +++++ src/Magnum/CubeMapTextureArray.h | 8 +++++ src/Magnum/RectangleTexture.h | 8 +++++ src/Magnum/Sampler.cpp | 13 +++++++ src/Magnum/Sampler.h | 22 ++++++++++++ src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 14 ++++++++ src/Magnum/Test/CubeMapTextureGLTest.cpp | 12 +++++++ src/Magnum/Test/RectangleTextureGLTest.cpp | 14 ++++++++ src/Magnum/Test/SamplerTest.cpp | 18 +++++++++- src/Magnum/Test/TextureArrayGLTest.cpp | 24 +++++++++++++ src/Magnum/Test/TextureGLTest.cpp | 36 +++++++++++++++++++ src/Magnum/Texture.h | 20 +++++++++++ src/Magnum/TextureArray.h | 8 +++++ src/Magnum/TextureFormat.h | 3 ++ 18 files changed, 218 insertions(+), 3 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index d06fdef20..0d1c4cac9 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -241,7 +241,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()" +@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::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 273b9c9db..c5ca18e64 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -184,7 +184,7 @@ following: @extension{ARB,robust_buffer_access_behavior} | done (nothing to do) @extension{ARB,shader_image_size} | done (shading language only) @extension{ARB,shader_storage_buffer_object} | only limit queries -@extension{ARB,stencil_texturing} | | +@extension{ARB,stencil_texturing} | done @extension{ARB,texture_buffer_range} | done @extension{ARB,texture_query_levels} | done (shading language only) @extension{ARB,texture_storage_multisample} | done diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index c7921e411..1fb3143d4 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -286,6 +286,12 @@ void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); } +#ifndef MAGNUM_TARGET_GLES +void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) { + (this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); +} +#endif + void AbstractTexture::invalidateImage(const Int level) { (this->*Context::current()->state().texture->invalidateImageImplementation)(level); } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 18feb72f5..f6797bb02 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -298,6 +298,9 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void setBorderColor(const Vector4ui& color); #endif void setMaxAnisotropy(Float anisotropy); + #ifndef MAGNUM_TARGET_GLES + void setDepthStencilMode(Sampler::DepthStencilMode mode); + #endif void invalidateImage(Int level); void generateMipmap(); diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index b23da70f3..b3b8f4574 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -179,6 +179,14 @@ class CubeMapTexture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setDepthStencilMode() */ + CubeMapTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) { + AbstractTexture::setDepthStencilMode(mode); + return *this; + } + #endif + #ifndef MAGNUM_TARGET_GLES /** * @brief %Image size in given mip level diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 2c64085cc..88ae9e584 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -207,6 +207,14 @@ class CubeMapTextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setDepthStencilMode() */ + CubeMapTextureArray& setDepthStencilMode(Sampler::DepthStencilMode mode) { + AbstractTexture::setDepthStencilMode(mode); + return *this; + } + #endif + /** * @brief %Image size in given mip level * @param level Mip level diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 3fbeefbe4..452fdfe75 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -180,6 +180,14 @@ class RectangleTexture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setDepthStencilMode() */ + RectangleTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) { + AbstractTexture::setDepthStencilMode(mode); + return *this; + } + #endif + /** * @brief Set storage * @param internalFormat Internal format diff --git a/src/Magnum/Sampler.cpp b/src/Magnum/Sampler.cpp index 35de1dab4..9a6138c72 100644 --- a/src/Magnum/Sampler.cpp +++ b/src/Magnum/Sampler.cpp @@ -99,6 +99,19 @@ Debug operator<<(Debug debug, const Sampler::Wrapping value) { return debug << "Sampler::Wrapping::(invalid)"; } + +#ifndef MAGNUM_TARGET_GLES +Debug operator<<(Debug debug, const Sampler::DepthStencilMode value) { + switch(value) { + #define _c(value) case Sampler::DepthStencilMode::value: return debug << "Sampler::DepthStencilMode::" #value; + _c(DepthComponent) + _c(StencilIndex) + #undef _c + } + + return debug << "Sampler::DepthStencilMode::(invalid)"; +} +#endif #endif } diff --git a/src/Magnum/Sampler.h b/src/Magnum/Sampler.h index 9f5819530..674e5a807 100644 --- a/src/Magnum/Sampler.h +++ b/src/Magnum/Sampler.h @@ -136,6 +136,23 @@ class MAGNUM_EXPORT Sampler { #endif }; + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Depth/stencil texture mode + * + * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" + * @requires_gl43 %Extension @extension{ARB,stencil_texturing} + * @requires_gl Stencil texturing is not available in OpenGL ES. + */ + enum class DepthStencilMode: GLenum { + /** Sample depth component */ + DepthComponent = GL_DEPTH_COMPONENT, + + /** Sample stencil index (as unsigned integer texture) */ + StencilIndex = GL_STENCIL_INDEX + }; + #endif + /** * @brief Max supported max anisotropy * @@ -165,6 +182,11 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::Mipmap value); /** @debugoperator{Magnum::Sampler} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::Wrapping value); +#ifndef MAGNUM_TARGET_GLES +/** @debugoperator{Magnum::Sampler} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::DepthStencilMode value); +#endif + } #endif diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 514cb87ea..847ffe9e3 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -44,6 +44,7 @@ class CubeMapTextureArrayGLTest: public AbstractOpenGLTester { void sampling(); void samplingBorderInteger(); + void samplingDepthStencilMode(); void storage(); @@ -64,6 +65,7 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { &CubeMapTextureArrayGLTest::sampling, &CubeMapTextureArrayGLTest::samplingBorderInteger, + &CubeMapTextureArrayGLTest::samplingDepthStencilMode, &CubeMapTextureArrayGLTest::storage, @@ -151,6 +153,18 @@ void CubeMapTextureArrayGLTest::samplingBorderInteger() { MAGNUM_VERIFY_NO_ERROR(); } +void CubeMapTextureArrayGLTest::samplingDepthStencilMode() { + 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::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + CubeMapTextureArray texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} + void CubeMapTextureArrayGLTest::storage() { 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 b55e7b252..892bc249c 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -51,6 +51,7 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester { #endif #ifndef MAGNUM_TARGET_GLES void samplingBorderInteger(); + void samplingDepthStencilMode(); #endif void storage(); @@ -81,6 +82,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES &CubeMapTextureGLTest::samplingBorderInteger, + &CubeMapTextureGLTest::samplingDepthStencilMode, #endif &CubeMapTextureGLTest::storage, @@ -182,6 +184,16 @@ void CubeMapTextureGLTest::samplingBorderInteger() { MAGNUM_VERIFY_NO_ERROR(); } + +void CubeMapTextureGLTest::samplingDepthStencilMode() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + CubeMapTexture texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #endif void CubeMapTextureGLTest::storage() { diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index 540985f10..ade0e0b03 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -45,6 +45,7 @@ class RectangleTextureGLTest: public AbstractOpenGLTester { void sampling(); void samplingBorderInteger(); + void samplingDepthStencilMode(); void storage(); @@ -63,6 +64,7 @@ RectangleTextureGLTest::RectangleTextureGLTest() { &RectangleTextureGLTest::sampling, &RectangleTextureGLTest::samplingBorderInteger, + &RectangleTextureGLTest::samplingDepthStencilMode, &RectangleTextureGLTest::storage, @@ -147,6 +149,18 @@ void RectangleTextureGLTest::samplingBorderInteger() { MAGNUM_VERIFY_NO_ERROR(); } +void RectangleTextureGLTest::samplingDepthStencilMode() { + 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::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + RectangleTexture texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} + void RectangleTextureGLTest::storage() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); diff --git a/src/Magnum/Test/SamplerTest.cpp b/src/Magnum/Test/SamplerTest.cpp index 48d4e947b..812734c02 100644 --- a/src/Magnum/Test/SamplerTest.cpp +++ b/src/Magnum/Test/SamplerTest.cpp @@ -37,12 +37,19 @@ class SamplerTest: public TestSuite::Tester { void debugFilter(); void debugMipmap(); void debugWrapping(); + #ifndef MAGNUM_TARGET_GLES + void debugDepthStencilMode(); + #endif }; SamplerTest::SamplerTest() { addTests({&SamplerTest::debugFilter, &SamplerTest::debugMipmap, - &SamplerTest::debugWrapping}); + &SamplerTest::debugWrapping, + #ifndef MAGNUM_TARGET_GLES + &SamplerTest::debugDepthStencilMode + #endif + }); } void SamplerTest::debugFilter() { @@ -66,6 +73,15 @@ void SamplerTest::debugWrapping() { CORRADE_COMPARE(out.str(), "Sampler::Wrapping::ClampToEdge\n"); } +#ifndef MAGNUM_TARGET_GLES +void SamplerTest::debugDepthStencilMode() { + std::ostringstream out; + + Debug(&out) << Sampler::DepthStencilMode::StencilIndex; + CORRADE_COMPARE(out.str(), "Sampler::DepthStencilMode::StencilIndex\n"); +} +#endif + }} CORRADE_TEST_MAIN(Magnum::Test::SamplerTest) diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index b3caf3532..4dbc82dfa 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -62,6 +62,8 @@ class TextureArrayGLTest: public AbstractOpenGLTester { #ifndef MAGNUM_TARGET_GLES void samplingBorderInteger1D(); void samplingBorderInteger2D(); + void samplingDepthStencilMode1D(); + void samplingDepthStencilMode2D(); #else void samplingBorder2D(); #endif @@ -127,6 +129,8 @@ TextureArrayGLTest::TextureArrayGLTest() { #ifndef MAGNUM_TARGET_GLES &TextureArrayGLTest::samplingBorderInteger1D, &TextureArrayGLTest::samplingBorderInteger2D, + &TextureArrayGLTest::samplingDepthStencilMode1D, + &TextureArrayGLTest::samplingDepthStencilMode2D, #else &TextureArrayGLTest::samplingBorder2D, #endif @@ -288,6 +292,16 @@ void TextureArrayGLTest::samplingBorderInteger1D() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureArrayGLTest::samplingDepthStencilMode1D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + Texture1DArray texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #endif void TextureArrayGLTest::sampling2D() { @@ -345,6 +359,16 @@ void TextureArrayGLTest::samplingBorderInteger2D() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureArrayGLTest::samplingDepthStencilMode2D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + Texture2DArray texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #else void TextureArrayGLTest::samplingBorder2D() { if(!Context::current()->isExtensionSupported()) diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index e8aaccf72..2ef5f9f35 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -68,6 +68,9 @@ class TextureGLTest: public AbstractOpenGLTester { #ifndef MAGNUM_TARGET_GLES void samplingBorderInteger2D(); void samplingBorderInteger3D(); + void samplingDepthStencilMode1D(); + void samplingDepthStencilMode2D(); + void samplingDepthStencilMode3D(); #else void samplingBorder2D(); void samplingBorder3D(); @@ -154,6 +157,9 @@ TextureGLTest::TextureGLTest() { #ifndef MAGNUM_TARGET_GLES &TextureGLTest::samplingBorderInteger2D, &TextureGLTest::samplingBorderInteger3D, + &TextureGLTest::samplingDepthStencilMode1D, + &TextureGLTest::samplingDepthStencilMode2D, + &TextureGLTest::samplingDepthStencilMode3D, #else &TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder3D, @@ -344,6 +350,16 @@ void TextureGLTest::sampling1D() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureGLTest::samplingDepthStencilMode1D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + Texture1D texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #endif void TextureGLTest::sampling2D() { @@ -396,6 +412,16 @@ void TextureGLTest::samplingBorderInteger2D() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureGLTest::samplingDepthStencilMode2D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + Texture2D texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #else void TextureGLTest::samplingBorder2D() { if(!Context::current()->isExtensionSupported()) @@ -466,6 +492,16 @@ void TextureGLTest::samplingBorderInteger3D() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureGLTest::samplingDepthStencilMode3D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + + Texture3D texture; + texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); + + MAGNUM_VERIFY_NO_ERROR(); +} #else void TextureGLTest::samplingBorder3D() { #ifdef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index e7eebf850..85ad55cb6 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -425,6 +425,26 @@ template class Texture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Set depth/stencil texture mode + * + * Selects which component of packed depth/stencil texture is used for + * texturing. If @extension{EXT,direct_state_access} is not available, + * the texture is bound to some texture unit before the operation. + * Initial value is @ref Sampler::DepthStencilMode::DepthComponent. + * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} + * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} + * with @def_gl{DEPTH_STENCIL_TEXTURE_MODE} + * @requires_gl43 %Extension @extension{ARB,stencil_texturing} + * @requires_gl Stencil texturing is not available in OpenGL ES. + */ + Texture& setDepthStencilMode(Sampler::DepthStencilMode mode) { + AbstractTexture::setDepthStencilMode(mode); + return *this; + } + #endif + /** * @brief Set storage * @param levels Mip level count diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index e21fba8f1..ce8413b60 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -184,6 +184,14 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setDepthStencilMode() */ + TextureArray& setDepthStencilMode(Sampler::DepthStencilMode mode) { + AbstractTexture::setDepthStencilMode(mode); + return *this; + } + #endif + #ifndef MAGNUM_TARGET_GLES /** @copydoc Texture::imageSize() */ typename DimensionTraits::VectorType imageSize(Int level) { diff --git a/src/Magnum/TextureFormat.h b/src/Magnum/TextureFormat.h index b173c7960..55f83fa44 100644 --- a/src/Magnum/TextureFormat.h +++ b/src/Magnum/TextureFormat.h @@ -834,6 +834,7 @@ enum class TextureFormat: GLenum { * Depth and stencil component, size implementation-dependent. Not * supported in 3D textures, not allowed in unemulated * @ref Texture::setStorage() "*Texture::setStorage()" calls. + * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @deprecated_gl Prefer to use exactly specified version of this format, * e.g. @ref Magnum::TextureFormat::Depth24Stencil8 "TextureFormat::Depth24Stencil8". * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} or @@ -847,6 +848,7 @@ enum class TextureFormat: GLenum { /** * 24bit depth and 8bit stencil component. Not supported in 3D textures. + * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @requires_gl30 %Extension @extension{ARB,framebuffer_object} * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} and * (@es_extension{OES,required_internalformat} or @@ -863,6 +865,7 @@ enum class TextureFormat: GLenum { /** * 32bit float depth component and 8bit stencil component. Not supported in * 3D textures. + * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} * @requires_gles30 Only integral depth textures are available in OpenGL ES * 2.0.