PDA

View Full Version : depth mapping



alok47
11-12-2001, 12:56 AM
I am specifying an ortho whose zNear = 0 and zFar = 1.
Now I cleared the depth buffer with different values say 0, 1 and 0.5.

By enabling depth test and depth func to
GL_EQUAL, I want to draw the objects after
appropriate translation of the object in the z direction.

But the object is seen when cleared depth
value is 0.For others nothing is seen.
I want to know how much I have to translate depending upon glOrtho and the clear value??

Here i am posting my code for more clarity.

glOrtho ( , , , , 0, -1);
glDepthRange (0, 1) ;

glClearDepth (0.5) ;
glClear (GL_DEPTH_BUFFER_BIT) ;

glEnable (GL_DEPTH_TEST) ;
glDepthFunc (GL_EQUAL) ;

glMatrixMode (GL_MODELVIEW) ;
glLoadIdentity () ;
glTranslatef (0, 0, -0.5) ;

glRectf (0, 0, 50, 50) ;
glDisable (GL_DEPTH_TEST) ;