Original Post
I'm having a problem with Renderbuffers. I have been messing around with this piece of code for a while and I couldn't get it to work the way I want. Here is how i initialize my color buffer, depth buffer and bind them to a FBO: Here is how I render to the FBO and then blit the FBO to the normal frame buffer: Now it is my understanding that this is enough and I should get something onscreen. However, thats not the case. I tried binding a texture instead of the color buffer and render it to a fullscreen quad with no success. I could however get something on the screen when i did not attach the depth component to the framebuffer (i.e. the framebuffer had a color texture only) but this is not what I'm looking for as there is no depth testing and no multisampling. What am I doing wrong? I'm sure it is something simple that I don't see.
//Depth renderbuffer
glGenRenderbuffersEXT(1, &depthbuf);
gbuf.DepthBufferID = depthbuf;
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuf);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 4, GL_DEPTH_COMPONENT, >ResolutionX,ResolutionY);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
//Color renderbuffer
glGenRenderbuffersEXT(1, &colorbuf);
gbuf.ColorBufferID = colorbuf;
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorbuf);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 4, GL_RGBA8, ResolutionX, ResolutionY);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
//FBO
glGenFramebuffersEXT(1, &framebuf);
gbuf.FramebufferID = framebuf;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuf);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorbuf);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuf);
//Render to FBO
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT);
glViewport(0, 0, ResolutionX, ResolutionY);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Gbuffers[0].FramebufferID);
for(int i=0; i<this->Renderables.size(); i++)
{
this->Renderables.Render();
}
glPopAttrib();
//Blit FBO to normal frame buffer
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, Gbuffers[0].FramebufferID);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
glBlitFramebufferEXT(0, 0, ResolutionX, ResolutionY, 0, 0, ResolutionX, ResolutionY, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);