OpenGL ES has different UV coordinates?

五迷三道 提交于 2019-12-18 09:08:23

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8619584/opengl-es-has-different-uv-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!