How to clear my fbo with a right way?

There was something strange when I tried to clear my fbo every frame.

fbo1.begin();

//difference
ofClear(255, 255, 0, 0);
ofSetColor(100, 100, 100, 200);
ofRect(0, 0, 200, 200);

fbo1.end();


fbo2.begin();

//difference
ofClear(255, 0, 0, 0);
ofSetColor(100, 100, 100, 200);
ofRect(0, 0, 200, 200);

fbo2.end();

But even when I set the alpha to 0, it seems still work on the follow-up rendering.

It is quite different from what I could have imagined.I thought the ofClear() ought not to have impact on the ofRect().

I tried to surround my rendering code with ofPushStyle() & ofPopStyle(), but it doesn’t work.

I’ve got no idea about this.

Are the ofRects covering the entirety of the fbos? if they fill up the fbo area, then it might be hard to tell what’s happening since the rects are drawing with the same color, maybe try drawing them with different colors. Also make sure that you are calling draw on the fbos somewhere to render them to the screen. :smile:

I tried hard to test it, eventually it seems ofClear parameter’s type was “float”, not “unsigned char”.

So the maximum value of the color was 1.0 not 255, and I thought it is very difficult to find.