I am confused in the relation between ndc to screen coordinate system. What i did was
select screen coordinates (for example touch points on the screen).
then pass the screen coordinates to gluUnproject. i set the depth variable(third variable of gluUnproject) to 0.0f.
then i multiply the object coordinates to modelviewmatrix and projectionmatrix.
after that I clipped the space. then i divide the clip space coordinate with W
after this I changed the gluUnproject`s third variable to 1.0f which i suppose the result was equal to 0.0f. But the result was 1.0f.
So here is the question what is relation between normalized coordinate system and screen coordinate system. how do i set the depth variable of gluUnproject function?
What is relation between normalized coordinate system and screen coordinate system?
Normalized device coordinates are expressed in the range [-1,+1] and are obtained from the clip-space coordinates dividing them by their W component.
They are transformed in Window-space coordinates by the viewport parameters and the depth range parameters.
How do i set the depth variable of gluUnproject function?
If you want to convert the Window-space coordinates back to Normalized device coordinates you need the Window-space z value at the point you want to convert. So, directly from the OpenGL FAQs:
GLdouble z;
glReadPixels (x, y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);
Please note that OpenGL store non-linear depth in the depth buffer.