View Full Version : Framebuffer Unsupported error

11-19-2009, 06:21 AM
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.Renderbuffe r, depthBuffer);
GL.RenderbufferStorage(RenderbufferTarget.Renderbu ffer,
RenderbufferStorage.DepthComponent32, 256, 256);

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

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

11-19-2009, 06:26 AM
Read the OpenTK manual:

GL.Ext.RenderbufferStorage(RenderbufferTarget.Rend erbufferExt, (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.

11-19-2009, 06:35 AM
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?

11-19-2009, 06:52 AM
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!

11-19-2009, 07:05 AM
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.

11-19-2009, 07:23 AM
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.