PDA

View Full Version : Noobie Question: Depth buffer setup



coder2010
03-01-2010, 06:19 PM
Hi Guys,

Brand new to openGL and 3d stuff. I am still trying to wrap my head around a totaly new way of thinking. So please be gentle. I got a very newbee question. What would be the steps in openGL coding (from start to end in c++) to get depth buffer values. To make it simple I am trying to work only on a single triangle, i know the clipping planes, the camera location, looking at the origin and the up vector being -z axis.

Now i have gone as far as this:

glMatrixMode(GL_MODELVIEW);
glLookAt(..);
gluProject(..);
glFrustrum(..);
glViewPort(..);

I think these are the right steps. I am not sure what would be calls after this to get to glReadPixels(..).

One of my freinds suggested I use gluProject/gluUnproject. but that seems to include some of the functionality of these above calls built into it. Also, I think I would learn better if I know each function call individually so that I know what they do. Once I understand how to get this done with individual calls I can use the gluProject I guess.

Please, any help will be appreciated. I know I just did a very crude representation of my problem. I you would like I can post all the data that I have.

HELP...

Dark Photon
03-01-2010, 07:32 PM
What would be the steps in openGL coding (from start to end in c++) to get depth buffer values. To make it simple I am trying to work only on a single triangle, i know the clipping planes, the camera location, looking at the origin and the up vector being -z axis. ... I think these are the right steps. I am not sure what would be calls after this to get to glReadPixels(..).
You need to pick up the Red Book (i.e. OpenGL Programming Guide (http://www.opengl.org/documentation/red_book/)) and read a bit. Just google for OpenGL tutorials, and this kind of thing will be the first tutorial on each list. For instance:

* OpenGL:Tutorials:Tutorial Framework:First Polygon (gpwiki) (http://gpwiki.org/index.php/OpenGL_Tutorial_Framework:First_Polygon)
* GLUT Tutorial (lighthouse3d) (http://www.lighthouse3d.com/opengl/glut/index.php?1)


One of my freinds suggested I use gluProject/gluUnproject. but that seems to include some of the functionality of these above calls built into it.
You wouldn't use these to render a triangle. These are used to transform some points on the CPU (e.g. before or after rendering).


Also, I think I would learn better if I know each function call individually so that I know what they do.

Agreed. That's why you need to get the Red Book and read. The manual pages (http://www.opengl.org/sdk/docs/man/) or the specs (http://www.opengl.org/registry/) aren't the place to go if you're just starting out. You need to understand how the pipeline works first.


Once I understand how to get this done with individual calls I can use the gluProject I guess.
For what?