View Full Version : Multisample QGLFramebufferObject gives double image

24th September 2010, 21:51
I'm using a QGLFramebufferObject to do some off-screen, OpenGL rendering and I'm getting a weird result.

The off-screen rendering task runs in it's own thread so I create a QGLPixelBuffer so I have a valid OpenGL context. Then I create the FBO, a display list and a cube-map texture.

When I run the task it should generate a lattitude-longitude thumbnail of the cube-map. This works fine if I use a standard QGLFramebufferObject with a texture as the target and NO multisampling:


This is the correct result with a test cube-map. Now, I tried modifying the FBO for multisampling, first just by passing in a QGLFramebufferObjectFormat with samples set to something like 4 or 8. This did not work and gave me the results below:


Note the double image with the 1/2 sized version in the bottom left AND the fact that no multisampling is being done (jagged edges still appear). I remembered from when I did multisampled FBOs on my own in a basic GLUT program that you need to only use a color attachment for the multisampled buffer and then blit this over to an FBO with a texture target attached to get this to work (at least, to get the results into a texture).

So I tried that as well (two QGLFBOs, one with the samples and one with a single texture attachment, rendered to the multisample one, called the new QGLFramebufferObject::blitFramebuffer() function) but I get the EXACT same results as above.

I'm going to leave my code out for now as it's quite large, I'm mostly just wondering if someone else has observed this type of behavior before and has any idea what I'm doing wrong. I know multisampled FBOs are tough and I've only ever gotten them working in native OpenGL. This is the first I've tried them in Qt.

Other details:
- The Qt Example 'framebuffer' works fine on the same machine WITH the multisampled FBO so it's not a hardware limitation.
- I'm drawing to the FBOs using my own native OpenGL code, not with a QPainter or anything like that as the 'framebuffer' example does so emulating that code only works to a point.