color attachment to default framebuffer

Hi all,

Is it possible to attach color attachments to the “default” framebuffer?

The effect would be that writes to gl_FragColor or gl_FragData[0] would directly go to the screen, and writes to gl_FragData[1 … 7] would go the the color attachments.

I have code that does all of that with a separate FBO, but then I always need to copy the first color attachment back to the screen, which seems wasteful.

Thanks,

Maybe I should rephrase:

It is possible to create a FBO, where all render buffers are those of the default framebuffer, and which has additionally color attachments?

No, this is not possible. The attachments of the default framebuffer are not exposed as renderbuffers or textures and you cannot attach any more color attachments to the default framebuffer.

Though, it is possible in hardware, but the OpenGL specification does not support it, neither the implementations. Actually, this is something that I’m waiting for a long time to be included in the specification.

No.

I hope that by ‘copy’ you mean ‘blit’ :wink:

Thanks for your quick replies.

If I understand everything correctly, the way to do this (for now) is:

  • create an entirely new FBO with color attachments
  • render to the FBO
  • blit from the FBO to the default framebuffer
    ?

Thanks,

It depends on what exactly you want to achieve, but in general, the approach you’ve presented looks like the way to go.

Another classic scenario where you wouldn’t blit is shadow mapping (or any render to texture technique). The algorithm in this case would be:

a) create FBO and attach a depth texture as DEPTH_ATTACHMENT
b) bind FBO and render z-only pass for the light source
c) render scene and use the depth attachment as depth texture