I use the following code to setup the framebuffer:
GLuint color_tex,depth_rb,fb;
glGenTextures(1,&color_tex);
//initialize textures
glBindTexture(GL_TEXTURE_2D,color_tex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,512,512,0,GL_RGB,GL_UNSIGNED_BYTE,0);
glGenRenderbuffersEXT(1, &depth_rb);
//initialize depth renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);
glGenFramebuffersEXT(1, &fb);
//initialize frame buffers
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
The code seems right, however, it doesn’t work in my system. If I comment out the depth attachment it works. I always get FRAMEBUFFER_UNSUPPORTED, no matter what format I choose for DEPTH_COMPONENT(16,24 or 32).
So, what’s the deal here? I have the latest drivers(75.90) and the extension is supported in my card.
I could assume it’s because the FBO implementation is still in beta, but other users tried it in 6800 and it worked.