PDA

View Full Version : gluUnproject()



Epidemi
08-10-2000, 02:15 PM
I was just wondering how the gluUnproject() functions works. I want to use gluUnproject() to convert 2D screen coords to 3D world coords. So I basicly have only 2 coordinates, whilst gluUnproject requires 3.

Can somebody help me on this?
Thanx!

--> Tize

Divide Overflow
08-10-2000, 02:16 PM
Yeah, wondering the same thing !

--> Divide

ben
08-10-2000, 05:09 PM
Remember that OpenGL, when projecting 3D world coordinates into 2D screen coordinates, retains the third coordinate (the z value). This allows OpenGL to do depth testing. Therefore when taking a screen point an un-projecting it back into the world, OpenGL needs to know how far away from the camera the point is (the third coordinate).

Without the third coordinate to define depth in the screen, a 2D point alone corresponds to an infinite number of points in 3D.

Hope this helps.

Kilam Malik
08-10-2000, 10:08 PM
Yep, and you get the third coordinate from the depth buffer (use glReadPixels on the x,y position)

Kilam.