Reputation: 347
I am trying to create framebuffer with 4 colour attachments, a 16 bit depth buffer and a 16 bit stencil buffer. I need 16 bits for the stencil buffer because I store object ID's in them for object picking, and I have a lot more then 255 objects. I create two render buffers:
glBindRenderbuffer(GL_RENDERBUFFER, mID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, mID2);
glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX16, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
I ask SDL to give me 16 bit stencils:
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 16);
But when I bind the stencil render buffer to the framebuffer I get a framebuffer incomplete error. I know the wiki states that GL_STENCIL_INDEX16 is not required by the spec. Is it not possible to create 16 stencil buffers? Could I encode the object ID integers down to 8 bit values?
Upvotes: 3
Views: 1071
Reputation: 210947
A separate depth and stencil buffer attachment need not be supported.
See OpenGL 4.6 API Core Profile Specification - 9.4.3 Required Framebuffer Formats
[...] However, when both depth and stencil attachments are present, implementations are only required to support framebuffer objects where both attachments refer to the same image.
See also:
Unable to attach separate stencil buffer to FBO (packed depth+stencil is fine)
Framebuffer Object - Completeness Rules
Upvotes: 5