Browse Source

Texture Filter and Mipmap enum refactoring.

Renamed the constants so they are better readable when passed to
setMinificationFilter(). Using self-documenting values for Mipmap enum,
added static_assert which checks their correctness.
vectorfields
Vladimír Vondruš 15 years ago
parent
commit
c51ea03b5b
  1. 11
      src/Texture.cpp
  2. 14
      src/Texture.h

11
src/Texture.cpp

@ -17,6 +17,17 @@
namespace Magnum {
/* Check correctness of binary OR in setMinificationFilter(). If nobody fucks
anything up, this assert should produce the same results on all dimensions,
thus testing only on Texture1D. */
static_assert(((Texture1D::NearestNeighborFilter|Texture1D::BaseMipLevel) == GL_NEAREST) &&
((Texture1D::NearestNeighborFilter|Texture1D::NearestMipLevel) == GL_NEAREST_MIPMAP_NEAREST) &&
((Texture1D::NearestNeighborFilter|Texture1D::LinearMipInterpolation) == GL_NEAREST_MIPMAP_LINEAR) &&
((Texture1D::LinearFilter|Texture1D::BaseMipLevel) == GL_LINEAR) &&
((Texture1D::LinearFilter|Texture1D::NearestMipLevel) == GL_LINEAR_MIPMAP_NEAREST) &&
((Texture1D::LinearFilter|Texture1D::LinearMipInterpolation) == GL_LINEAR_MIPMAP_LINEAR),
"Unsupported constants for GL texture filtering");
template<size_t dimensions> void Texture<dimensions>::setWrapping(const Math::Vector<Wrapping, dimensions>& wrapping) {
bind();
for(int i = 0; i != dimensions; ++i) switch(i) {

14
src/Texture.h

@ -43,30 +43,30 @@ template<size_t dimensions> class Texture {
/**
* Nearest neighbor filtering
*/
NearestNeighbor = GL_NEAREST,
NearestNeighborFilter = GL_NEAREST,
/**
* Linear filtering
*/
Linear = GL_LINEAR
LinearFilter = GL_LINEAR
};
/** @brief Mip level selection */
enum Mipmap {
/**
* Select base mipmap level.
* Select base mip level.
*/
BaseLevel = 0,
BaseMipLevel = GL_NEAREST & ~GL_NEAREST,
/**
* Select nearest mip level.
*/
NearestLevel = 0x100,
NearestMipLevel = GL_NEAREST_MIPMAP_NEAREST & ~GL_NEAREST,
/**
* Linear interpolation of nearest mip levels.
*/
LinearInterpolation = 0x102
LinearMipInterpolation = GL_NEAREST_MIPMAP_LINEAR & ~GL_NEAREST
};
/** @brief Texture wrapping on the edge */
@ -161,7 +161,7 @@ template<size_t dimensions> class Texture {
* creating the texture, otherwise it will be unusable.
* @see generateMipmap()
*/
inline void setMinificationFilter(Filter filter, Mipmap mipmap = BaseLevel) {
inline void setMinificationFilter(Filter filter, Mipmap mipmap = BaseMipLevel) {
bind();
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filter|mipmap);
unbind();

Loading…
Cancel
Save