Browse Source

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.
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
bf1d2e26fa
  1. 2
      doc/opengl-support.dox
  2. 30
      src/Magnum/AbstractTexture.cpp
  3. 16
      src/Magnum/AbstractTexture.h
  4. 16
      src/Magnum/CubeMapTexture.h
  5. 14
      src/Magnum/CubeMapTextureArray.h
  6. 4
      src/Magnum/Implementation/TextureState.cpp
  7. 2
      src/Magnum/Implementation/TextureState.h
  8. 14
      src/Magnum/RectangleTexture.h
  9. 26
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  10. 34
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  11. 21
      src/Magnum/Test/RectangleTextureGLTest.cpp
  12. 40
      src/Magnum/Test/TextureArrayGLTest.cpp
  13. 42
      src/Magnum/Test/TextureGLTest.cpp
  14. 28
      src/Magnum/Texture.h
  15. 14
      src/Magnum/TextureArray.h

2
doc/opengl-support.dox

@ -71,7 +71,7 @@ following:
@extension{EXT,texture_shared_exponent} | done @extension{EXT,texture_shared_exponent} | done
@extension{EXT,framebuffer_sRGB} | | @extension{EXT,framebuffer_sRGB} | |
@extension{EXT,draw_buffers2} | | @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{EXT,transform_feedback} | |
@extension{NV,half_float} | done (GL 3.0 subset) @extension{NV,half_float} | done (GL 3.0 subset)
@extension{NV,depth_buffer_float} | | @extension{NV,depth_buffer_float} | |

30
src/Magnum/AbstractTexture.cpp

@ -162,6 +162,16 @@ void AbstractTexture::setBorderColor(const Color4& color) {
#endif #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) { void AbstractTexture::setMaxAnisotropy(const Float anisotropy) {
(this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy);
} }
@ -609,6 +619,26 @@ void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat
} }
#endif #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::setMaxAnisotropyImplementationNoOp(GLfloat) {}
void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) { void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {

16
src/Magnum/AbstractTexture.h

@ -245,6 +245,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap); void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap);
void setMagnificationFilter(Sampler::Filter filter); void setMagnificationFilter(Sampler::Filter filter);
void setBorderColor(const Color4& color); void setBorderColor(const Color4& color);
void setBorderColor(const Vector4i& color);
void setBorderColor(const Vector4ui& color);
void setMaxAnisotropy(Float anisotropy); void setMaxAnisotropy(Float anisotropy);
void invalidateImage(Int level); void invalidateImage(Int level);
void generateMipmap(); void generateMipmap();
@ -264,18 +266,18 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
#endif #endif
void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); 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, GLfloat value);
void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLfloat* values);
#ifndef MAGNUM_TARGET_GLES #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 #endif
void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, const GLfloat* values);
#ifndef MAGNUM_TARGET_GLES #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 GLfloat* values);
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLuint* values);
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLint* values);
#endif #endif
void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat);

16
src/Magnum/CubeMapTexture.h

