View Full Version : How to do MRT with color buffer from default FBO?
11-04-2011, 01:55 PM
For my MRT shader I need just 2 color buffers total, and there is already one in the default frame buffer, but I can't find a way to retreive it so that I can attach it to another FBO to do my MRT algorithm. Is this possible to do ?
11-04-2011, 02:45 PM
If you're hardware is OpenGL 3.0 capable, you can blit the default framebuffer to the color attachment of the FBO.
The GL keeps track of one or read and one or more draw buffers. When you bind the FBO with GL_DRAW_FRAMEBUFFER it's bound as the target for drawing operations. The back buffer of a double-buffered context is initially bound as both a draw and read framebuffer.
You can copy the contents of the back buffer to the FBO by:
// first bind FBO as draw framebuffer
// copy contents from back buffer to color attachment
// this assumes the default fb and the fbo have equal dimensions
void glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
Please tell if this helps.
11-04-2011, 03:55 PM
No. You can't attach an image from the default framebuffer to an FBO. You have to create a new image instead and then copy it to the framebuffer. You can use a blit, as thokra suggests, or draw a full-screen quad.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.