[solved] Deepthbuffer from FBO

Hello,

I know this is a very simple question but I didn’t found an answer.
I just want to get a deep texure of a rendered scene which is rendered in a FBO.
I know there is the getDepthTexture function, but when I use this i get this error:

[ error ] ofFbo: getDepthTexture(): frame buffer object 1 not allocated with depthStencilAsTexture

I just want the deepBuffer as a grey texture and I want them to draw.
What am I doing wrong?

Chears

when allocating the fbo you need to use an ofFboSettings and set the depthStencilAsTexture flag to true as the error says. Otherwise the fbo depth buffer is allocated using a renderbuffer instead of a texture which is usually slightly faster but can’t be drawn or read from a shader:

ofFboSettings settings;
settings.width = width;
settings.height = height;
settings.internalFormat = GL_RGBA;
settings.depthStencilAsTexture;
fbo.allocate(settings);

Thanks arturo.
It works :slight_smile: