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 5 of 5

Thread: glFramebufferTexture2D with depth or stencil textures

  1. #1
    Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    284

    glFramebufferTexture2D with depth or stencil textures

    I am using glFramebufferTexture2D and have some doubts regarding it:
    1) With Depth render able formats, we attach texture as depth component attachment so how do we render color image with depth attachment?
    2) How to render colored image with stencil attachment?

  2. #2
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    you can have several color-attachments, depth-attachment and stencil-attachment simultaneously. take a look at these examples:
    https://www.opengl.org/wiki/Framebuf..._Depth_texture
    https://www.opengl.org/wiki/Framebuf..._depth_stencil

    and ask if you cant figure out something.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135
    What do you mean "render color with depth attachment(stencil)"?

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    284
    Quote Originally Posted by thokra View Post
    What do you mean "render color with depth attachment(stencil)"?
    Depth texture stores only depth values and so we attach this to FBO but when we attach this non default FBO to system fbo as a texture where do the color values come from, i mean as we dont have any color attachment, how to draw this depth texture ??

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135
    Your not making much sense here. There isno such thing as a system FBO, there is only the default framebuffer, which is window system provided and has nothing to do with FBOs. Actually, I think I already told you so in another thread IIRC. So once and for all: There is no default or window system provided FBO. Also, you cannot attach anything to the default framebuffer. Period.

    Second, having a depth texture and one or more color attachments are different things - and in the following I'm only talking about core GL without any legacy stuff. Writing to color attachments happens via fragment shaders. Fragment shaders are not run, if the depth test discards a fragment. To be able to actually do a depth test, there needs to be a depth buffer attached to the FBO. Depth values are automatically generated - you don't need to do anything for that. The depth attachment will be updated automatically when you render stuff and newly rasterized fragments pass the depth test (i.e. the depth attachment is updated). I'm not exactly sure right now what happens if the depth test is enabled and there is no depth attachment on your FBO, but I suspect it works anyway. You can write depth values from a fragment shader as well, using gl_FragDepth. This will write depth values to your depth attachment not to any color attachment.

    What's your use-case? What do you want to achieve? Shadow mapping, by any chance?

Posting Permissions

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