Hello Everyone,
I am trying MSAA with FBOs. I use two FBOs. One that reads from the other FBO. I am following the ideas presented here:
And this is where i do the drawing:
// mfbo: MSAA FBO
// fbo: Normal FBO
void drawFBO()
{
glBindFramebuffer(GL_FRAMEBUFFER, mfbo);
glPushAttrib(GL_VIEWPORT_BIT);
// Draw scene.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawScene();
glPopAttrib();
glBindFramebuffer(GL_READ_FRAMEBUFFER, mfbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
// ############## Draw to screen #########################
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glGenerateMipmap(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Draw Some scene.( i am drawing a quad)
}
Now, what i do not understand is, this does not work if do not give :
glGenerateMipmap(GL_TEXTURE_2D);
Why do we need to generate Mipmaps? Can’t we do a render to texture without it? When i do texture mapping, i use glTexImage2D() and give the texel data and it works. So, in a render to texture, i thought that the texel data would be obtained from the texture attachment. But, it doesn’t seem to work until i generate Mipmaps.
Can anyone please explain where i am going wrong?