PDA

View Full Version : enable depth test but disable write



kaesemeister
10-17-2011, 02:37 AM
Hi,

I am trying to use occlusion queries for objects that are hidden by other objects:
1. render bounding volume of some object
2. check if any fragment of the volume passed the depth test
3. if not: don't render object

to do this I need to disable writes to color and depth buffer when rendering a bounding volume in a way that keeps the depth test (for the queries).

The documentation says, that GL_ANY_SAMPLES_PASSED gives me true, if any sample passed the depth test. I thought, okay.. I can just enable the stencil test with GL_NEVER, but sadly this has not worked.

Is there a way to do this?

kRogue
10-17-2011, 03:09 AM
use glDepthMask to enable/disable depth writes and glColorMask to enable/disable color writes and glStencilMask for stencil writes. All but stencil is just on or off, but stencil is per-bit control writes.

kaesemeister
10-17-2011, 03:10 AM
thank you! That's what I searched for :)