PDA

View Full Version : depth and stencil buffer



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

rgpc
06-01-2004, 05: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?

pantxua
06-02-2004, 05: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 :


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