ofFbo easyCam visualization before save high res pict

Hi, I am trying to save a high resolution image using ofFbo. I am converting an image to a mesh and then position the mesh using ofEasyCam, however I cannot see the mesh when using the ofFbo. The mesh is present on the captured image, yet very small (I reckon because the size of the ofFbo). I would like to move and rotate the mesh and then capture the High Res image. The mesh is not drawn either with and without the ofFbo.draw(). I guess I am missing something or perhaps there is another approach.

the resumed code:

void ofApp::setup(){

 ofSetVerticalSync(true);
  image.load("image.jpg");

  image.resize(image.getWidth()/2, image.getHeight()/2);

  w = image.getWidth();
  h = image.getHeight();

  fbo.allocate(8192, 8192, GL_RGBA);
  
  mesh.setMode(OF_PRIMITIVE_LINES); // Line mode
  mesh.enableIndices();
  mesh.enableColors();

  //IMAGE TO MESH FUNCTIONS

  imageToMesh(); //Image to mesh function
  vertLines(); //function that creates lines between the vertices
}

void ofApp::draw(){

  ofColor centerColor = ofColor(255, 255, 255);
  ofColor edgeColor(255, 255, 255);
  ofBackgroundGradient(centerColor, edgeColor, OF_GRADIENT_CIRCULAR);
 
  fbo.begin();
  ofClear(255);
  
  easyCam.begin();
  ofPushMatrix();  

//ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);

  mesh.draw();

  ofPopMatrix();
  easyCam.end();	    
  
fbo.end();

 //fbo.draw(0,0);
    
}

void ofApp::keyPressed(int key){

  if (key=='s') {
ofPixels pixels;
fbo.readToPixels(pixels);
 ofSaveImage(pixels, "test.png");
  }
}

Any idea why? thanks

Hey @pemb

This works for me - I am just testing with a sphere.

Bear in mind 0,0 will be the fbo / cam center and the apparent size will be relative to 8192 width ( ie: a sphere with a radius of 8192/2 will fill the whole fbo ).

void ofApp::setup(){
  fbo.allocate(8192, 8192, GL_RGBA);
  ofBackground(40, 40, 40);
}

void ofApp::draw(){
 
    //the camera needs the viewport to be the same dimnensions as the fbo
    ofRectangle fboRect(0, 0, fbo.getWidth(), fbo.getHeight());

    fbo.begin();
        ofClear(0, 0, 0, 255);

        easyCam.begin(fboRect);
                //put all the meshes in here
                //y might be flipped, but you can use an ofScale(1,-1,1) if needed.
                ofDrawSphere(0, 0, 0, 150);
        easyCam.end();
    fbo.end();

    //now when we draw the fbo to the screen, it is so much bigger than the screen.
    //so scale it down proportionally so it fits on the screen
    ofRectangle screenRect = fboRect;
    screenRect.scaleTo(ofRectangle(0, 0, ofGetWidth(), ofGetHeight()));
    
    fbo.draw(screenRect);
}
1 Like

Thanks a lot, it works great. I had forgotten the ofRectangle.

1 Like