Depth buffer reading and depth buffer test

Hi guys,

i am quite new to this and got like little knowledge on this matter and would like to ask you all for some help.

ok, things i know is that in order for the depth buffer to work, we need to enable it,clear it, mask it and use the gldepthfunc to do a GL_LESS or GL_GREATER to compare the values.

After stating all that, we need to do a GL_QUAD to specify the area for the depth buffer to tell the buffer which are the depth value i am interested in.

i hope up to this point i am still correct.

ok my question is that i got some problem understanding how to read from the depth buffer to do some debugging and understanding how does it work. At this point, i assumed the depth values are automatically wrote to the depth buffer in order for it to do the depth test.

So, to read from the buffer, i guess i have to use the glReadPixels command but i got no idea how to use it since it involved other operation like glpixelmap and glpixelstore…

is there any example available? I have searched but it seems that it is not available. the opengl guide also didnt state how actually all the operations are linked and i hope you guys could give me some insights.

thanks!!!