# How to check for OpenGL support?

**URL:** <https://forum.juce.com/t/how-to-check-for-opengl-support/52081>\
**Category:** General JUCE discussion\
**Created:** [July 5, 2022, 4:28pm UTC](https://forum.juce.com/t/how-to-check-for-opengl-support/52081 "2022-07-05T16:28:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![timart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timart/32/1119_2.png) [@timart](https://forum.juce.com/u/timart)\
**Post date:** [July 5, 2022, 4:28pm UTC](https://forum.juce.com/t/how-to-check-for-opengl-support/52081/1 "2022-07-05T16:28:48Z")

</div>

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](https://forum.juce.com/t/how-to-test-for-opengl/36895/2)?

> [@How to test for OpenGL?](https://forum.juce.com/t/how-to-test-for-opengl/36895/2):
>
> An approach I’ve used is to: Create a test component with 1x1 px size, positioned in the corner of the window. This component should hold an OpenGLContext. Give the OpenGLContext a custom renderer. This renderer will simply check some of the context’s extension function pointers in the first paint callback, and then use MessageManager::callAsync to report back whether or not the context supports all the features that are required. When the callback is fired, the owner of the test component can…

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [July 6, 2022, 1:17pm UTC](https://forum.juce.com/t/how-to-check-for-opengl-support/52081/2 "2022-07-06T13:17:50Z")

</div>

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):

- [squarepine\_core/HighPerformanceRendererConfigurator.h at main · SquarePine/squarepine\_core · GitHub](https://github.com/SquarePine/squarepine_core/blob/main/modules/squarepine_graphics/components/HighPerformanceRendererConfigurator.h)
- [squarepine\_core/HighPerformanceRendererConfigurator.cpp at main · SquarePine/squarepine\_core · GitHub](https://github.com/SquarePine/squarepine_core/blob/main/modules/squarepine_graphics/components/HighPerformanceRendererConfigurator.cpp)

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):

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

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

```
