Sign in to follow this  

How to set back buffer format?

Recommended Posts

[quote name='Brother Bob' timestamp='1313447573' post='4849600']
The back buffer has the same format as the front buffer. If you need a buffer with an arbitrary format, then you need to look into offscreen framebuffer objects.

That's actually the reason I need to do this. I'm using a framebuffer to render my effects but I need multi-sampling and I have to use OpenGL 3.1 which does not support multi sampled textures.(Ironically GL 3.2 does)The only thing I could think to do was draw to the back buffer with multi sampling and then copy it to a texture. This works great but the one flaw with this is that the back buffer is not a floating point texture which prevents me from using HDR effects...

I think what I need to do is create my frame buffer like this:

glGenFramebuffers(1, &rendertarget->frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, rendertarget->frameBuffer);

//// Multi sample colorbuffer
glGenRenderbuffers(1, &rendertarget->colorBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, rendertarget->colorBuffer);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA16F, WindowRect.right - WindowRect.left, WindowRect.bottom -;
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rendertarget->colorBuffer);

// Multi sample depth buffer
glGenRenderbuffers(1, &rendertarget->depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, rendertarget->depthBuffer);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT24, WindowRect.right - WindowRect.left, WindowRect.bottom -;
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rendertarget->depthBuffer);[/code]

Then I bind the buffer, render to it, then copy the texture information from the frame buffer to a texture. Is that right? If so then how do I copy the frame buffer to a texture without binding a texture to the frame buffer?

Share this post

Link to post
Share on other sites
You can get the supported formats with DescribePixelFormat or use the the modern version which I can't remember off the top of my head. Check out the functions for FSAA.
Normally, the backhuffer doesn't support floating point formats.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this