PDA

View Full Version : Unable to attach separate stencil buffer to FBO (packed depth+stencil is fine)



fred_em
09-11-2013, 10:11 AM
Hi,

I can use a packed depth stencil with my FBO just fine using the following code (color buffer construction code omitted):


glBindTexture(target = GL_TEXTURE_2D, texture = 17)
glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_DEPTH24_STENCIL8, width = 1486, height = 1400, border = 0, format = GL_DEPTH_STENCIL, type = GL_UNSIGNED_INT_24_8, pixels = NULL)

glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_DEPTH_ATTACHMENT, textarget = GL_TEXTURE_2D, texture = 17, level = 0)
glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_STENCIL_ATTACHMENT, textarget = GL_TEXTURE_2D, texture = 17, level = 0)
glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_COLOR_ATTACHMENT0, textarget = GL_TEXTURE_2D, texture = 18, level = 0)

glCheckFramebufferStatus(target = GL_FRAMEBUFFER) returns GL_FRAMEBUFFER_COMPLETE

However, attaching a separate stencil buffer doesn't work (code below) and returns a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error.


glBindTexture(target = GL_TEXTURE_2D, texture = 16)
glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_DEPTH_COMPONENT, width = 1486, height = 1400, border = 0, format = GL_DEPTH_COMPONENT, type = GL_UNSIGNED_BYTE, pixels = NULL)

glBindTexture(target = GL_TEXTURE_2D, texture = 17)
glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_STENCIL_INDEX8, width = 1486, height = 1400, border = 0, format = GL_STENCIL_INDEX, type = GL_UNSIGNED_BYTE, pixels = NULL)

glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_DEPTH_ATTACHMENT, textarget = GL_TEXTURE_2D, texture = 16, level = 0)
glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_STENCIL_ATTACHMENT, textarget = GL_TEXTURE_2D, texture = 17, level = 0)
glFramebufferTexture2D(target = GL_FRAMEBUFFER, attachment = GL_COLOR_ATTACHMENT0, textarget = GL_TEXTURE_2D, texture = 18, level = 0)

glCheckFramebufferStatus(target = GL_FRAMEBUFFER) returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT​, here.

Any idea why?

Thanks,
Fred

nb: using a GeForce GTS 450 and latest drivers.

tksuoran
09-11-2013, 11:35 AM
This is not required to be supported: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."