When using mipmapped textures in your OpenGL applications you might sometimes notice that those textures are often severly blurred when the camera looks at the them from an oblique angle. That's because the texture mapping mode assumes that the texture space is a square - so isotropic - while in reality it's rather long and narrow - anisotropic. And here's where anisotropic filtering comes into the game which allows to increase texture quality of those textures.
So as we are dealing with an extension, it would be better to first check whether this extension is really supported by our graphics driver:
//check whether extension string can be found if (!strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_filter_anisotropic")) { // do whatever you want but don't // use anisotropic filtering ;-) }
Then we need two defines used by this extension. Either you include glext.h - link can be found in the code section - or you create the defines yourself:
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
If we are sure that anistropic filtering is supported, we are free to create our textures using this extension. Like setting what MIN_FILTER should be used for this texture, you also do the same here. The corresponding texture attribute is GL_TEXTURE_MAX_ANISOTROPY_EXT:
// texture creation code // ... glBindTexture(GL_TEXTURE_2D,texture); //... glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
float maximumAnistropy; //get the value glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
That's it! This extension really belongs to the most easiest ones to use. If you like you can compare filtered and non-filtered textures in the anistropic filtering test app I wrote. At the same time you might see that the effects aren't that overwhelming. Questions? Message Board! Happy Coding!