PDA

View Full Version : Multisample FBO problems with stencil buffer



RedSonja
10-05-2009, 11:59 AM
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_RENDERBUFFE R_EXT, 8, GL_RGBA32F_ARB, sx, sy);

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

glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, ColorBufferID);

glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, StencilBufferID);

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

Thanks.

MarkZ3
10-05-2009, 01:08 PM
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."

http://www.opengl.org/wiki/GL_EXT_framebuffer_object#Stencil

Alfonse Reinheart
10-05-2009, 01:16 PM
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_RENDERBUFFE R_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 ;)

RedSonja
10-05-2009, 01:42 PM
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.