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

Thread: Framebuffer: Color and depth at same time

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    7

    Framebuffer: Color and depth at same time

    Is it possible to draw to a color and depth buffer at the same time (using the same shader)? I have a feeling the answer will be no, but maybe there are some tricks I don't know about.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,714

    Re: Framebuffer: Color and depth at same time

    What do you mean by that? It's generally quite hard to not render both color and depth at the same time. That is after all what you do normally. FBOs wouldn't be worth much if you couldn't use them with depth buffers.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    7

    Re: Framebuffer: Color and depth at same time

    I'm looking at glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo) and I get the sense that only one FBO can bound for drawing at a time. I need to create a depth FBO and a color FBO, and I'm wondering if I can write to both in one fell swoop.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,714

    Re: Framebuffer: Color and depth at same time

    There is no such thing as a "depth FBO" or a "color FBO". There is only a Framebuffer Object, which can have color and/or depth images bound to it.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    7

    Re: Framebuffer: Color and depth at same time

    Ok, that is what I meant. Is there a way to write color and depth data to a single FBO? If not, is there a way to write each to a separate FBO but do so at the same time?

  6. #6
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: Framebuffer: Color and depth at same time

    You create a framebuffer object and attach images (textures) to it. So yes, you can attach upto 16 textures and 1 depth texture to the same fbo.

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    7

    Re: Framebuffer: Color and depth at same time

    Thanks. Would this let me write to the color and depth textures in the same render call?

  8. #8
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Framebuffer: Color and depth at same time

    yes
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  9. #9
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    7

    Re: Framebuffer: Color and depth at same time

    Ok, I understand FBOs better now. I appreciate all the help.

Posting Permissions

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