@ -116,12 +116,26 @@ class CubeMapTexture: public AbstractTexture {
return *this; return *this;
} }
/** @copydoc Texture::setBorderColor() */ /** @copydoc Texture::setBorderColor(const Color4&) */
CubeMapTexture& setBorderColor(const Color4& color) { CubeMapTexture& setBorderColor(const Color4& color) {
AbstractTexture::setBorderColor(color); AbstractTexture::setBorderColor(color);
return *this; 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() */ /** @copydoc Texture::setMaxAnisotropy() */
CubeMapTexture& setMaxAnisotropy(Float anisotropy) { CubeMapTexture& setMaxAnisotropy(Float anisotropy) {
AbstractTexture::setMaxAnisotropy(anisotropy); AbstractTexture::setMaxAnisotropy(anisotropy);

14
src/Magnum/CubeMapTextureArray.h

@ -113,6 +113,20 @@ class CubeMapTextureArray: public AbstractTexture {
return *this; 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() */ /** @copydoc Texture::setMaxAnisotropy() */
CubeMapTextureArray& setMaxAnisotropy(Float anisotropy) { CubeMapTextureArray& setMaxAnisotropy(Float anisotropy) {
AbstractTexture::setMaxAnisotropy(anisotropy); AbstractTexture::setMaxAnisotropy(anisotropy);

4
src/Magnum/Implementation/TextureState.cpp

@ -63,6 +63,8 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
parameteriImplementation = &AbstractTexture::parameterImplementationDSA; parameteriImplementation = &AbstractTexture::parameterImplementationDSA;
parameterfImplementation = &AbstractTexture::parameterImplementationDSA; parameterfImplementation = &AbstractTexture::parameterImplementationDSA;
parameterfvImplementation = &AbstractTexture::parameterImplementationDSA; parameterfvImplementation = &AbstractTexture::parameterImplementationDSA;
parameterIuivImplementation = &AbstractTexture::parameterImplementationDSA;
parameterIivImplementation = &AbstractTexture::parameterImplementationDSA;
getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSA; getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSA;
mipmapImplementation = &AbstractTexture::mipmapImplementationDSA; mipmapImplementation = &AbstractTexture::mipmapImplementationDSA;
getImageImplementation = &AbstractTexture::getImageImplementationDSA; getImageImplementation = &AbstractTexture::getImageImplementationDSA;
@ -82,6 +84,8 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
parameterfImplementation = &AbstractTexture::parameterImplementationDefault; parameterfImplementation = &AbstractTexture::parameterImplementationDefault;
parameterfvImplementation = &AbstractTexture::parameterImplementationDefault; parameterfvImplementation = &AbstractTexture::parameterImplementationDefault;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
parameterIuivImplementation = &AbstractTexture::parameterImplementationDefault;
parameterIivImplementation = &AbstractTexture::parameterImplementationDefault;
getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault; getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault;
#endif #endif
mipmapImplementation = &AbstractTexture::mipmapImplementationDefault; mipmapImplementation = &AbstractTexture::mipmapImplementationDefault;

2
src/Magnum/Implementation/TextureState.h

@ -41,6 +41,8 @@ struct TextureState {
void(AbstractTexture::*parameteriImplementation)(GLenum, GLint); void(AbstractTexture::*parameteriImplementation)(GLenum, GLint);
void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat); void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat);
void(AbstractTexture::*parameterfvImplementation)(GLenum, const 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::*setMaxAnisotropyImplementation)(GLfloat);
void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*); void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*);
void(AbstractTexture::*mipmapImplementation)(); void(AbstractTexture::*mipmapImplementation)();

14
src/Magnum/RectangleTexture.h

@ -146,6 +146,20 @@ class RectangleTexture: public AbstractTexture {
return *this; 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() */ /** @copydoc Texture::setMaxAnisotropy() */
RectangleTexture& setMaxAnisotropy(Float anisotropy) { RectangleTexture& setMaxAnisotropy(Float anisotropy) {
AbstractTexture::setMaxAnisotropy(anisotropy); AbstractTexture::setMaxAnisotropy(anisotropy);

26
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -40,26 +40,38 @@ class CubeMapTextureArrayGLTest: public AbstractOpenGLTester {
explicit CubeMapTextureArrayGLTest(); explicit CubeMapTextureArrayGLTest();
void construct(); void construct();
void sampling(); void sampling();
void samplingBorderInteger();
void storage(); void storage();
void image(); void image();
void imageBuffer(); void imageBuffer();
void subImage(); void subImage();
void subImageBuffer(); void subImageBuffer();
void generateMipmap(); void generateMipmap();
void invalidateImage(); void invalidateImage();
void invalidateSubImage(); void invalidateSubImage();
}; };
CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() {
addTests({&CubeMapTextureArrayGLTest::construct, addTests({&CubeMapTextureArrayGLTest::construct,
&CubeMapTextureArrayGLTest::sampling, &CubeMapTextureArrayGLTest::sampling,
&CubeMapTextureArrayGLTest::samplingBorderInteger,
&CubeMapTextureArrayGLTest::storage, &CubeMapTextureArrayGLTest::storage,
&CubeMapTextureArrayGLTest::image, &CubeMapTextureArrayGLTest::image,
&CubeMapTextureArrayGLTest::imageBuffer, &CubeMapTextureArrayGLTest::imageBuffer,
&CubeMapTextureArrayGLTest::subImage, &CubeMapTextureArrayGLTest::subImage,
&CubeMapTextureArrayGLTest::subImageBuffer, &CubeMapTextureArrayGLTest::subImageBuffer,
&CubeMapTextureArrayGLTest::generateMipmap, &CubeMapTextureArrayGLTest::generateMipmap,
&CubeMapTextureArrayGLTest::invalidateImage, &CubeMapTextureArrayGLTest::invalidateImage,
&CubeMapTextureArrayGLTest::invalidateSubImage}); &CubeMapTextureArrayGLTest::invalidateSubImage});
} }
@ -92,6 +104,20 @@ void CubeMapTextureArrayGLTest::sampling() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
void CubeMapTextureArrayGLTest::samplingBorderInteger() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { void CubeMapTextureArrayGLTest::storage() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported."));

34
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -43,34 +43,52 @@ class CubeMapTextureGLTest: public AbstractOpenGLTester {
explicit CubeMapTextureGLTest(); explicit CubeMapTextureGLTest();
void construct(); void construct();
void sampling(); void sampling();
#ifndef MAGNUM_TARGET_GLES
void samplingBorderInteger();
#endif
void storage(); void storage();
void image(); void image();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void imageBuffer(); void imageBuffer();
#endif #endif
void subImage(); void subImage();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void subImageBuffer(); void subImageBuffer();
#endif #endif
void generateMipmap(); void generateMipmap();
void invalidateImage(); void invalidateImage();
void invalidateSubImage(); void invalidateSubImage();
}; };
CubeMapTextureGLTest::CubeMapTextureGLTest() { CubeMapTextureGLTest::CubeMapTextureGLTest() {
addTests({&CubeMapTextureGLTest::construct, addTests({&CubeMapTextureGLTest::construct,
&CubeMapTextureGLTest::sampling, &CubeMapTextureGLTest::sampling,
#ifndef MAGNUM_TARGET_GLES
&CubeMapTextureGLTest::samplingBorderInteger,
#endif
&CubeMapTextureGLTest::storage, &CubeMapTextureGLTest::storage,
&CubeMapTextureGLTest::image, &CubeMapTextureGLTest::image,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::imageBuffer, &CubeMapTextureGLTest::imageBuffer,
#endif #endif
&CubeMapTextureGLTest::subImage, &CubeMapTextureGLTest::subImage,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
&CubeMapTextureGLTest::subImageBuffer, &CubeMapTextureGLTest::subImageBuffer,
#endif #endif
&CubeMapTextureGLTest::generateMipmap, &CubeMapTextureGLTest::generateMipmap,
&CubeMapTextureGLTest::invalidateImage, &CubeMapTextureGLTest::invalidateImage,
&CubeMapTextureGLTest::invalidateSubImage}); &CubeMapTextureGLTest::invalidateSubImage});
} }
@ -97,6 +115,22 @@ void CubeMapTextureGLTest::sampling() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifndef MAGNUM_TARGET_GLES
void CubeMapTextureGLTest::samplingBorderInteger() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { void CubeMapTextureGLTest::storage() {
CubeMapTexture texture; CubeMapTexture texture;
texture.setStorage(5, TextureFormat::RGBA8, Vector2i(32)); texture.setStorage(5, TextureFormat::RGBA8, Vector2i(32));

21
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -41,12 +41,14 @@ class TextureGLTest: public AbstractOpenGLTester {
explicit TextureGLTest(); explicit TextureGLTest();
void construct(); void construct();
void sampling(); void sampling();
void samplingBorderInteger();
void storage(); void storage();
void image(); void image();
void imageBuffer(); void imageBuffer();
void subImage(); void subImage();
void subImageBuffer(); void subImageBuffer();
@ -56,7 +58,10 @@ class TextureGLTest: public AbstractOpenGLTester {
TextureGLTest::TextureGLTest() { TextureGLTest::TextureGLTest() {
addTests({&TextureGLTest::construct, addTests({&TextureGLTest::construct,
&TextureGLTest::sampling, &TextureGLTest::sampling,
&TextureGLTest::samplingBorderInteger,
&TextureGLTest::storage, &TextureGLTest::storage,
&TextureGLTest::image, &TextureGLTest::image,
@ -97,6 +102,20 @@ void TextureGLTest::sampling() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
void TextureGLTest::samplingBorderInteger() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { void TextureGLTest::storage() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));

40
src/Magnum/Test/TextureArrayGLTest.cpp

@ -50,7 +50,10 @@ class TextureGLTest: public AbstractOpenGLTester {
#endif #endif
void sampling2DArray(); void sampling2DArray();
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void samplingBorderInteger1DArray();
void samplingBorderInteger2DArray();
#else
void samplingBorder2DArray(); void samplingBorder2DArray();
#endif #endif
@ -103,7 +106,10 @@ TextureGLTest::TextureGLTest() {
#endif #endif
&TextureGLTest::sampling2DArray, &TextureGLTest::sampling2DArray,
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::samplingBorderInteger1DArray,
&TextureGLTest::samplingBorderInteger2DArray,
#else
&TextureGLTest::samplingBorder2DArray, &TextureGLTest::samplingBorder2DArray,
#endif #endif
@ -189,6 +195,20 @@ void TextureGLTest::sampling1DArray() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
void TextureGLTest::samplingBorderInteger1DArray() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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 #endif
void TextureGLTest::sampling2DArray() { void TextureGLTest::sampling2DArray() {
@ -211,7 +231,21 @@ void TextureGLTest::sampling2DArray() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::samplingBorderInteger2DArray() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { void TextureGLTest::samplingBorder2DArray() {
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."));

42
src/Magnum/Test/TextureGLTest.cpp

@ -54,7 +54,10 @@ class TextureGLTest: public AbstractOpenGLTester {
void sampling2D(); void sampling2D();
void sampling3D(); void sampling3D();
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void samplingBorderInteger2D();
void samplingBorderInteger3D();
#else
void samplingBorder2D(); void samplingBorder2D();
void samplingBorder3D(); void samplingBorder3D();
#endif #endif
@ -126,7 +129,10 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::sampling2D, &TextureGLTest::sampling2D,
&TextureGLTest::sampling3D, &TextureGLTest::sampling3D,
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&TextureGLTest::samplingBorderInteger2D,
&TextureGLTest::samplingBorderInteger3D,
#else
&TextureGLTest::samplingBorder2D, &TextureGLTest::samplingBorder2D,
&TextureGLTest::samplingBorder3D, &TextureGLTest::samplingBorder3D,
#endif #endif
@ -251,7 +257,21 @@ void TextureGLTest::sampling2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::samplingBorderInteger2D() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { 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."));
@ -284,7 +304,21 @@ void TextureGLTest::sampling3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
} }
#ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void TextureGLTest::samplingBorderInteger3D() {
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_integer>())
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() { 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>())

28
src/Magnum/Texture.h

@ -261,6 +261,34 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
return *this; 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<dimensions>& setBorderColor(const Vector4ui& color) {
AbstractTexture::setBorderColor(color);
return *this;
}
/** @overload */
Texture<dimensions>& setBorderColor(const Vector4i& color) {
AbstractTexture::setBorderColor(color);
return *this;
}
#endif
/** /**
* @brief Set max anisotropy * @brief Set max anisotropy
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)

14
src/Magnum/TextureArray.h

@ -131,6 +131,20 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
return *this; return *this;
} }
#ifndef MAGNUM_TARGET_GLES
/** @copydoc Texture::setBorderColor(const Vector4ui&) */
TextureArray<dimensions>& setBorderColor(const Vector4ui& color) {
AbstractTexture::setBorderColor(color);
return *this;
}
/** @copydoc Texture::setBorderColor(const Vector4i&) */
TextureArray<dimensions>& setBorderColor(const Vector4i& color) {
AbstractTexture::setBorderColor(color);
return *this;
}
#endif
/** @copydoc Texture::setMaxAnisotropy() */ /** @copydoc Texture::setMaxAnisotropy() */
TextureArray<dimensions>& setMaxAnisotropy(Float anisotropy) { TextureArray<dimensions>& setMaxAnisotropy(Float anisotropy) {
AbstractTexture::setMaxAnisotropy(anisotropy); AbstractTexture::setMaxAnisotropy(anisotropy);

Loading…
Cancel
Save