Multisample FBO problems with stencil buffer

Hi - can anyone see an obvious reason why this should come back as FBO ‘incomplete attachment’ ? :

glGenFramebuffersEXT(1, &fboID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);

glGenRenderbuffersEXT(1, &ColorBufferID);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorBufferID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 8, GL_RGBA32F_ARB, sx, sy);

glGenRenderbuffersEXT(1, &StencilBufferID);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilBufferID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 8, GL_STENCIL_INDEX, sx, sy);



Works fine if I remove the stencil buffer (and just keep the color render buffer)


Maybe this can help you?

“NEVER EVER MAKE A STENCIL buffer. All GPUs and all drivers do not support an independent stencil buffer. If you need a stencil buffer, then you need to make a Depth=24, Stencil=8 buffer, also called D24S8. Please search for the example about GL_EXT_packed_depth_stencil on this page.”

Actually, that’s not the reason. Drivers can ignore specific formats, but only by using GL_UNSUPPORTED. If it actually comes back as GL_INCOMPLETE_ATTACHMENT, then that means you have done something that can’t be done.

What likely happened is that “glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 8, GL_STENCIL_INDEX, sx, sy);” failed with a glError. Thus, the stencil buffer could not be created, and when you bind it, it isn’t of stencil type.

The solution is, well, what MarkZ3 said :wink:

Changing the internal format for glRenderbufferStorageMultisample to GL_DEPTH24_STENCIL8_EXT, and the attachment point for glFramebufferRenderbufferEXT to DEPTH rather than STENCIL works.

Thanks guys.