PDA

View Full Version : how to get value from opengl calls



mahsa
10-26-2008, 06:05 PM
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

trinitrotoluene
10-26-2008, 07:34 PM
To get the window coordinates from an object coordinate you can use gluProject (http://www.opengl.org/sdk/docs/man/xhtml/gluProject.xml). Look at this thread (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=48000&Number=245870) for more information. To read the depth buffer (z-buffer) you can use the glReadPixels (http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml) 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.