Nothing written to FBO depth

Hi all,

I have some FBO shadow code that works fine in my game. On integrating the code into another game (same machine) it’s failing to write anything to the FBO depth buffer (all vals exactly 1.0 == far val).
I’ve dumped the FBO colour buffer and that has the expected geometry rendered on it - but nothing is getting written to the depth attachment.
The code definitely works fine in the other app.

Have checked:

  • GL window PIXELFORMATDESCRIPTOR - all same.
  • Call glDisable(GL_DEPTH_TEST), glDepthMask(GL_TRUE) & glDisable(GL_CULL_FACE) before rendering.
  • Set glDepthFunc(GL_LEQUAL)

Been tearing hair out for a few days now :frowning:
Can anyone think of any GL settings this other app may be meddling with to result in this problem?!

Aren’t you suposed to enable depth test otherwise nothing is written to depth texture.

Bloody hell! And there’s me thinking I knew exactly what disabling GL_DEPTH_TEST did. Apparently not :eek:
[ed] Although the red book doesn’t make it clear at all :frowning:

Yeah, I agree with you. Been there. :stuck_out_tongue: That feature is just odd. Intuitively, seems like DEPTH_TEST and DepthMask should be independent, not chained.

They are independent. Disabling depth test should not disable depth writing. This is more than likely some kind of driver bug or just user error.

They are not independent. OGL specification is quite clear:

GL_DEPTH_TEST - If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled.

OGL specification is quite clear

Well you’re right that the spec does require this (though you’re quoting from the man-pages, which are not normative). The 3.2 core specification says, in section 4.1.5:

When disabled, the depth comparison and subsequent possible updates to the depth buffer value are bypassed and the fragment is passed to the next operation. The stencil value, however, is modified as indicated below as if the depth buffer test passed. If enabled, the comparison takes place and the depth buffer and stencil value may subsequently be modified.

And I have to agree with Dark Photon that this is stupid. It may explain why GL_ALWAYS exists, but that’s no excuse.

Reference pages are not normative but very informative. I agree the wording in OGL Spec is quite complicated.