ofDrawBitmapString and ofSetBackgroundAuto(false);

Hi,
I am drawing paths with ofPath and I need to have the background refresh set to false in order to keep the path (or so I think).
At the same time I am trying to get some data displayed through ofDrawBitmapString. Unfortunately, as expected, the refreshed bitmap data overlap and they become unreadable.
I also tried with ofTruetypeFont. Same result of course.
I was wondering if there’s a way to split the background or another way to get this?
I also have other questions about ofPath but I’ll put them in another post.

Cheers!

You should look at ofFbo. But if your string is not too long, it will be easier to use ofSetWindowTitle(…) instead of rendering the string.

you might also look at ofDrawBitmapStringHighlight(…) which draws a string and a box behind it. If your string is not changing size too much (for example, drawing FPS as a string) this can work.

@micuat thanks for the hint, I think ofFbo it’s really interesting and I will dig into it but either is not working for this or I didn’t manage to make it work as I keep on having the same overlapping.
@zach thanks! Your solutions sounded like the quick and painless way. indeed it’s working quite well with a tiny bug that I can’t understand.
I am enclosing a screenshot
pMouseDelta ( pMouseDelta=ofDist(mouseX, mouseY, pMouseX,pMouseY); )
is the only one that doesn’t work well. first digit is overlapping the second for some reason.

thanks for help!

I think that’s just because the earlier value is longer than the incoming value and the screen is not redrawing. You might need to change the string, alternatively, you can draw a bigger box behind the type.

also, as @micuat suggest, FBO should really help you here. small example:

in .h:

ofFbo myFbo;

in .cpp

//--------------------------------------------------------------
void ofApp::setup(){

    myFbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA, 4);
    myFbo.begin();
    ofClear(255,0,255, 255);
    myFbo.end();
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

    
    myFbo.begin();
    ofSetColor(0,255,255, 30);
    ofCircle(mouseX, mouseY, 30);
    myFbo.end();
    
    
    ofSetColor(255);
    myFbo.draw(0,0);
    
    ofDrawBitmapString(ofToString(ofGetFrameRate()), 100, 100);
}

then, you can do stuff like this – have a non clearing portion of the screen and draw things that don’t need to be in that, on top:

hope this helps,
zach

1 Like

@micuat I understand now why my ofFbo wasn’t working.
I put the ofDrawBitmapString in the ofFbo, instead of the code for drawing the line.
Now it’s working perfectly!
Thanks a lot to both of you.

:sunny: