PDA

View Full Version : color attachment to default framebuffer



Ares Lagae
11-04-2011, 03:18 PM
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,

Ares Lagae
11-04-2011, 03:41 PM
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?

aqnuep
11-04-2011, 03:48 PM
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.

kyle_
11-04-2011, 03:49 PM
Is it possible to attach color attachments to the "default" framebuffer?
No.


but then I always need to copy the first color attachment back to the screen
I hope that by 'copy' you mean 'blit' ;)

Ares Lagae
11-04-2011, 03:52 PM
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,

aqnuep
11-05-2011, 01:22 AM
It depends on what exactly you want to achieve, but in general, the approach you've presented looks like the way to go.

thokra
11-05-2011, 02:14 AM
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