View Full Version : depth and stencil buffer

05-31-2004, 10:23 PM
How can I get a copy of the depth buffer in the stencil buffer?

06-01-2004, 04:39 PM
Im guessing but I'd say you can't.

Depth buffer is 16/24bit and stencil buffer is (typically) 8 bit. The only way you might be able to do it is to read the depth buffer, reduce it's precision then set each pixel in the stencil buffer individually. Which'd take a matter of hours per frame I'd expect.

And the Depth buffer is 0.0->1.0 while the stencil buffer is 0->255 AFAIK.

That's assuming I understood your question. Why would you want to do such an operation?

06-02-2004, 04:22 AM
ok, thanks
I found another way to render my scene in function of a zbuffer content. I draw objects from back to front with this depth function :

glDepthFunc(GL_GREATER);So only the nearest objects behind the depth value in the zbuffer are drawn.