How to blit two transparent frame buffer objects using QOpenGLFramebufferObject?

Viewed 385

I have two FBOs created using QOpenGLFrameBufferObject, which are images with a transparent background and some lines and text on top of them. I am blitting the first fbo onto the second using QOpenGLFramebufferObject::blitFramebuffer, this results in the content of the first fbo on top of the second. However, I would like to preserve the transparency of the the first fbo and blend the content of the first fbo on top of the second fbo (instead of erasing the portion of the second fbo and redrawing the first fbo on top of it). Looking around, I think this might be possible with glBlendFunc, but the following didn't really achieve the result I wanted.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// then blit fbo1 on top of fbo2
QOpenGLFramebufferObject::blitFramebuffer(fbo2, fbo1);

How can I preserve the transparency (by blending them together) of my framebuffers when I blit them?

1 Answers
Related