I'm working on a program and want to display the depth complexity for
each frame I render. I'm trying to use the approach outlined in the
Advanced OpenGL Siggraph notes on "Finding Depth Complexity with the
Stencil Buffer." Problem is, I don't have too much experience with
pixel operations, so there are a few areas that are unclear to me.
Here's the method that the article describes:
1) Clear the stencil and depth buffers
2) Enable stenciling
3) Set the stencil function w/glStencilFunc( GL_ALWAYS, 0, 0 ) and the
stencil op w/glStencilOp( GL_KEEP, GL_INCR, GL_INCR )
4) Draw the scene
5) Use glReadPixels( ) w/GL_STENCIL_INDEX as format
6) Draw the stencil buffer using glDrawPixels with GL_COLOR_INDEX as
7) Control over color mapping can be done by enabling color mapping
and setting up pixel maps.
I'm using a double buffer and have set the read and write buffers to
the back buffer and I'm making sure to flush the buffer after the
write before the swap, but the screen is always white.
It's 5-7 that are giving me the trouble. What type should I take from
glReadPixles? GL_FLOAT? GL_UNSIGNED_INT?
I'm not sure how to use the mapping because I don't know what the
range should be with what glReadPixels returns. Is that dependant on
if the type is GL_FLOAT or GL_WHATEVER?