Framebuffer Unsupported error

I get FrameBufferUnsupported error when doing the following. What I’m doing wrong? (I’m using OpenTK)

                // Create color texture
                reflectionTexture = GL.GenTexture();
                GL.BindTexture(TextureTarget.Texture2D, reflectionTexture);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, 
                    256, 256, 0, PixelFormat.Rgb, PixelType.UnsignedByte, IntPtr.Zero);                               
                GL.BindTexture(TextureTarget.Texture2D, 0);

                // Create depth buffer
                GL.GenRenderbuffers(1, out depthBuffer);
                GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, depthBuffer);
                    RenderbufferStorage.DepthComponent32, 256, 256);

                // Create framebuffer
                GL.GenFramebuffers(1, out frameBuffer);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
                // Attach color texture
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, 
                    TextureTarget.Texture2D, reflectionTexture, 0);
                // Attach depth buffer
                GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment,
                    RenderbufferTarget.Renderbuffer, depthBuffer);                
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

                GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
                FramebufferErrorCode err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

Read the OpenTK manual:

GL.Ext.RenderbufferStorage(RenderbufferTarget.RenderbufferExt, (RenderbufferStorage)All.DepthComponent32, FboWidth, FboHeight);
// test for GL Error here (might be unsupported format)

Try DepthComponent (without 32) to be sure the format causes error.

Hi Dmitry.

I added


just below

GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, 
                    256, 256, 0, PixelFormat.Rgb, PixelType.UnsignedByte, IntPtr.Zero);  

and it worked!

The strange thing is that I’m getting low color values. I mean, I clear the buffer with ClearColor = 1,0,0,1 and I get a dim red color, same for blue or green. Any idea what can be wrong?

Got it. I’ve been catch by the OpenTK overloads. Once again! :

GL.Color4(1, 1, 1, 1);

Instead of:

GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);

Thanks anyway dmitry!

GL.Color4(1, 1, 1, 1) is not correct (the value passed is 1/256).
GL.Color4(1.0f, 1.0f, 1.0f, 1.0f) is a right value (have you misplaced when answering?).

And I still don’t understand how GenerateMipmap helped you. It has nothing to do with FBO as you are rendering to 0-level only.

I was not clear enough. Sorry.
GL.Color4(1,1,1,1) was what I was doing to display the rendered texture, that’s why I got dim colors. I replaced it by the float version. I don’t understand the mipmap stuff neither, but it worked with it.