Skip to content

Instantly share code, notes, and snippets.

@HalfdanJ
Created May 25, 2016 19:00
Show Gist options
  • Save HalfdanJ/ecabb757e72092c698a5b90c8622fc27 to your computer and use it in GitHub Desktop.
Save HalfdanJ/ecabb757e72092c698a5b90c8622fc27 to your computer and use it in GitHub Desktop.
ofFbo with premultiplied alpha
// Kudos to armadilly
fbo.begin();
///pre-multiply background color of the fbo for correct blending!
ofClear(ofColor(fboBgColor * (fboBgColor.a / 255.) , fboBgColor.a));
//Set this blending mode for anything you draw INSIDE the fbo
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
//your draw code here!
fbo.end();
//then draw the fbo to your screen buffer with this blending
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
fbo.draw(0,0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment