How to know when it's safe to draw in ::draw()?

I have that code to load an image and draw it on the screen. It should draw it once and keep it shown. Below is the simplified code. However the window stays grey. It works if I let call image.draw() several times before skipping on next calls, but that would mean that when ::draw() of the ofBaseApp is called you can never know if you can start drawing or if something is still initializing in the background. Or is maybe something wrong with my code?

OSX, OF 0.9.3.

#include "ofApp.h" 
bool painted = false;
ofImage image;

//--------------------------------------------------------------
void ofApp::setup(){
    ofSetVerticalSync(true);
    ofSetFrameRate(60);
    ofSetBackgroundAuto(false);
    ofDisableAntiAliasing();
    ofDisableDepthTest();

    image.load("/Users/test/image.jpg");
}

void ofApp::update(){
}

void ofApp::draw(){
    if (!painted) {
        image.draw(0, 0);
        painted = true;
    }
}

the OF model is not to draw something once and it stays but actually draw everything every frame. this comes from video games and similar applcaitions where everything changes every frame so there’s no point in trying to draw some things only once, you just redraw the whole screen every frame.

also there’s nothing loading in the background by default you would have to explictly create a thread to load anything in the background, otherwise everything is loaded when you do the call and the call won’t return until it finishes.

calling ofSetBackgroundAuto should not clear the background every frame though but because of a gltich when starting the applciation we leave 3 frames after untill really starting to not clear.

thinking of it, it really sounds like a bug and we should just clear the screen manuallly until calling draw again in the app to avoid unpredictable behaviour like this. can you open an issue in github

Thanks for the reply, will open an issue. You are right and I understand the Of model working that way. However it seems for me as a waste of CPU and GPU time to redraw something that will maybe never change. For embedded systems that’s something that cares…