Using ofEasyCam with a larger FBO

I’m trying to draw a scene to an FBO which is larger than the window whilst being able to move around the scene with a camera.

Currently I’m set up like this:

//--------------------------------------------------------------
void ofApp::setup(){
    largeFBO.allocate(ofGetWidth() * 2, ofGetHeight() * 2);
    
    largeFBO.begin();
    ofClear(ofColor::grey);
    largeFBO.end();
    
    cam.setupPerspective();
}

And drawing:

//--------------------------------------------------------------
void ofApp::draw(){
    // draw to the fbo
    largeFBO.begin();
    ofClear(ofColor::grey);
    ofPushMatrix();
    
    cam.begin();
    ofScale(1, -1, 1);
    ofScale(0.5, 0.5, 0.5);
    
    // ...
    // render the meshes
    // ...
    
    cam.end();
    ofPopMatrix();
    largeFBO.end();
    
    // draw the fbo to the window
    largeFBO.draw(0, 0, ofGetWidth(), ofGetHeight());
    
}

The scene renders correctly but the camera interaction is pushed off centre somehow.

The region where a drag on the window rotates the camera around the z-axis seems to move as though the the camera is using the larger space of the FBO for the interaction. I can’t figure out how to transform the space of the window into the FBO correctly.

Any pointers would be greatly appreciated :slight_smile:

I have managed to get this working by using two ofEasyCam instances: one for the FBO and one for the screen. The model view matrix being transferred from the screen camera to the FBO camera in update.

There’s probably a much more elegant solution but I just wanted to share in case someone is interested.

1 Like