psyched
psyched

Reputation: 1939

OpenGL ES has different UV coordinates?

I use OpenGL ES 1.1 with texture mapping. I always thought that UV coordinate system for textures starts from the top-left and goes to bottom-right. This is fine on android, I have tested it. However, if I test it with Qt on the desktop, my UV coordinate system starts from the bottom-left and goes to top-right. Is that OK? I am using the same code to setup OpenGL

glViewport(0, 0, m_screenWidth, m_screenHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

#ifdef DESKTOP_QT
glOrtho(0, 1, 0, 1, -1, 1);
#else
glOrthof(0, 1, 0, 1, -1, 1);
#endif

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

Also I wonder, why there is glOrthof is not supported by Qt and glOrtho is not supported by Android? Is there a function that is common in both frameworks?

Upvotes: 2

Views: 3300

Answers (2)

Christian Rau
Christian Rau

Reputation: 45948

In OpenGL by default the texture coordinate (0,0) corresponds to the lower left corner of the texture. It has always been (and probably will always be) that way since OpenGL exists.

Nevertheless you can change this convention by altering the texture matrix or by just storing your texture flipped bottom to top.

And by the way, glOrtho has nothing to do with Qt or Android, it's an OpenGL function. So what you are probably experiencing is not a difference between Qt and Android, but between desktop OpenGL and OpenGL ES. But nevertheless texture coordinates should start at the bottom left corner in both versions.

Upvotes: 2

Kizik Studios
Kizik Studios

Reputation: 179

How do you know that the texture is starting from the bottom left and goes to the top right? I have never heard of this type of orientation for texture mapping.

Upvotes: 0

Related Questions