I am playing a bit with bit blitting in OpenGL. When I run the code looking like this:
GLuint fbo = CreateFBO(); // creates fbo and attaches a texture to it
glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLfloat some_color[] = {0.8, 0.4, 0.6, 1.0};
glClearBufferfv(GL_COLOR, 0, some_color);
glBlitNamedFramebuffer(0, fbo, 0, 0, 100, 100, 0, 0, 100, 100, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |GL_STENCIL_BUFFER_BIT);
glBlitNamedFramebuffer(fbo, 0, 0, 0, 100, 100, 0, 0, 100, 100, GL_COLOR_BUFFER_BIT, GL_NEAREST);
It yields a black screen, that is, the screen was cleared, although it should have the color of some_color. But if I change the "named" function to the "unnamed" counterpart, then it works as intended. The new piece of code looks like:
GLuint fbo = CreateFBO(); // creates fbo and attaches a texture to it
glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLfloat some_color[] = {0.8, 0.4, 0.6, 1.0};
glClearBufferfv(GL_COLOR, 0, some_color);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_);
glBlitFramebuffer(0, 0, 100, 100, 0, 0, 100, 100, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |GL_STENCIL_BUFFER_BIT);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, 100, 100, 0, 0, 100, 100, GL_COLOR_BUFFER_BIT, GL_NEAREST);
And executing this code, I get the expected result, namely the screen having the color of some_color. What am I doing wrong employing bit blitting? Or if I am using it correctly, why doesn't it work properly?
UPD: I mixed up blit functions in the second code sample.