Direct State AccessGL 4.5
glTextureParameterf
Sets one floating-point setting of a texture, such as anisotropic filtering or LOD bias.
Signature
void glTextureParameterf(GLuint texture, GLenum pname, GLfloat param);
How it works
The same as glTextureParameteri for settings whose value is a number with a fraction. The one you will use most is GL_TEXTURE_MAX_ANISOTROPY: it keeps floors and roads sharp when seen at a grazing angle, where plain mipmapping blurs them. 16 is the usual maximum, and it costs very little on modern GPUs.
Parameters
textureGLuint
The texture.
pnameGLenum
Which setting.
Common values
- GL_TEXTURE_MAX_ANISOTROPY
- 1 = off, up to GL_MAX_TEXTURE_MAX_ANISOTROPY (usually 16). Core in GL 4.6, an extension (…_EXT) before.
- GL_TEXTURE_LOD_BIAS
- Shifts the chosen mip level: negative = sharper, positive = blurrier.
- GL_TEXTURE_MIN_LOD / GL_TEXTURE_MAX_LOD
- Clamp the level of detail.
paramGLfloat
The new value.
Tips & pitfalls
Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.
Example
example.cpp
1GLfloat maxAniso = 1.0f;
2glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &maxAniso);
3glTextureParameterf(tex, GL_TEXTURE_MAX_ANISOTROPY, std::min(16.0f, maxAniso));