View Full Version : opengl coordinate system

02-10-2011, 07:26 PM
I find the OpenGL Co-ordinate system really hard to use. I would much rather have things like glVertex2f(-100,-100) put a vertex back 100 pixels in the X and Y direction from the origin, instead of it being totally off the screen. Is there any way that I can do this? I was thinking mabey just glTranslate'ing out in the Z direction but I am not sure if this will work.

02-10-2011, 10:52 PM
If you want to use pixel coordinates, use the correct projection, like for example :
glLoadIdentity ();
glOrtho(0, WindowWidthInPixels, 0, WindowHeightInPixels, -1, 1);

02-10-2011, 10:57 PM
Thanks for your answer.
When I use that method, the origin (0,0) seems to be at the bottom left corner of the screen. Is there anyway to make it the top right? I don't really understand the left, right, top, bottom paramaters.

02-10-2011, 10:58 PM
With GL u decide what to do. As pointed out by ZBuffer set the appropriate projection matrix and u will have what u want.

02-11-2011, 01:23 AM
Top right ? This is unusual.
left, right, top, bottom paramaters define the range of GL coordinates visible on the glViewPort. So reverse order to reverse axes, like :