FBO with multiple color attachments and MSAA

Hi

i have FBO with GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT binded
both GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT
are multisampled renderbuffers (glRenderbufferStorageMultisampleEXT … etc.)
now i render to this FBO
and unbind it

then i have another fbo with with GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT binded (this time those two are textures
with format and dimensions identical to renderbuffers of previous FBO)

now i want to resolve my MSAA renderbuffers to those textures

glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, MSAA_FBO);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, TEXTURES_FBO);

glBlitFramebufferEXT( 0, 0, texWidth, texHeight, 0, 0, texWidth, texHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

but what a crap ! :wink:
both textures binded to TEXTURES_FBO now have context of the FIRST renderbuffer :wink:

what is wrong ?
my first texture should have context from the GL_COLOR_ATTACHMENT0_EXT of MSAA_FBO and the second one from GL_COLOR_ATTACHMENT1_EXT.

is there any way to do this ‘at once’ ?
or i must bind each renderbuffer to the fbo, then texture to the fbo and do it one by one ?

There’s only one glReadBuffer(), thus only one source for the blit. But, as you have experienced, there can be multiple glDrawBuffers().

To do what you want, perform two blits, adjusting glReadBuffer() and glDrawBuffer() inbetween.

I find it amusing that the blit actually really followed the glDrawBuffers() setting - this is something I have never thought about, nor read about in the specs. But it seems logical and consistent.

ok, after reading the GL_EXT_framebuffer_blit specification second time i’v spot that there is a note about multiple color attachments :slight_smile: