Drawing TextureFont, FBO, framerate capped at 70

  1. I’m having trouble creating and FBO, in the tutorials these functions are not working:
    gl::Fbo::Format msaaFormat;
    msaaFormat.setSamples(4); // enable 4x MSAA
    gl::Fbo myMsaaFbo(640, 480, msaaFormat);

It says “declared at line 277 in gl/Fbo.h is inaccessible”
also gl::Fbo(400,400); is not a constructor that is available

  1. I think I need to draw the the TextureFont to an FBO because it’s barely readable (not showing up as if it’s in a static UI) when using a 3D camera perspective, right?

  2. I used disableFrameRate(); and the framerate is still capped at 70, but I’m using a GTX 1080.


Generally speaking, cinder prefers to heap allocate the OpenGL wrapper objects via a factory function.

gl::FboRef myMsaaFbo = gl::Fbo::create ( 640, 480, msaaFormat );
1 Like

To clarify a bit:

an Fbo uses resources that can potentially become very big. Copying an Fbo would result in huge memory transfers. Since copying data in C++ can happen at unexpected times (at least for novice users), the Cinder developers wanted to avoid this. There are several ways in which one can do that, for example by using a pointer or reference to an Fbo. Or using a technique called implicit sharing, where the details of the class are stored in an internal shared pointer, making copies light and fast.

The latter was used until version 0.9.0 came out. It was then decided that it would be better to use explicit shared pointers in combination with a create factory method. This is what Cinder uses today.

You can not create an Fbo, because the constructor, copy constructor and assignment operator are protected. This prevents you from writing code that would perform poorly. Instead, you use a shared pointer to an Fbo, for which Cinder defines an abbreviation:

using FboRef = std::shared_ptr<Fbo>;

And as @lithium pointed out, you can then use Fbo’s create method to create one. Your member variable should be of type FboRef, not Fbo. Same goes for things like Texture, Batch and Vbo.


1 Like

Thanks guys, this works. I also got the UI text rendering to the screen correctly by using

Does anyone know about the 70FPS framerate cap? I’m running a 165hz monitor here.

try calling gl::disableVerticalSync() in your setup method.

1 Like

…and call disableFrameRate() in your setup() code to disable the internal frame rate limiter.

1 Like

Thanks! disableFrameRate() got the framerate above 60, but I was confused why it wasn’t going higher than 70. I actually couldn’t find gl::disableVerticalSync() maybe because of the new cinder version?

But I figured out the offender on the draw call was:
mFont = Font("arial", 0.1);mTextureFont = gl::TextureFont::create(mFont);
Removing it made it go from 70FPS to 50000 FPS

I should be careful not to do certain things redundantly on the draw call, doing them only on setup! Trying to get some 3D cellular automation going on here.

My bad. It’s gl::enableVerticalSync(false), but either way it sounds like you’ve gotten to the bottom of it.

1 Like