Initializing an OpenGL context during startup?

Currently I’m using JUCE’s OpenGLContext and OpenGLRenderer to render some stuff. As I’ve understood, you’re supposed to do any OpenGL initialisation during OpenGLRenderer::newOpenGLContextCreated() as there is a context available then.

Is it also possible to do the initialisation during startup already somewhere (so before any GUI-items are shown)? This would save me a few ugly callbacks, but more importantly, would allow me to use a valid OpenGLContext during unit testing.

Thanks in advance for your help!

As far as I remember I once ran into a lot of trouble trying to do so, with some hard to understand errors. One of the JUCE devs here on the forum then replied to this that it’s obvious that GL related setup stuff does not work before any GUI has been created as the OS has not chosen which physical GPU to use to do the rendering before the Window appears on your screen which seemed logical to me back then.

However, there might be people round here with some deeper insight :wink:

Thanks for your reply! I was afraid of something like that. My tests are currently run in FractaliciousApplication::initialise(), just before creating the MainWindow. Do you have any idea at what point an OpenGLContext could be available? It seems as if it’s only initialized after all the constructors are run?