Does glBlitFramebuffer copy all color attachments if GL_COLOR_BUFFER_BIT mask is specified?

blit, framebuffer, graphics, opengl

Solution

A framebuffer color blitting operation will only read from the current `glReadBuffer` for the `GL_READ_FRAMEBUFFER`, and it will only write to the `glDrawBuffers` specified for the `GL_DRAW_FRAMEBUFFER`. So it's not about the attachments; it's about the read and draw buffers of the two framebuffers.

Problem

If I am copying pixels from one FBO to another and each of them have multiple (not necessary the same number) of color attachments, and if my mask is `GL_COLOR_BUFFER_BIT`, which color attachments (`GL_COLOR_ATTACHMENT0`, `GL_COLOR_ATTACHMENT1`, ...., `GL_COLOR_ATTACHMENTi`) does it copy? All of them? If yes, what if these FBOs have different number of color buffers attached to them? Assume that there are 2 FBOs that are bound in this way: ``` glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo1); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo2); ``` Note that `fbo1` has 2 color attachments and `fbo2` has 4 color attachments. So how does the `glBlitFrameBuffer` blit color attachments in this case? I could not find this anywhere in the OpenGL documentation.

Original source