From bf1d2e26fa19f898cde76de4347618de35162763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 28 Mar 2014 12:15:38 +0100 Subject: [PATCH] Support for setting border color on integer textures. EXT_texture_integer implementation is now complete. Just GL 3.0 subset, though, as apparently glClearColorI*() is not part of it. --- doc/opengl-support.dox | 2 +- src/Magnum/AbstractTexture.cpp | 30 +++++++++++++ src/Magnum/AbstractTexture.h | 16 +++---- src/Magnum/CubeMapTexture.h | 16 ++++++- src/Magnum/CubeMapTextureArray.h | 14 +++++++ src/Magnum/Implementation/TextureState.cpp | 4 ++ src/Magnum/Implementation/TextureState.h | 2 + src/Magnum/RectangleTexture.h | 14 +++++++ src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 26 ++++++++++++ src/Magnum/Test/CubeMapTextureGLTest.cpp | 34 +++++++++++++++ src/Magnum/Test/RectangleTextureGLTest.cpp | 21 +++++++++- src/Magnum/Test/TextureArrayGLTest.cpp | 40 ++++++++++++++++-- src/Magnum/Test/TextureGLTest.cpp | 42 +++++++++++++++++-- src/Magnum/Texture.h | 28 +++++++++++++ src/Magnum/TextureArray.h | 14 +++++++ 15 files changed, 286 insertions(+), 17 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 9da8957c3..ed585c8ab 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -71,7 +71,7 @@ following: @extension{EXT,texture_shared_exponent} | done @extension{EXT,framebuffer_sRGB} | | @extension{EXT,draw_buffers2} | | -@extension{EXT,texture_integer} | missing integer color specification functions +@extension{EXT,texture_integer} | done (GL 3.0 subset) @extension{EXT,transform_feedback} | | @extension{NV,half_float} | done (GL 3.0 subset) @extension{NV,depth_buffer_float} | | diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 26d668a75..427f90140 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -162,6 +162,16 @@ void AbstractTexture::setBorderColor(const Color4& color) { #endif } +#ifndef MAGNUM_TARGET_GLES +void AbstractTexture::setBorderColor(const Vector4ui& color) { + (this->*Context::current()->state().texture->parameterIuivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); +} + +void AbstractTexture::setBorderColor(const Vector4i& color) { + (this->*Context::current()->state().texture->parameterIivImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); +} +#endif + void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); } @@ -609,6 +619,26 @@ void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat } #endif +#ifndef MAGNUM_TARGET_GLES +void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLuint* values) { + bindInternal(); + glTexParameterIuiv(_target, parameter, values); +} + +void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLuint* values) { + glTextureParameterIuivEXT(_id, _target, parameter, values); +} + +void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLint* values) { + bindInternal(); + glTexParameterIiv(_target, parameter, values); +} + +void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLint* values) { + glTextureParameterIivEXT(_id, _target, parameter, values); +} +#endif + void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {} void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) { diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 263094e53..d0ab656f1 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -245,6 +245,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap); void setMagnificationFilter(Sampler::Filter filter); void setBorderColor(const Color4& color); + void setBorderColor(const Vector4i& color); + void setBorderColor(const Vector4ui& color); void setMaxAnisotropy(Float anisotropy); void invalidateImage(Int level); void generateMipmap(); @@ -264,18 +266,18 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #endif void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); - #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLint value); - #endif - void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLfloat value); + void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLfloat* values); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLfloat value); + void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLuint* values); + void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLint* values); #endif - - void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLfloat* values); #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLint value); + void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLfloat value); void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLfloat* values); + void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLuint* values); + void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLint* values); #endif void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 7b2ce1363..d750fd99d 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -116,12 +116,26 @@ class CubeMapTexture: public AbstractTexture { return *this; } - /** @copydoc Texture::setBorderColor() */ + /** @copydoc Texture::setBorderColor(const Color4&) */ CubeMapTexture& setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setBorderColor(const Vector4ui&) */ + CubeMapTexture& setBorderColor(const Vector4ui& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + + /** @copydoc Texture::setBorderColor(const Vector4i&) */ + CubeMapTexture& setBorderColor(const Vector4i& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + #endif + /** @copydoc Texture::setMaxAnisotropy() */ CubeMapTexture& setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 22cc837cc..5ec43b656 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -113,6 +113,20 @@ class CubeMapTextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setBorderColor(const Vector4ui&) */ + CubeMapTextureArray& setBorderColor(const Vector4ui& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + + /** @copydoc Texture::setBorderColor(const Vector4i&) */ + CubeMapTextureArray& setBorderColor(const Vector4i& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + #endif + /** @copydoc Texture::setMaxAnisotropy() */ CubeMapTextureArray& setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index 536f6a7b9..beae61381 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -63,6 +63,8 @@ TextureState::TextureState(Context& context, std::vector& extension parameteriImplementation = &AbstractTexture::parameterImplementationDSA; parameterfImplementation = &AbstractTexture::parameterImplementationDSA; parameterfvImplementation = &AbstractTexture::parameterImplementationDSA; + parameterIuivImplementation = &AbstractTexture::parameterImplementationDSA; + parameterIivImplementation = &AbstractTexture::parameterImplementationDSA; getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSA; mipmapImplementation = &AbstractTexture::mipmapImplementationDSA; getImageImplementation = &AbstractTexture::getImageImplementationDSA; @@ -82,6 +84,8 @@ TextureState::TextureState(Context& context, std::vector& extension parameterfImplementation = &AbstractTexture::parameterImplementationDefault; parameterfvImplementation = &AbstractTexture::parameterImplementationDefault; #ifndef MAGNUM_TARGET_GLES + parameterIuivImplementation = &AbstractTexture::parameterImplementationDefault; + parameterIivImplementation = &AbstractTexture::parameterImplementationDefault; getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault; #endif mipmapImplementation = &AbstractTexture::mipmapImplementationDefault; diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index f6dec2d7c..f4ef89d69 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -41,6 +41,8 @@ struct TextureState { void(AbstractTexture::*parameteriImplementation)(GLenum, GLint); void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat); void(AbstractTexture::*parameterfvImplementation)(GLenum, const GLfloat*); + void(AbstractTexture::*parameterIuivImplementation)(GLenum, const GLuint*); + void(AbstractTexture::*parameterIivImplementation)(GLenum, const GLint*); void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*); void(AbstractTexture::*mipmapImplementation)(); diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 034e44dd9..17a49372c 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -146,6 +146,20 @@ class RectangleTexture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setBorderColor(const Vector4ui&) */ + RectangleTexture& setBorderColor(const Vector4ui& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + + /** @copydoc Texture::setBorderColor(const Vector4i&) */ + RectangleTexture& setBorderColor(const Vector4i& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + #endif + /** @copydoc Texture::setMaxAnisotropy() */ RectangleTexture& setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy); diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index e3da6a916..94e187714 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -40,26 +40,38 @@ class CubeMapTextureArrayGLTest: public AbstractOpenGLTester { explicit CubeMapTextureArrayGLTest(); void construct(); + void sampling(); + void samplingBorderInteger(); + void storage(); + void image(); void imageBuffer(); void subImage(); void subImageBuffer(); + void generateMipmap(); + void invalidateImage(); void invalidateSubImage(); }; CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { addTests({&CubeMapTextureArrayGLTest::construct, + &CubeMapTextureArrayGLTest::sampling, + &CubeMapTextureArrayGLTest::samplingBorderInteger, + &CubeMapTextureArrayGLTest::storage, + &CubeMapTextureArrayGLTest::image, &CubeMapTextureArrayGLTest::imageBuffer, &CubeMapTextureArrayGLTest::subImage, &CubeMapTextureArrayGLTest::subImageBuffer, + &CubeMapTextureArrayGLTest::generateMipmap, + &CubeMapTextureArrayGLTest::invalidateImage, &CubeMapTextureArrayGLTest::invalidateSubImage}); } @@ -92,6 +104,20 @@ void CubeMapTextureArrayGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +void CubeMapTextureArrayGLTest::samplingBorderInteger() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + CubeMapTextureArray a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + CubeMapTextureArray b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + 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 6e4d75a77..a66ca896e 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -43,34 +43,52 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester { explicit CubeMapTextureGLTest(); void construct(); + void sampling(); + #ifndef MAGNUM_TARGET_GLES + void samplingBorderInteger(); + #endif + void storage(); + void image(); #ifndef MAGNUM_TARGET_GLES2 void imageBuffer(); #endif + void subImage(); #ifndef MAGNUM_TARGET_GLES2 void subImageBuffer(); #endif + void generateMipmap(); + void invalidateImage(); void invalidateSubImage(); }; CubeMapTextureGLTest::CubeMapTextureGLTest() { addTests({&CubeMapTextureGLTest::construct, + &CubeMapTextureGLTest::sampling, + #ifndef MAGNUM_TARGET_GLES + &CubeMapTextureGLTest::samplingBorderInteger, + #endif + &CubeMapTextureGLTest::storage, + &CubeMapTextureGLTest::image, #ifndef MAGNUM_TARGET_GLES2 &CubeMapTextureGLTest::imageBuffer, #endif + &CubeMapTextureGLTest::subImage, #ifndef MAGNUM_TARGET_GLES2 &CubeMapTextureGLTest::subImageBuffer, #endif + &CubeMapTextureGLTest::generateMipmap, + &CubeMapTextureGLTest::invalidateImage, &CubeMapTextureGLTest::invalidateSubImage}); } @@ -97,6 +115,22 @@ void CubeMapTextureGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +#ifndef MAGNUM_TARGET_GLES +void CubeMapTextureGLTest::samplingBorderInteger() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + CubeMapTexture a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + CubeMapTexture b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} +#endif + void CubeMapTextureGLTest::storage() { CubeMapTexture texture; texture.setStorage(5, TextureFormat::RGBA8, Vector2i(32)); diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index e4ff02c4e..eedb2cdea 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -41,12 +41,14 @@ class TextureGLTest: public AbstractOpenGLTester { explicit TextureGLTest(); void construct(); + void sampling(); + void samplingBorderInteger(); + void storage(); void image(); void imageBuffer(); - void subImage(); void subImageBuffer(); @@ -56,7 +58,10 @@ class TextureGLTest: public AbstractOpenGLTester { TextureGLTest::TextureGLTest() { addTests({&TextureGLTest::construct, + &TextureGLTest::sampling, + &TextureGLTest::samplingBorderInteger, + &TextureGLTest::storage, &TextureGLTest::image, @@ -97,6 +102,20 @@ void TextureGLTest::sampling() { MAGNUM_VERIFY_NO_ERROR(); } +void TextureGLTest::samplingBorderInteger() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + RectangleTexture a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + RectangleTexture b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} + void TextureGLTest::storage() { 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 2c2eccfde..0a35c44c2 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -50,7 +50,10 @@ class TextureGLTest: public AbstractOpenGLTester { #endif void sampling2DArray(); - #ifdef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES + void samplingBorderInteger1DArray(); + void samplingBorderInteger2DArray(); + #else void samplingBorder2DArray(); #endif @@ -103,7 +106,10 @@ TextureGLTest::TextureGLTest() { #endif &TextureGLTest::sampling2DArray, - #ifdef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES + &TextureGLTest::samplingBorderInteger1DArray, + &TextureGLTest::samplingBorderInteger2DArray, + #else &TextureGLTest::samplingBorder2DArray, #endif @@ -189,6 +195,20 @@ void TextureGLTest::sampling1DArray() { MAGNUM_VERIFY_NO_ERROR(); } + +void TextureGLTest::samplingBorderInteger1DArray() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + Texture1DArray a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + Texture1DArray b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} #endif void TextureGLTest::sampling2DArray() { @@ -211,7 +231,21 @@ void TextureGLTest::sampling2DArray() { MAGNUM_VERIFY_NO_ERROR(); } -#ifdef MAGNUM_TARGET_GLES +#ifndef MAGNUM_TARGET_GLES +void TextureGLTest::samplingBorderInteger2DArray() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + Texture2DArray a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + Texture2DArray b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} +#else void TextureGLTest::samplingBorder2DArray() { 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 79a9368ae..e208c4f8d 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -54,7 +54,10 @@ class TextureGLTest: public AbstractOpenGLTester { void sampling2D(); void sampling3D(); - #ifdef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES + void samplingBorderInteger2D(); + void samplingBorderInteger3D(); + #else void samplingBorder2D(); void samplingBorder3D(); #endif @@ -126,7 +129,10 @@ TextureGLTest::TextureGLTest() { &TextureGLTest::sampling2D, &TextureGLTest::sampling3D, - #ifdef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES + &TextureGLTest::samplingBorderInteger2D, + &TextureGLTest::samplingBorderInteger3D, + #else &TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder3D, #endif @@ -251,7 +257,21 @@ void TextureGLTest::sampling2D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifdef MAGNUM_TARGET_GLES +#ifndef MAGNUM_TARGET_GLES +void TextureGLTest::samplingBorderInteger2D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + Texture2D a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + Texture2D b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} +#else void TextureGLTest::samplingBorder2D() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::texture_border_clamp::string() + std::string(" is not supported.")); @@ -284,7 +304,21 @@ void TextureGLTest::sampling3D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifdef MAGNUM_TARGET_GLES +#ifndef MAGNUM_TARGET_GLES +void TextureGLTest::samplingBorderInteger3D() { + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); + + Texture3D a; + a.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4i(1, 56, 78, -2)); + Texture3D b; + b.setWrapping(Sampler::Wrapping::ClampToBorder) + .setBorderColor(Vector4ui(35, 56, 78, 15)); + + MAGNUM_VERIFY_NO_ERROR(); +} +#else void TextureGLTest::samplingBorder3D() { #ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported()) diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 6edcefa75..0f1ecf236 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -261,6 +261,34 @@ template class Texture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Set border color for integer texture + * @return Reference to self (for method chaining) + * + * Border color for integer textures when wrapping is set to + * @ref Sampler::Wrapping::ClampToBorder. If @extension{EXT,direct_state_access} + * is not available, the texture is bound to some texture unit before + * the operation. Initial value is `{0, 0, 0, 0}`. + * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} + * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} + * with @def_gl{TEXTURE_BORDER_COLOR} + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gl Border is available only for float textures in OpenGL + * ES. + */ + Texture& setBorderColor(const Vector4ui& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + + /** @overload */ + Texture& setBorderColor(const Vector4i& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + #endif + /** * @brief Set max anisotropy * @return Reference to self (for method chaining) diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 578fcb6a2..dcf983c14 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -131,6 +131,20 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_GLES + /** @copydoc Texture::setBorderColor(const Vector4ui&) */ + TextureArray& setBorderColor(const Vector4ui& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + + /** @copydoc Texture::setBorderColor(const Vector4i&) */ + TextureArray& setBorderColor(const Vector4i& color) { + AbstractTexture::setBorderColor(color); + return *this; + } + #endif + /** @copydoc Texture::setMaxAnisotropy() */ TextureArray& setMaxAnisotropy(Float anisotropy) { AbstractTexture::setMaxAnisotropy(anisotropy);