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

Thread: Clearing 4 draw buffers at once

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    24

    Clearing 4 draw buffers at once

    Hi all, I have an FBO with a depth buffer and four color buffers (two RGBA16F and two LUMINANCE32F). Google says that if I call glClear with GL_COLOR_BUFFER_BIT, it clears all four color buffers at once. This doesn't agree with my experiments though.

    If I do this:
    Code :
        beginFBO();
        GLenum drawBuffers[4] = {
                GL_COLOR_ATTACHMENT0,
                GL_COLOR_ATTACHMENT1,
                GL_COLOR_ATTACHMENT2,
                GL_COLOR_ATTACHMENT3
        };
        glDrawBuffers(4, drawBuffers);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    Shouldn't it clear all four buffers? Or is it not working because I have odd types (RGBA16F and LUMINANCE32F)?

    Thanks for your help!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    802

    Re: Clearing 4 draw buffers at once

    Hi,
    Recheck your code to see if your framebuffer bound to the draw framebuffer target like this,
    Code :
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);
    Regards,
    Mobeen

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

    Re: Clearing 4 draw buffers at once

    Shouldn't it clear all four buffers? Or is it not working because I have odd types (RGBA16F and LUMINANCE32F)?
    Which buffers does it clear?

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    24

    Re: Clearing 4 draw buffers at once

    Ack, when I posted this, I thought it was only clearing the first one, the RGBA16F one. On a closer look, it looks like its successfully clearing both the RGBA16F ones, and its leaving the LUMINANCE32F's dirty.

    It must be a format issue then, because only LUMINANCE32F's are not being cleared. I'm looking on Google though, and nobody mentions anything about this clearing not working for them...

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    24

    Re: Clearing 4 draw buffers at once

    Clarification: GL_LUMINANCE32F_ARB, not GL_LUMINANCE32F

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    24

    Re: Clearing 4 draw buffers at once

    Shoot, nevermind! It turns out it had nothing to do with the format, it was somewhere else completely in my code. Sorry about that! Thanks for your help anyway though!

Posting Permissions

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