Binding a stencil render buffer to a frame buffer in opengl

Has anyone done this successfully? It seems that any index format that I use in the stencil rendering buffer glCheckFramebufferStatus(...)returns GL_FRAMEBUFFER_UNSUPPORTED. I have successfully bound the \ color render depth buffer, but whenever I try to do the same with my stencil buffer, I get (as I said) GL_FRAMEBUFFER_UNSUPPORTED.

Here are the snippets of my code:

// Create frame buffer
GLuint fb;
glGenFramebuffers(1, &fb);

// Create stencil render buffer (note that I create depth buffer the exact same way, and It works.
GLuint sb;
glGenRenderbuffers(1, &sb);
glBindRenderbuffer(GL_RENDERBUFFER, sb);
glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, w, h);

// Attach color
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, cb, 0);

// Attach stencil buffer
glBindFramebuffer(GL_FRAMEBUFFER, fb);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
// And here I get an GL_FRAMEBUFFER_UNSUPPORTED when doing glCheckFramebufferStatus()

Any ideas?

Note. Color pinning is a texture, not a rendering buffer.

+5
source share
2 answers

. , + . , .

, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT​.

+7

/ nvidia

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, fboStencilTexture, 0);

- ,

0

All Articles