Browse Source

Enabled stencil texturing in ES 3.1.

pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
01053ec504
  1. 2
      src/Magnum/AbstractTexture.cpp
  2. 2
      src/Magnum/AbstractTexture.h
  3. 2
      src/Magnum/CubeMapTexture.h
  4. 5
      src/Magnum/Sampler.h
  5. 11
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  6. 16
      src/Magnum/Test/TextureArrayGLTest.cpp
  7. 32
      src/Magnum/Test/TextureGLTest.cpp
  8. 5
      src/Magnum/Texture.h
  9. 2
      src/Magnum/TextureArray.h

2
src/Magnum/AbstractTexture.cpp

@ -326,7 +326,7 @@ void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function
, GLenum(function)); , GLenum(function));
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) { void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) {
(this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); (this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode));
} }

2
src/Magnum/AbstractTexture.h

@ -335,7 +335,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void setCompareMode(Sampler::CompareMode mode); void setCompareMode(Sampler::CompareMode mode);
void setCompareFunction(Sampler::CompareFunction function); void setCompareFunction(Sampler::CompareFunction function);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
void setDepthStencilMode(Sampler::DepthStencilMode mode); void setDepthStencilMode(Sampler::DepthStencilMode mode);
#endif #endif
void invalidateImage(Int level); void invalidateImage(Int level);

2
src/Magnum/CubeMapTexture.h

@ -228,7 +228,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** @copydoc Texture::setDepthStencilMode() */ /** @copydoc Texture::setDepthStencilMode() */
CubeMapTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) { CubeMapTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) {
AbstractTexture::setDepthStencilMode(mode); AbstractTexture::setDepthStencilMode(mode);

5
src/Magnum/Sampler.h

@ -206,13 +206,14 @@ class MAGNUM_EXPORT Sampler {
Greater = GL_GREATER Greater = GL_GREATER
}; };
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** /**
* @brief Depth/stencil texture mode * @brief Depth/stencil texture mode
* *
* @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()"
* @requires_gl43 %Extension @extension{ARB,stencil_texturing} * @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 { enum class DepthStencilMode: GLenum {
/** Sample depth component */ /** Sample depth component */

11
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -55,6 +55,8 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester {
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void samplingBorderInteger(); void samplingBorderInteger();
#endif
#ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode(); void samplingDepthStencilMode();
#endif #endif
@ -90,6 +92,8 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::samplingBorderInteger, &CubeMapTextureGLTest::samplingBorderInteger,
#endif
#ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::samplingDepthStencilMode, &CubeMapTextureGLTest::samplingDepthStencilMode,
#endif #endif
@ -235,10 +239,17 @@ void CubeMapTextureGLTest::samplingBorderInteger() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2
void CubeMapTextureGLTest::samplingDepthStencilMode() { void CubeMapTextureGLTest::samplingDepthStencilMode() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); 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; CubeMapTexture texture;
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);

16
src/Magnum/Test/TextureArrayGLTest.cpp

