Render to multiple windows with OpenGL

opengl

#1

Hi,

I have a situation where I need to render a texture to multiple windows and this texture can be the same for all the windows.
Now technically (not considering JUCE) I have a few options, of which two are the most obvious:

1: Create a context for every window and let the contexts share resources.
2: Create one context and for every window: attach to context and render.

With the JUCE OpenGLContext neither of these options really work for me because attaching a Component to the context starts a thread that runs a loop continuously or not depending on setRepaintContinuously().
This behaviour gives me some glitches because multiple threads are binding/unbinding the same texture that can be fixed by locking them, but this is far from ideal.
This behaviour also drops the fps by a factor of two for every thread that is started.

My question is if there is a way to attach a component without the context starting a new thread so I can run my own loop and just attach the window I want to render on and swap the buffers?

The platform specific implementation of this for MacOS would be to simply set the view member of the NSOpenGLContext.
On windows you can make the context current with a different HDC (with the same pixelformat).

Thanks :slight_smile: