Michael IV
Michael IV

Reputation: 11424

FBO depth and stencil render buffer attachments

The OpenGL wiki says that in order to use stencil buffer attachment with depth buffer in FBO one needs to create the render buffer with format of the type GL_DEPTH24_STENCIL8, as it seems like GL_STENCIL_INDEXX aren't implemented.

What I don't understand is whether such a buffer is also depth buffer if I set it as GL_DEPTH_STENCIL_ATTACHMENT? Or should I still create separate depth render buffer with formats (GL_DEPTH_COMPONENTXX)?

Upvotes: 0

Views: 2070

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473252

It's not that the STENCIL_INDEX formats aren't "implemented". It's that the specification does not require an implementation to consider them to be complete. Implementations are allowed to reject a combination of image formats for whatever reasons it deems fit, unless you stick to the list of required image formats.

A depth/stencil image has depth and stencil in it, just like a red/green image has both red and green in it. So yes, you attach the same image to the GL_DEPTH_ATTACHMENT and GL_STENCIL_ATTACMENT points. Or you use GL_DEPTH_STENCIL_ATTACHMENT as shorthand for both.

Upvotes: 3

Related Questions