PDA

View Full Version : Is the origin of an image in the bottom left corner in OpenGL?



surgptr
05-01-2003, 09:24 AM
I have just added texture mapping to my app but when I map a texture it comes out upside down and I have to swap the ST co-ordinates to flip it the right way up.

The origin of my texture is top left and it is loaded into memory in that format. I verified that by doing a binary dump into a file and examining the contents with a hex editor after nearly pulling my hair out. http://www.opengl.org/discussion_boards/ubb/smile.gif

Now all the OpenGL tutorials I have come across map a quad like this :

glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (0.0, 0.0, 0.0); // Bottom left
glTexCoord2f (1.0, 0.0);
glVertex3f (10.0, 0.0, 0.0); // Bottom right
glTexCoord2f (1.0, 1.0);
glVertex3f (10.0, 10.0, 0.0); // Top right
glTexCoord2f (0.0, 1.0);
glVertex3f (0.0, 10.0, 0.0); // Top left
glEnd ();

When working with ST co-ordinates does (0,0) mean the bottom left corner in MEMORY or the top left corner in MEMORY?
According to me it means the top left corner in memory which means that all images should be loaded into OpenGL upside down, correct?

Thanks
Paul

Bob
05-01-2003, 09:46 AM
The origin is in the lower left corner.

surgptr
05-01-2003, 11:11 AM
Hmmm ... ok I'll just swap my ST co-ords since I like to work with my images right way up. http://www.opengl.org/discussion_boards/ubb/wink.gif

Thanks
Paul