How do I obtain the projection matrix and the depth value?

I want to know the projection matrix and the depth value in each pixel.

And I will solve the 3D coordinate value in the real axis.

But I don’t know the function that can return the projection matrix

and the depth value.

Thanks in advance…

GLdouble projMatrix[16];

glGetDoublev(GL_PROJECTION_MATRIX,projMatrix);

returns you the projection matrix.

glFloat pixels;

glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&pixels);

gives you the z value at a specific 2D point on screen.

Kilam.