Ways to optimize slow ofTrueTypeFont

Hi All,
I’m trying to draw some scrolling text with ofTrueTypeFont. However the frame rate is slow on Raspberry Pi.
Is there way to pre-render mesh or bitmap and keep it in memory instead of generate the same thing in each frame?

Thanks
Deqing

Try drawing all the text into a framebuffer first and then drawing subsections of that:

void ofApp::setup(){
    fbo.allocate(ofGetWidth(), totalTextHeight, GL_RGBA);
    fbo.begin();
    //draw all the text you'll display.
    fbo.end();
}

void ofApp::draw(){
    fbo.getTextureReference().drawSubsection(0, 0, ofGetWidth(), ofGetHeight(), 0, ofGetElapsedTimef(), ofGetWidth(), ofGetHeight()); 
}

http://openframeworks.cc/documentation/gl/ofTexture.html#!show_drawSubsection

This should only make one draw call and will hopefully be faster.

2 Likes

Thanks.
I used this method. Create a new ofFbo when preparing a new string.
And my frame rate increased from 27 to 60(Max framerate) on Rpi2