PDA

View Full Version : glBlitFramebufferEXT



Taicoon
05-29-2010, 05:41 AM
I have an offscreen framebuffer which I blit to the primary framebuffer using
glBlitFramebufferEXT(0, 0, width,height,
0, 0, windowWidth, windowHeight,
GL_COLOR_BUFFER_BIT ,
GL_NEAREST);

This works fine when width and height equals windowWidth and windowHeight, but if they are off by just a single pixel, then it fails with invalid operation. I am using the offscreen fbo to let the visible window rescale while keeping the offscreen rendering constant in size, so this is a big problem for me now.

I have previously been blitting from the offscreen fbo to the primary with different size and it worked just fine. After rewriting the fbo creation to multisampling (now using renderbuffers rather than textures) it has the size requirement which it didn't have before.

glGenFramebuffersEXT(1, &fboID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
glGenRenderbuffersEXT(1, &ColorBufferID);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorBufferID);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFE R_EXT, 8, GL_RGBA8, width, height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, ColorBufferID);

Is there anything in my framebuffer creation which makes it unable to rescale pixel data when blitting? According the the specks, this should work just fine, but it doesn't. Any pointers would be greatly appresiated.

EDIT: currently primary frame buffer is non multisample while the offscreen has been anything from 0 to 16

arekkusu
05-29-2010, 08:00 AM
Spec:

If either the draw or read framebuffer is framebuffer complete and
has a value of SAMPLE_BUFFERS that is greater than zero, then the
error INVALID_OPERATION is generated if BlitFramebufferEXT is called
and the specified source and destination dimensions are not
identical.

Taicoon
05-29-2010, 08:43 AM
Hm, I missed that part, it seems.
Could it be written any clearer? ;-)

The solution is then to have TWO offscreen buffers? one with multisampling and one without, but both with same size. Blit from the one with multisample to the one without and then to the default framebuffer, or is there a simplere generic solution?