PDA

View Full Version : strange OpenGL coordinates?



Vincent22
12-08-2011, 10:00 AM
Hi everyone, I'm a bit confused about OGL coordinates.
I read that the origin in OGL is in the bottom left corner, but when I draw a vertex in 0,0,0 position the vertex is in the center of my window.
Is it correct?

That's important because I need to retrive mouse position when clicking the left button, I use GLUT method and the 0 position is in the top left corner, and so it's difficoult "normalize" mouse coordinates with OGL coordinates.
Thank you.

thokra
12-08-2011, 10:36 AM
No, no, no. Window coordinates begin in the lower left corner of the window.

The world space position (0, 0, 0) is mapped to the center of the screen, if your camera model features a symmetric or aspect ratio corrected frustum, is not situated itself at the origin, and has its clipping planes set accordingly.

OpenGL has nothing to do with retrieving the position of the mouse pointer in the active window. That's the job of the windowing toolkit and your OS's window server.

Vincent22
12-08-2011, 10:42 AM
Thanks

and how can I recognize when the mouse is clicked on a shape drawed on screen? I don't know the window coordinates of the shapes (eg a rectangle)

V-man
12-08-2011, 12:07 PM
This should cover it
http://www.opengl.org/wiki/Common_Mistakes#Selection_and_Picking_and_Feedback _Mode