Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Unable to attach separate stencil buffer to FBO (packed depth+stencil is fine)

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jul 2010
    Posts
    131

    Unable to attach separate stencil buffer to FBO (packed depth+stencil is fine)

    Hi,

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

    Code :
    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.

    Code :
    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.

  2. #2
    Junior Member Regular Contributor tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    Cambridge, UK
    Posts
    224
    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."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •