Browse Source

Overloaded AbstractTexture methods in subclasses for better chaining.

Allows to conveniently set the data after fully configuring the texture,
so OpenGL can optimize the data to match the settings. Advice taken from
http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesForWorkingWithTextureData/TechniquesForWorkingWithTextureData.html#//apple_ref/doc/uid/TP40008793-CH104-SW1
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
9f7ae0b34f
  1. 3
      src/AbstractTexture.h
  2. 26
      src/CubeMapTexture.h
  3. 26
      src/CubeMapTextureArray.h
  4. 26
      src/Texture.h

3
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
*/

26
src/CubeMapTexture.h

@ -109,6 +109,32 @@ class CubeMapTexture: public AbstractTexture {
DataHelper<2>::setSub(this, static_cast<GLenum>(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<GLfloat>& 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
};
}

26
src/CubeMapTextureArray.h

@ -118,6 +118,32 @@ class CubeMapTextureArray: public AbstractTexture {
DataHelper<3>::setSub(this, GL_TEXTURE_CUBE_MAP_ARRAY, mipLevel, Math::Vector3<GLint>(offset, layer*6+static_cast<GLsizei>(coordinate)), image, Math::Vector<2, GLsizei>(Math::Vector<Image::Dimensions, GLsizei>()));
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<GLfloat>& 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
};
}

26
src/Texture.h

@ -188,6 +188,32 @@ template<std::uint8_t dimensions> class Texture: public AbstractTexture {
DataHelper<Dimensions>::setSub(this, _target, mipLevel, offset, image);
return this;
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
inline Texture<Dimensions>* setMinificationFilter(Filter filter, Mipmap mipmap = Mipmap::BaseLevel) {
AbstractTexture::setMinificationFilter(filter, mipmap);
return this;
}
inline Texture<Dimensions>* setMagnificationFilter(Filter filter) {
AbstractTexture::setMagnificationFilter(filter);
return this;
}
#ifndef MAGNUM_TARGET_GLES
inline Texture<Dimensions>* setBorderColor(const Color4<GLfloat>& color) {
AbstractTexture::setBorderColor(color);
return this;
}
inline Texture<Dimensions>* setMaxAnisotropy(GLfloat anisotropy) {
AbstractTexture::setMaxAnisotropy(anisotropy);
return this;
}
#endif
inline Texture<Dimensions>* generateMipmap() {
AbstractTexture::generateMipmap();
return this;
}
#endif
};
#ifndef MAGNUM_TARGET_GLES

Loading…
Cancel
Save