ofSetFullscreen() automatically clears the screen once?

If I disable automatic background clearing by calling ofSetBackgroundAuto(false);, and then if I call ofSetFullscreen(true); to enter the fullscreen mode, it seems to clear out the previous drawings.

Here’s my simple test code.

//--------------------------------------------------------------
void ofApp::setup(){
    
    ofSetBackgroundAuto(false);
}

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

//--------------------------------------------------------------
void ofApp::draw(){
    
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
    ofRotateZ(ofGetFrameNum()/2);
    ofTranslate(ofGetHeight()/4, 0);
    ofDrawCircle(0, 0, ofGetHeight()/40);
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    
    if (key == '1')
        ofSetFullscreen(true);
    else if (key == '2')
        ofSetFullscreen(false);
}

If you run the program and press ‘1’ to enter the fullscreen mode, you will see the previous drawings getting cleared.

Is this natural behaviour or could this be a bug?
Thanks in advance!

this depends on the platform but usually switching to fullscreen involves destroying the current buffer or even the current window and creating a new one so yes it’s normal that the screen is cleared. if you want more control over this is better to use an fbo instead of drawing directly to the screen

1 Like

Thank you @arturo