PDA

View Full Version : glOrtho() Mirror Image



Pan007
10-18-2011, 06:59 AM
Hello,

I am using glOrtho command to set the camera viewing positions for my opengl window in QT, I need to make center of the screen as orgin.But, when I load any texture on GL window it appears like mirror Image. I am doing as below.

glViewport(0.0f, 0.0f, 650, 800);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-325 , 325, -350, 250, -15, 15);
glMatrixMode(GL_MODELVIEW);

when I change the glOrtho statement to
glOrtho(-325 , 325, 250, -350, -15, 15); it works, I mean texture would be shown normally. But I know there is something wrong because this is against specification of glOrtho().

How to set the view origin to center without effecting on other primitives or textures?

V-man
10-18-2011, 08:49 AM
when I change the glOrtho statement to
glOrtho(-325 , 325, 250, -350, -15, 15); it works, I mean texture would be shown normally. But I know there is something wrong because this is against specification of glOrtho().

It isn't against the specification.



How to set the view origin to center without effecting on other primitives or textures?

you call
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-325 , 325, -350, 250, -15, 15);

after you are done rendering your quad with that texture.

Aleksandar
10-18-2011, 09:31 AM
I bet that the problem is not in the projection but in the way you map the texture!

Change t-koordinates of the vertices and everything will be just fine. ;)

Pan007
10-19-2011, 12:45 AM
Yes Thank you Aleksandar! you are right..
I am using glTexCoord2d() with wrong quadrants.
Thanks for the link V-man, Now I have to explore about the GLU stuff
Thanks Again!