ofFBO in iOS - depth buffer

Hey guys,

I’m having an issue with the depthBuffer in ofFBO. When I draw to the screen, the depth of all of my objects are rendered correctly. When I draw the scene into an ofFBO, the depth buffer isn’t enabled – the polygons are all stacked in the order they are drawn in the loop, not their correct order in z-space.

Enabling the depth buffer through allocate() displays a grey screen – the app runs but nothing is rendered to the screen (FBO or anything else).

    ofFbo::Settings settings;  
    settings.width = 512;  
    settings.height = 512;  
    settings.internalformat = GL_RGB;  
    settings.numSamples = 0;  
    settings.useDepth = true;  
    settings.useStencil = false;  

It looks as though the stencil buffer in ofFBO has been solved in another thread – does anyone have any ideas on how to fix the depth buffer?—stencil-buffer/6837/0

Thanks in advance,

On iOS the depth buffer and stencil buffer are combined, so you need to have them both enabled. If you check out the ofFBO::allocate() you’ll see:

if( settings.useDepth && settings.useStencil )  
		stencilBuffer = depthBuffer = createAndAttachRenderbuffer(GL_DEPTH_STENCIL, GL_DEPTH_STENCIL_ATTACHMENT);  

so I think your settings need to have stencil and depth to work properly. It might be nice to put a message in there if someone on iOS has depth but not stencil or vice versa.

This doesn’t work for me – setting useDepth to true displays a grey screen. Nothing is rendered to screen, though the app runs in the background. This true is regardless of useStencil is true or false.

When useDepth and useStencil are true, I get this message:

Which originates here in ofFbo.cpp:

bool ofFbo::checkStatus(){  
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);  

Any thoughts?


Hmm. I’m not sure and I don’t have an iOS device to test on. For the time being, could you file it as a bug on github at Hopefully someone with a little more iOS knowledge can help out.

I *know* I talked about this but I can’t remember if it was here on the forum or on github. The code as it was would not work properly on iOS, I suggested changes.


Man, my reading comprehension sure is crappy, isn’t it? Or maybe it’s the ADD kicking in…