First off, this is my first time on the forums and I really need to publicly thank you all for this great framework. It got me started with C++ and opened a lot of creative possibilities for me
But now I’ve run into a problem where I don’t know what to do.
I’m drawing lots of circles on top of circles with no background in between the draw calls.
So I use this configuration in my setup:
ofSetBackgroundAuto(false); ofEnableAntiAliasing(); ofEnableAlphaBlending();
The result when drawing is this:
I want to save an image sequence out of it with a larger size than my screen.
So I figured I would need to use an FBO.
To get the layered effect working, I’m saving the current image as an FBO and drawing it before drawing the current iteration of circles.
It looks like this:
[...] ofClear(255, 255, 255, 0); fbo2.draw(0, 0); ofClearAlpha(); [...] fbo.end(); fbo2 = fbo; fbo.draw(0, 0);
This works perfectly fine, I had some troubles with the alpha (before ofClearAlpha(), but I found a solution. The problem was, that the colors looked different.
They now looked like this:
IMGUR, first picture titled “raw FBO / glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);”
A little more washed out.
I stumbled upon a couple of forum posts like this one: " [Weird problem rendering semi-transparent image to FBO"
And started to implement a GLBlendMode. Using
ofClear(255, 255, 255, 0); glEnable(GL_BLEND); glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); fbo2.draw(0, 0); ofClearAlpha();
I get the right colors, but not the sexy anti-alias blur anymore. It looks like this:
IMGUR, second picture titled “glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);”
Tinkering around with different GLBlendFunc settings, I found out that
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); instead of the
glBlendFuncSeparateto the washed-out result, so this is what OF seems to use in some way?
But I can’t figure out what the correct glBlendFunc settings would be.
Or how I can just use an FBO without getting altered colors?
Does anybody have any idea?
I can of course share more code, just didn’t want to spam you with a wall.
Thanks a lot!
Also sorry about the IMGUR links, can’t have more than one picture as a new user in a post.