From 01053ec504eaa297586109b686f5568de6a8b2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 13:38:47 +0200 Subject: [PATCH] Enabled stencil texturing in ES 3.1. --- src/Magnum/AbstractTexture.cpp | 2 +- src/Magnum/AbstractTexture.h | 2 +- src/Magnum/CubeMapTexture.h | 2 +- src/Magnum/Sampler.h | 5 ++-- src/Magnum/Test/CubeMapTextureGLTest.cpp | 11 ++++++++ src/Magnum/Test/TextureArrayGLTest.cpp | 16 ++++++++++-- src/Magnum/Test/TextureGLTest.cpp | 32 +++++++++++++++++++++--- src/Magnum/Texture.h | 5 ++-- src/Magnum/TextureArray.h | 2 +- 9 files changed, 63 insertions(+), 14 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index ae381d210..f5518f4d7 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -326,7 +326,7 @@ void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function , GLenum(function)); } -#ifndef MAGNUM_TARGET_GLES +#ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) { (this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 6d713509a..f7f478423 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -335,7 +335,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void setCompareMode(Sampler::CompareMode mode); void setCompareFunction(Sampler::CompareFunction function); - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 void setDepthStencilMode(Sampler::DepthStencilMode mode); #endif void invalidateImage(Int level); diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 67319620b..8209be45c 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -228,7 +228,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { return *this; } - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** @copydoc Texture::setDepthStencilMode() */ CubeMapTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) { AbstractTexture::setDepthStencilMode(mode); diff --git a/src/Magnum/Sampler.h b/src/Magnum/Sampler.h index e65627462..94dd23b6e 100644 --- a/src/Magnum/Sampler.h +++ b/src/Magnum/Sampler.h @@ -206,13 +206,14 @@ class MAGNUM_EXPORT Sampler { Greater = GL_GREATER }; - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * @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. + * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 + * and older */ enum class DepthStencilMode: GLenum { /** Sample depth component */ diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 0f77f2bc4..8cd00eba4 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -55,6 +55,8 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester { #endif #ifndef MAGNUM_TARGET_GLES void samplingBorderInteger(); + #endif + #ifndef MAGNUM_TARGET_GLES2 void samplingDepthStencilMode(); #endif @@ -90,6 +92,8 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES &CubeMapTextureGLTest::samplingBorderInteger, + #endif + #ifndef MAGNUM_TARGET_GLES2 &CubeMapTextureGLTest::samplingDepthStencilMode, #endif @@ -235,10 +239,17 @@ void CubeMapTextureGLTest::samplingBorderInteger() { MAGNUM_VERIFY_NO_ERROR(); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::samplingDepthStencilMode() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 not supported."); + #endif CubeMapTexture texture; texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index dc8fc08b9..a93011b9c 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -74,8 +74,11 @@ class TextureArrayGLTest: public AbstractOpenGLTester { void samplingBorderInteger1D(); void samplingBorderInteger2D(); void samplingDepthStencilMode1D(); + #endif + #ifndef MAGNUM_TARGET_GLES2 void samplingDepthStencilMode2D(); - #else + #endif + #ifdef MAGNUM_TARGET_GLES void samplingBorder2D(); #endif @@ -457,19 +460,28 @@ void TextureArrayGLTest::samplingBorderInteger2D() { MAGNUM_VERIFY_NO_ERROR(); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void TextureArrayGLTest::samplingDepthStencilMode2D() { + #ifndef MAGNUM_TARGET_GLES 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::ARB::stencil_texturing::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif Texture2DArray texture; texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); MAGNUM_VERIFY_NO_ERROR(); } -#else +#endif + +#ifdef MAGNUM_TARGET_GLES void TextureArrayGLTest::samplingBorder2D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported.")); diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index fcbe09c4f..4f699cb4e 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -82,9 +82,12 @@ class TextureGLTest: public AbstractOpenGLTester { void samplingBorderInteger2D(); void samplingBorderInteger3D(); void samplingDepthStencilMode1D(); + #endif + #ifndef MAGNUM_TARGET_GLES2 void samplingDepthStencilMode2D(); void samplingDepthStencilMode3D(); - #else + #endif + #ifdef MAGNUM_TARGET_GLES void samplingBorder2D(); void samplingBorder3D(); #endif @@ -184,9 +187,12 @@ TextureGLTest::TextureGLTest() { &TextureGLTest::samplingBorderInteger2D, &TextureGLTest::samplingBorderInteger3D, &TextureGLTest::samplingDepthStencilMode1D, + #endif + #ifndef MAGNUM_TARGET_GLES2 &TextureGLTest::samplingDepthStencilMode2D, &TextureGLTest::samplingDepthStencilMode3D, - #else + #endif + #ifdef MAGNUM_TARGET_GLES &TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder3D, #endif @@ -499,17 +505,26 @@ void TextureGLTest::samplingBorderInteger2D() { MAGNUM_VERIFY_NO_ERROR(); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingDepthStencilMode2D() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif Texture2D texture; texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); MAGNUM_VERIFY_NO_ERROR(); } -#else +#endif + +#ifdef MAGNUM_TARGET_GLES void TextureGLTest::samplingBorder2D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported.")); @@ -607,17 +622,26 @@ void TextureGLTest::samplingBorderInteger3D() { MAGNUM_VERIFY_NO_ERROR(); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingDepthStencilMode3D() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif Texture3D texture; texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); MAGNUM_VERIFY_NO_ERROR(); } -#else +#endif + +#ifdef MAGNUM_TARGET_GLES void TextureGLTest::samplingBorder3D() { #ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported()) diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 25a142b99..cbda5f7e9 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -531,7 +531,7 @@ template class Texture: public AbstractTexture { return *this; } - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Set depth/stencil texture mode * @return Reference to self (for method chaining) @@ -545,7 +545,8 @@ template class Texture: public AbstractTexture { * 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. + * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 + * and older. */ Texture& setDepthStencilMode(Sampler::DepthStencilMode mode) { AbstractTexture::setDepthStencilMode(mode); diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index f4865b588..3ca9fdcf2 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -236,7 +236,7 @@ template class TextureArray: public AbstractTexture { return *this; } - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /** * @copybrief Texture::setDepthStencilMode() * @return Reference to self (for method chaining)