test.allocate(ofGetWidth(),ofGetHeight(), GL_RGBA);
//clear with a black color non transparent
test.begin(); ofClear(0,0,0,255); test.end();
draw:
test.begin();
ofEnableAlphaBlending();
//clear blue
ofClear(0,0,255,255);
ofFill();
ofSetColor(255,255,0);
ofRect(10,10,100,100);
test.end();
test.draw(100,100);
I would expect a blue fbo with a yellow rectangle. However I end up with a yellow rectangle on a black background. Why? What am I missing? Drawing directly to screen instead of the Fbo works as expected.
So the reason you were getting black is that you were drawing the fbo with the current color being:
255,255,0 ( yellow )
The FBO background is blue ( 0, 0, 255 ), so when multiplied, the 0 in the blue channel of the yellow draw color, cancels out the blue in the background all together - leaving you with black.
As a general rule you should always do ofSetColor(255, 255, 255);
before drawing an FBO, unless your intentionally wishing to draw it with a tint.