View Full Version : enable depth test but disable write

10-17-2011, 03:37 AM

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?

10-17-2011, 04: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.

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