OpenGL Context resize needs a call to makeActive


#1

I have the following problem with the Cocoa implementation for OpenGL (Juce 1.50):
My program has two threads: the user-interface thread and an OpenGL thread. In my OpenGL thread, I call makeCurrentContextActive() once when the thread begins and makeCurrentContextInactive() once when the thread finishes. In this setting, resizing the OpenGL context fails.

I found that the problem comes from the ThreadSafeNSOpenGLView class, which waits a call to makeActive(), to update the GL context (through the needUpdates flag). makeActive() should thus be called before rendering each frame, which – in my thought – could slow down rendering (when the thread uses a single opengl context, and depending on the GL driver implementation).

Maybe, checking the needUpdates flag should be done during the swapBuffers() to fix this problem ?


#2

I think that the whole point of doing it like that was to make sure the update happened on the drawing thread, during a makeActive() call, so yes, I’d suggest just calling it before each frame. I don’t think it’d slow anything down noticably.