Original Post
okay, I got some weird problem going on... i'm trying to display a texture in "perspective mode" but it's somehow upside-down... however in "ortho-mode" it's the right way, even tho the texture coordinates are the same for both. The texture is manually generated inside the program, so the pixel(0,0) is at the beginning of memory array and (size,size) is at the end of the memory array, and I send this over to OpenGL just as it is. Then I draw my quads using the following code: Any ideas why the texture gets flipped in perspective mode?
// for ortho mode
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 800.0f, 600.0f, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2f( 0.0f, 64.0f);
glTexCoord2f(0.0f, 0.0f); glVertex2f( 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex2f(64.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex2f(64.0f, 64.0f);
glEnd();
// for perspective mode
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.333f, 1.0f, 5000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -164.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-32.0f, 32.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-32.0f,-32.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 32.0f,-32.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 32.0f, 32.0f, 0.0f);
glEnd();