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:


    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!

Hi,
Recheck your code to see if your framebuffer bound to the draw framebuffer target like this,


glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);

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?

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…

Clarification: GL_LUMINANCE32F_ARB, not GL_LUMINANCE32F

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!