I’m trying to use a frame buffer object in a project I’m working on, and encountered an odd problem.
I’ve cut’n’paste code from an online OGL tutorial to create a straightforward frame buffer object with a colour buffer and a depth buffer attached. Everything works fine - I can render to the FBO, and use the resulting texture elsewhere - apart from one problem: I can’t clear the FBO’s depth buffer. When I call:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
only the colour buffer is cleared.
Now, I could understand it if the depth buffer wasn’t working at all, but it is. The geometry clearly is being rendered into the depth buffer; the effect is hard to describe but I’m sure you can imagine it: in each frame only the geometry that pokes in front of everything rendered in previous frames actually appears.
That’s it, really. Clearing the depth buffer on the primary frame buffer works fine; it just doesn’t work on the FBO. I’ve searched around and nobody else seems to be having this problem, and it’s such a basic operation that I can’t really think of anything else to try.
Anyone else experienced this?