@ -74,8 +74,11 @@ class TextureArrayGLTest: public AbstractOpenGLTester {
void samplingBorderInteger1D(); void samplingBorderInteger1D();
void samplingBorderInteger2D(); void samplingBorderInteger2D();
void samplingDepthStencilMode1D(); void samplingDepthStencilMode1D();
#endif
#ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode2D(); void samplingDepthStencilMode2D();
#else #endif
#ifdef MAGNUM_TARGET_GLES
void samplingBorder2D(); void samplingBorder2D();
#endif #endif
@ -457,19 +460,28 @@ void TextureArrayGLTest::samplingBorderInteger2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2
void TextureArrayGLTest::samplingDepthStencilMode2D() { void TextureArrayGLTest::samplingDepthStencilMode2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>()) if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_array>())
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); 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; Texture2DArray texture;
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#else #endif
#ifdef MAGNUM_TARGET_GLES
void TextureArrayGLTest::samplingBorder2D() { void TextureArrayGLTest::samplingBorder2D() {
if(!Context::current()->isExtensionSupported<Extensions::GL::NV::texture_border_clamp>()) if(!Context::current()->isExtensionSupported<Extensions::GL::NV::texture_border_clamp>())
CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported."));

32
src/Magnum/Test/TextureGLTest.cpp

@ -82,9 +82,12 @@ class TextureGLTest: public AbstractOpenGLTester {
void samplingBorderInteger2D(); void samplingBorderInteger2D();
void samplingBorderInteger3D(); void samplingBorderInteger3D();
void samplingDepthStencilMode1D(); void samplingDepthStencilMode1D();
#endif
#ifndef MAGNUM_TARGET_GLES2
void samplingDepthStencilMode2D(); void samplingDepthStencilMode2D();
void samplingDepthStencilMode3D(); void samplingDepthStencilMode3D();
#else #endif
#ifdef MAGNUM_TARGET_GLES
void samplingBorder2D(); void samplingBorder2D();
void samplingBorder3D(); void samplingBorder3D();
#endif #endif
@ -184,9 +187,12 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::samplingBorderInteger2D, &TextureGLTest::samplingBorderInteger2D,
&TextureGLTest::samplingBorderInteger3D, &TextureGLTest::samplingBorderInteger3D,
&TextureGLTest::samplingDepthStencilMode1D, &TextureGLTest::samplingDepthStencilMode1D,
#endif
#ifndef MAGNUM_TARGET_GLES2
&TextureGLTest::samplingDepthStencilMode2D, &TextureGLTest::samplingDepthStencilMode2D,
&TextureGLTest::samplingDepthStencilMode3D, &TextureGLTest::samplingDepthStencilMode3D,
#else #endif
#ifdef MAGNUM_TARGET_GLES
&TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder2D,
&TextureGLTest::samplingBorder3D, &TextureGLTest::samplingBorder3D,
#endif #endif
@ -499,17 +505,26 @@ void TextureGLTest::samplingBorderInteger2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::samplingDepthStencilMode2D() { void TextureGLTest::samplingDepthStencilMode2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); 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; Texture2D texture;
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#else #endif
#ifdef MAGNUM_TARGET_GLES
void TextureGLTest::samplingBorder2D() { void TextureGLTest::samplingBorder2D() {
if(!Context::current()->isExtensionSupported<Extensions::GL::NV::texture_border_clamp>()) if(!Context::current()->isExtensionSupported<Extensions::GL::NV::texture_border_clamp>())
CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported.")); 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(); MAGNUM_VERIFY_NO_ERROR();
} }
#endif
#ifndef MAGNUM_TARGET_GLES2
void TextureGLTest::samplingDepthStencilMode3D() { void TextureGLTest::samplingDepthStencilMode3D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); 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; Texture3D texture;
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex); texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#else #endif
#ifdef MAGNUM_TARGET_GLES
void TextureGLTest::samplingBorder3D() { void TextureGLTest::samplingBorder3D() {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>()) if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>())

5
src/Magnum/Texture.h

@ -531,7 +531,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** /**
* @brief Set depth/stencil texture mode * @brief Set depth/stencil texture mode
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
@ -545,7 +545,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{DEPTH_STENCIL_TEXTURE_MODE} * with @def_gl{DEPTH_STENCIL_TEXTURE_MODE}
* @requires_gl43 %Extension @extension{ARB,stencil_texturing} * @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<dimensions>& setDepthStencilMode(Sampler::DepthStencilMode mode) { Texture<dimensions>& setDepthStencilMode(Sampler::DepthStencilMode mode) {
AbstractTexture::setDepthStencilMode(mode); AbstractTexture::setDepthStencilMode(mode);

2
src/Magnum/TextureArray.h

@ -236,7 +236,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** /**
* @copybrief Texture::setDepthStencilMode() * @copybrief Texture::setDepthStencilMode()
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)

Loading…
Cancel
Save