Threaded GL Content Loading in Cinder

hey there ci::Folk,

ive come up against some slow downs in my app when loading various content,
and now working on mitigating using some threaded loading.

have been sticking close to the FlickrTestMultithreaded sample,
and have implemented threaded image loading in my app,
this has been working great but was not enough to stop the jerkiness on load.

my app is generating a lot of custom text using ci::TextBox as well as other FBOs for content which im hoping to off-load to a background thread.

i thought that maybe following the FlickrTestMultithreaded sample, i could do all my FBO initialisation and text generation on a background GL thread. the way ive approached this is by passing my content object as a shared_ptr (using ConcurrentCircularBuffer) to the background thread and calling a method on it to create and render FBOs and text.

the results were promising on OSX, seemed to be working fine but on Windows im getting blank FBOs, suggesting that FBOs don’t like to be created or rendered on the background GL thread.

would love to know if what im trying to achieve is even possible?
and if so, what the correct way of doing it would be?

cheers, L.

I’m pretty sure FBOs can’t be shared across contexts, but the textures / renderbuffers they contain can. Are you creating the FBO on the secondary thread as well as rendering to it there?

hey @lithium, yes the FBOs are being created on the background thread.
sounds like this is where the issue is… :frowning:

i have been considering creating a number of FBOs when the app first launches and then reusing them for the content rendering, so there is a way i can get around the FBO issue.

but the app is still generating a lot of text using ci::TextBox which i have noticed slows down the app quite a bit.
im assuming that under the hood the text is being rendered into an FBO also.
is there any way of somehow generating dynamic text in cinder on a background thread?


My understanding is that TextBox is entirely CPU side and renders to a Surface. With this case you could either share a context and do the texture upload on the background thread, or just do the CPU side text rendering on the background thread and push the Surface back to the main thread via App::dispatchAsync() for GPU uploading.

I can’t help you with the FBO side of things though, thankfully it’s not an issue I’ve come across before.

1 Like

@lithium.snepe, thanks for the info about ci::TextBox
i’ll investigate some more and try to generate the text on the background thread.
once the text is generated ill be rendering it to an FBO on the main thread.
hopefully that works… will report back with results.

didn’t know about App::dispatchAsync()
but i might stick to using the ConcurrentCircularBuffer approach as ive become familiar with it… assuming both approaches are just mechanisms for getting content back onto the main thread.