how to get value from opengl calls

hi every body,

I’m beginner in opengl and I need an immediate help because my due is the day after tomorrow. we are supposed to implement z-buffer and flat - gouraund- phong shading and this is the hint from the insrtuctor :
“you may use opengl to
you pass coordinates of a 3D point and you can ask
> opengl to give you the 2D coordinates of the projected point. From then
> on, you are to implement rasterization and other steps.”
how can i take values of the 2D coordiante and the Z’ (for z-buffer)
from opengl call.

I appreciate your quick answers.

Yours,
Mahsa

To get the window coordinates from an object coordinate you can use gluProject. Look at this thread for more information. To read the depth buffer (z-buffer) you can use the glReadPixels function.

Edit: After rereading the thread that I give you the link, you do not need to call glReadPixels because the value of the depth seem to be included as WinZ.