Multi-Window Rendering - path of least resistance

Hey Embers,

While developing my Cinder-based audio/video instrument I’ve run into some complications I was anticipating, but still unsure of how to handle most effectively. My program will be rendering some video/visuals - partially by help of FBO’s - which I’d like to display on a secondary window. I’m aware that FBO’s cannot be shared across OpenGL Contexts, which as far as I am concerned, is fine.

Since I really just want my secondary window to output a flat 2d render, I am currently thinking the easiest way forward is simply to do 99% of the heavy lifting in the primary context, and share one solitary texture with the second context and render it as necessary. What I’m wondering is…

  • How do I actually do this?
  • Performance penalties?
  • Alternate drawbacks?

Varying sources that I’ve read seem to indicate that Cinder/OpenGL automatically will share resources from the primary windows context with the secondary windows context, as long as they’re created in this primary context? Which would lead me to think all I need to do is create single texture in the main context at any time, copy the FBO contents I want to draw into that and have the secondary window display that? Does that sound feasible?

Apart from the penalty of copying a texture, I fail to immediately see any performance drawbacks. I will likely want to render the contents of this FBO output in the primary window as well, so it seems like this is the smartest way forward to me.

I’ve tried to think if I might face problems down the road if the secondary interface suddenly becomes interactable - which I currently don’t foresee happening. Even there it would seem keeping everything in the primary context is far (FAR) easier, no?

Regards,

Gazoo

Hint: an Fbo can not be shared between contexts, but a Texture can be :slight_smile:

1 Like

@paul.houx - Many thanks for the tip :slight_smile: - although I feel as though my text highlights my awareness this approach? I know the right thing is to just try it, which I intend to do now - I couldn’t help myself to ask if anyone might perceive some downsides or issues that I highlight?

I think most of what you wrote is correct and should work. My hint was aimed at how you’d render to an Fbo. You don’t have to copy from the Fbo to another Texture, just use the shared Texture as the target of the Fbo and render directly to it on the main thread. Then unbind the Fbo and display the Texture in the second window.

1 Like

You can easily do that compiling two applications and sharing the texture with Syphon.