# Drawing TextureFont, FBO, framerate capped at 70

**URL:** <https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211>\
**Category:** Using Cinder\
**Created:** [July 9, 2018, 1:42am UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211 "2018-07-09T01:42:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlJalal](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@CarlJalal](https://discourse.libcinder.org/u/CarlJalal)\
**Post date:** [July 9, 2018, 1:42am UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/1 "2018-07-09T01:42:01Z")

</div>

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [July 9, 2018, 2:31am UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/2 "2018-07-09T02:31:27Z")

</div>

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

```cpp
gl::FboRef myMsaaFbo = gl::Fbo::create ( 640, 480, msaaFormat );

```

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [July 9, 2018, 7:03am UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/3 "2018-07-09T07:03:42Z")

</div>

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:

```auto
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`.

-Paul

---

<div class="post-metadata">

**Author:** ![CarlJalal](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@CarlJalal](https://discourse.libcinder.org/u/CarlJalal)\
**Post date:** [July 9, 2018, 1:53pm UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/4 "2018-07-09T13:53:29Z")

</div>

Thanks guys, this works. I also got the UI text rendering to the screen correctly by using  
gl::setMatricesWindow(getWindowSize());

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

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [July 9, 2018, 1:59pm UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/5 "2018-07-09T13:59:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [July 9, 2018, 2:42pm UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/6 "2018-07-09T14:42:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CarlJalal](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@CarlJalal](https://discourse.libcinder.org/u/CarlJalal)\
**Post date:** [July 9, 2018, 2:48pm UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/7 "2018-07-09T14:48:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)\
**Post date:** [July 9, 2018, 3:12pm UTC](https://discourse.libcinder.org/t/drawing-texturefont-fbo-framerate-capped-at-70/1211/8 "2018-07-09T15:12:42Z")

</div>

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