How to draw mesh in Fbo?

I just want to mesh draw on fbo. because ofxVideoRecorder need pixels from fbo. I try to add fbo in 3d examples. The code like below that.

void ofApp::draw() {

recordFbo.begin();

float spinX = sin(ofGetElapsedTimef()*.35f);
float spinY = cos(ofGetElapsedTimef()*.075f);

if(bMousePressed) {
    spinX = spinY = 0.0f;
}

ofEnableDepthTest();

... 

if(bInfoText) {
    stringstream ss;
    ss << "Framerate: " << ofToString(ofGetFrameRate(),0) << "\n";
    ss << "(f): Toggle Fullscreen"<<endl<<"(s): Draw Solid Shapes"<<endl<<"(w): Draw Wireframes"<<endl;
    ss <<"(1/2/3/4): Set Resolutions" <<endl<<"(n): Draw Normals"<<"\n(LEFT/RIGHT): Set Mode "<<ofToString(mode,0)<<endl;
    ss <<"(z): Split Faces " <<bSplitFaces<<endl;
    ss <<"(a): Draw Axes"<<endl<<"(l): Render lights"<<endl<<"(t): Info Text"<<endl;
    
    ofDrawBitmapString(ss.str().c_str(), 20, 20);
}

recordFbo.end();

recordFbo.draw(0,0);
}

This code represented like that

Please let me know how to draw mesh in fbo.

Thanks,

fbos don’t autoclear themselves so you are seeing noise that was originally in the texture backing the fbo both in the color and depth buffers. calling ofClear(255) (or whatever color you want to use to clear the background) should solve the problem

Great!!! I really appreciate your comment. The problem has solved.

I just try to fbo.clear(); I don’t know why don’t try ofClear(). It works perfect for me.

Thanks again…

Hi!

I’m having a problem drawing a mesh into a Fbo. When I draw the mesh directly to the screen it works great, but if I draw that mesh into a Fbo and then I draw the Fbo to the screen, it looks more pixelated. I tried allocating the Fbo with different GL modes with no success. I get the same bad results when I try drawing the path into the Fbo instead of the mesh.

this is how I allocate the fbo:

fbo.allocate(1920, 1080);
fbo.begin();
ofClear(0,0,0);
fbo.end();

then I create a mesh coming from a SVG file like this:

svg.load(openFileResult.getPath());

ofPath path;
ofMesh mesh;

path = svg.getPathAt(0);
mesh = path.getTessellation();

fbo.begin();
ofClear(0);
mesh.draw();
fbo.end();

this is how I draw the Mesh and the Fbo into the screen:

mesh.draw();
fbo.draw(0, 200);

and the result looks like this:

I read a lot of problems about opacity in Fbo’s, my background is transparent, just in case is a useful info.

Can anyone help me on this?

Hi @luiscript

Witch Fbo settings http://openframeworks.cc/documentation/gl/ofFbo::Settings/ did you try?

For me would make sense try different GL modes (like GL_RGBA16F_ARB,
GL_RGBA32F_ARB ) to check depth color quality needed.

About this antialiasing issues, [multisampling] (https://forum.openframeworks.cc/t/render-to-texture/371/33)
seems to help.

Transparent background and blend mode seems to negatively affect…

was drawing on a transparent FBO; the blending wasn’t helping. When I clear the FBO with solid black (0,255) it looks as it
https://github.com/openframeworks/openFrameworks/issues/3598

Hello @charli_e

I found a solution within the github issue that you posted… I tried with different GL modes but I never tried to increase the number of samples, that was the key.

void ofFbo::allocate(int width, int height, int internalformat, int numSamples=0)

this worked for my case:

fbo.allocate(1920, 1080, GL_RGBA, 4);

Your reply was quick and accurate, thank you so much for that.

Great ! :slight_smile: