I'm exploring FBO's, and I have a few questions about FBO completeness.
I started by setting up my render targets with RenderBuffers that were the same size as my Window. (1024x768, I'm working on Windows XP).
glGenFramebuffers( 1, &fbo_id );glBindFramebuffer( GL_FRAMEBUFFER, fbo_id );glGenRenderbuffers( 1, &depthbuf_id );glBindRenderbuffer( GL_RENDERBUFFER, depthbuf_id );glRenderbufferStorageMultisample( GL_RENDERBUFFER, 0, GL_DEPTH_COMPONENT, w, h ); glGenRenderbuffers( 1, &colorbuf_id );glBindRenderbuffer( GL_RENDERBUFFER, colorbuf_id );glRenderbufferStorageMultisample( GL_RENDERBUFFER, 0, GL_RGBA, w, h );glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthbuf_id );glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuf_id );glBindFramebuffer( GL_FRAMEBUFFER, 0 ); //restore rendering to default framebuffer
This worked fine, no problems. I upped the Multisample values, and got some MSAA, lost some framerate, just as expected. Then I tried to use Textures instead of Render Buffers, and I'm getting FRAMEBUFFER_INCOMPLETE_ATTACHMENT errors.
glGenFramebuffers( 1, &fbo_id );glBindFramebuffer( GL_FRAMEBUFFER, fbo_id );glGenTextures( 1, &depthbuf_id );glBindTexture( GL_TEXTURE_2D, depthbuf_id );glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, w, h, 0, GL_DEPTH_COMPONENT16, GL_UNSIGNED_BYTE, 0 );glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthbuf_id, 0 );printf("%x\n", glCheckFramebufferStatus( GL_FRAMEBUFFER )); //INCOMPLETE_ATTACHMENTglGenTextures( 1, &colorbuf_id );glBindTexture( GL_TEXTURE_2D, colorbuf_id );glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf_id, 0 );printf("%x\n", glCheckFramebufferStatus( GL_FRAMEBUFFER )); //INCOMPLETE_ATTACHMENT
I'm running on a rather old (but not ancient) GeForce 8400M GS. I have a recent driver which is telling me I support OGL 3.2. It also tells me that I support GL_ARB_framebuffer_object (as opposed to GL_EXT_framebuffer_object)
I first thought that it might be a power of two problem, my first attempt used TEXTURE_RECTANGLE as the target. My driver advertises that I support GL_ARB_texture_rectangle, and GL_ARB_texture_non_power_of_two. I also read atthe Khronos website that the supported color formats for "Color attachable images" were very limited (like GL_RGBA4), which is just confusing to me (after all, isn't the color renderbuffer in my top example a "color attachable image"?) Also, that doesn't line up with this really old NVidia presentation.
So, basically, I'm left thinking that I'm just missing some obvious step, and I'm looking in all the wrong places for the mistake. Does anyone with better eyes than me see a problem?
One other quick thing I changed - when I started messing with the FBO code, I removed the depth buffer from my Window PixelFormatDescriptor - I figured that at the end of my post processing, I would just blit the output to the main window, so depth wouldn't be necessary.
Anyhow, thanks for any help!