I am writing depth component to framebuffer which a render buffer attaches to. Then I am using glReadPixels to retrieve the depth from buffers. But gl gave me error 'null' from the call of glReadPixels

I searched for the answers but got no luck. Where am I doing wrong here?

Thanks.

thekend

10-20-2010, 11:19 PM

For glReadPixels, the format should be GL_DEPTH_COMPONENT instead of GL_DEPTH_COMPONENT_24. It's a bit confusing at first time, but the symbolic constants for formats in client memory (so the readback format) and the internal formats used by GL for buffers/textures are different.

JoeOgl

10-21-2010, 09:28 AM

I tried the format change from GL_DEPTH_COMPONENT24 to GL_DEPTH_COMPONENT, but it did not solve the problem. I still got the same error.

arekkusu

10-22-2010, 11:32 AM

If you call CheckFramebufferStatus on your FBO, instead of zero (the system drawable) it should tell you that your FBO is incomplete.

That's because the default glReadBuffer state is COLOR0.
You should set glReadBuffer in addition to glDrawBuffer.

See example (7) "Render to depth texture with no color attachments" in the EXT_fbo spec.

JoeOgl

10-22-2010, 05:24 PM

I added glReadBuffer(GL_NONE) after glDrawBuffer(GL_NONE), plus, I changed from GL_DEPTH_COMPONENT24 to GL_DEPTH_COMPONENT in glReadPixels call. Now I seem to get some results for my data. But all the values are 1. That does not seem right... I will keep looking into it...

tksuoran

11-05-2010, 03:50 AM

If you find that you can read depth on AMD on non-default framebuffer, I would be interested to hear about that. I*have recently had issues with that (works fine on NVidia).