PDA

View Full Version : Mipmapping Problem

Katun
04-23-2012, 10:23 AM
I'm using the following code to draw a 256x256 .tga texture and it works just fine:

....

for(int n = 0; n < 1; n++){
glGenTextures(1, &amp;texture[n].texID);
glBindTexture(GL_TEXTURE_2D, texture[n].texID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture[n].width, texture[n].height, GL_RGB, GL_UNSIGNED_BYTE, texture[n].imageData);}

....

glBindTexture(GL_TEXTURE_2D, texture[0].texID);

int c[][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0, 0, 1}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}};
int p[][4] = {{4, 5, 7, 6}, {4, 6, 2, 0}, {7, 5, 1, 3}, {5, 4, 0, 1}, {6, 7, 3, 2}};

for(int a = 0; a < 4; a++){
glTexCoord2f(a%3 > 0, a < 2);
glVertex3f((a%3 > 0)*256, c[p[0][a]][1]*256, 0);}

glEnd();

....

Now when I use a 220x204 texture (with glVertex3f((a%3 > 0)*220, c[p[0][a]][1]*204, 0); ), it comes out all blurry: see the attached pictures. My guess was that this is a mipmapping issue and that gluBuild2DMipmaps was supposed to fix it, but it doesn't.
So what am I doing wrong? It's probably a simple mistake since I'm quite a newbie.