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;
}