Anisotropic Filtering Help

Hello people! Myself, along with a couple of friends, have been attempting to implement a small, textured, 3-dimensional house. For the most part, everything has gone quite swimmingly, but we’ve encountered a problem where images appear to be awkwardly stretched if viewed from a weird angle. A quick Google search seemed to hint that this problem required us to implement Anisotropic filtering, though very little is actually available in terms of code we can utilize.

If anyone could tell us why this fails to change anything, I would be most appreciative!

Below is our entire LoadTexture function.

float maxA;
GLuint LoadTexture(const char*filename, int width, int height)
{
GLuint texture;
unsigned char * data;
FILE * file;

file = fopen(filename, "rb");
if (file == NULL) return 0;
data = (unsigned char *)malloc(width*height*3);
fread(data, width*height*3,1,file);
fclose(file);

[b]glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxA);[/b]
glGenTextures(1,&texture);
glBindTexture(GL_TEXTURE_2D,texture);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
[b]glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,maxA);//Anisotropic Filtering Attempt[/b]


glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,data);
free(data);
return texture;

}

Because, according to the extension spec, anisotropic filtering doesn’t work unless you have mipmaps.

Thank you, and done!

glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data );

I’ve noticed a change, but the textures still appear stretched, leading me to believe that something is still wrong with my attempt to filter. Any other suggestions?

Your GL_TEXTURE_MAG_FILTER should be just GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR is not a legal value for it.

Changed! Thank you too! Though the problem remains. I figured I’d throw a screencap in too.

I know, I know. Very “Intro to Computer Graphics”. But as you can see the grass in particular, looks really bad unless you move the camera downward, then the image quality improves. Any ideas?

This is false. Anisotropy is orthogonal to other filtering state.

Consider 2D blits:
http://developer.download.nvidia.com/SDK…oDecimation.pdf