diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index c9e4b16ec..f53d7c690 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -63,6 +63,9 @@ To achieve least state changes, fully configure each texture in one run -- method chaining comes in handy -- and try to have often used textures in dedicated layers, not occupied by other textures. +Always fully configure the texture before setting the texture data, so OpenGL +can optimize the data to match your settings. + @todo Add glPixelStore encapsulation @todo Texture copying */ diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index ef5de7806..110214c42 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -109,6 +109,32 @@ class CubeMapTexture: public AbstractTexture { DataHelper<2>::setSub(this, static_cast(coordinate), mipLevel, offset, image); return this; } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + inline CubeMapTexture* setMinificationFilter(Filter filter, Mipmap mipmap = Mipmap::BaseLevel) { + AbstractTexture::setMinificationFilter(filter, mipmap); + return this; + } + inline CubeMapTexture* setMagnificationFilter(Filter filter) { + AbstractTexture::setMagnificationFilter(filter); + return this; + } + #ifndef MAGNUM_TARGET_GLES + inline CubeMapTexture* setBorderColor(const Color4& color) { + AbstractTexture::setBorderColor(color); + return this; + } + inline CubeMapTexture* setMaxAnisotropy(GLfloat anisotropy) { + AbstractTexture::setMaxAnisotropy(anisotropy); + return this; + } + #endif + inline CubeMapTexture* generateMipmap() { + AbstractTexture::generateMipmap(); + return this; + } + #endif }; } diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 0af738bef..165e38e54 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -118,6 +118,32 @@ class CubeMapTextureArray: public AbstractTexture { DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, Math::Vector3(offset, layer*6+static_cast(coordinate)), image, Math::Vector<2, GLsizei>(Math::Vector())); return this; } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + inline CubeMapTextureArray* setMinificationFilter(Filter filter, Mipmap mipmap = Mipmap::BaseLevel) { + AbstractTexture::setMinificationFilter(filter, mipmap); + return this; + } + inline CubeMapTextureArray* setMagnificationFilter(Filter filter) { + AbstractTexture::setMagnificationFilter(filter); + return this; + } + #ifndef MAGNUM_TARGET_GLES + inline CubeMapTextureArray* setBorderColor(const Color4& color) { + AbstractTexture::setBorderColor(color); + return this; + } + inline CubeMapTextureArray* setMaxAnisotropy(GLfloat anisotropy) { + AbstractTexture::setMaxAnisotropy(anisotropy); + return this; + } + #endif + inline CubeMapTextureArray* generateMipmap() { + AbstractTexture::generateMipmap(); + return this; + } + #endif }; } diff --git a/src/Texture.h b/src/Texture.h index dcbc3a190..0dd5bcf2d 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -188,6 +188,32 @@ template class Texture: public AbstractTexture { DataHelper::setSub(this, _target, mipLevel, offset, image); return this; } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + inline Texture* setMinificationFilter(Filter filter, Mipmap mipmap = Mipmap::BaseLevel) { + AbstractTexture::setMinificationFilter(filter, mipmap); + return this; + } + inline Texture* setMagnificationFilter(Filter filter) { + AbstractTexture::setMagnificationFilter(filter); + return this; + } + #ifndef MAGNUM_TARGET_GLES + inline Texture* setBorderColor(const Color4& color) { + AbstractTexture::setBorderColor(color); + return this; + } + inline Texture* setMaxAnisotropy(GLfloat anisotropy) { + AbstractTexture::setMaxAnisotropy(anisotropy); + return this; + } + #endif + inline Texture* generateMipmap() { + AbstractTexture::generateMipmap(); + return this; + } + #endif }; #ifndef MAGNUM_TARGET_GLES