How to check for OpenGL support?

What is the best way to check for OpenGL support when my JUCE app/plugin opens? If a computer does not support OpenGL, I want my app to show a warning pop-up and render without OpenGL.

Is this approach reported by @reuk still the best method for checking OpenGL support?

It’s not terribly straightforward. Feel free to have a look at a class I wrote that handles applying GL 3 or removing the context if GL isn’t found (or too old):

Note that you have to attach (or “configure” in this case) on the main thread, and depending on the system you might only be able to attach a bit later than construction time of your editor.

Loosely speaking, you can do this with the configurator (you’ll probably want to use a SafePointer):

  MessageManager::callAsync ([&]()
      configurator.configureWithOpenGLIfAvailable (*this);

      if (auto* context =  configurator.context.get())
          context->executeOnGLThread ([&] (OpenGLContext& c)
          }, false);
1 Like