# FR: Make JUCE\_CHECK\_OPENGL\_ERROR and clearGLError() public

**URL:** <https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127>\
**Category:** General JUCE discussion\
**Created:** [April 29, 2019, 6:02pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127 "2019-04-29T18:02:40Z")\
**Posts on this page:** 12\
**Page:** 1

<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:** [April 29, 2019, 6:02pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/1 "2019-04-29T18:02:40Z")

</div>

To keep with the conventions, make the latter a macro: `JUCE_CLEAR_GL_ERROR`.

---

<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:** [April 29, 2019, 7:14pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/2 "2019-04-29T19:14:04Z")

</div>

I just realised `OpenGLHelpers::resetErrorState()` exists…

Might be worthwhile DRYing the framework to use that - it helps get a better sense of the overall implementation.

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 5:54pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/3 "2023-01-19T17:54:47Z")

</div>

As a follow on. How do I access JUCE\_CHECK\_OPENGL\_ERROR officially in my own code?  
I’m getting uniform issues that showed somewhere else entire different due to not enough error checking.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [January 19, 2023, 7:26pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/4 "2023-01-19T19:26:22Z")

</div>

If you call `setOpenGLVersionRequired (openGL4_3)` on Windows, and assuming you have a GPU with OpenGL 4.3+ drivers, JUCE will install a debugging callback that will automatically fire when an error is detected. I’d recommend this over using the error checking macro in new code.

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 7:40pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/5 "2023-01-19T19:40:01Z")

</div>

Oh ok, thanks man. What about on Mac?

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [January 19, 2023, 7:41pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/6 "2023-01-19T19:41:09Z")

</div>

Mac only supports up to GL 4.1, so it doesn’t support the debugging callback.

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 7:53pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/7 "2023-01-19T19:53:23Z")

</div>

Cheers, so **JUCE\_CHECK\_OPENGL\_ERROR** exists on Mac OS? I haven’t tried it yet.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [January 19, 2023, 8:06pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/8 "2023-01-19T20:06:06Z")

</div>

It’s private on macOS. It’s pretty easy to get something equivalent working, though, by using glGetError directly.

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 8:16pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/9 "2023-01-19T20:16:29Z")

</div>

I see people quoting **JUCE\_CHECK\_OPENGL\_ERROR** in their code. I just wondered how they do that, I don’t know why it’s hidden, it’s a useful tool.

I have OpenGL 4.6 installed on Windows.  
But these are the only options allowed, it seems…

```auto
enum OpenGLVersion
    {
        defaultGLVersion = 0,
        openGL3_2
    };

```

Oh well, I guess I’ll just use glGetError instead. It would have been handy to have the error code strings automatically.

---

<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:** [January 19, 2023, 8:34pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/10 "2023-01-19T20:34:46Z")

</div>

You would need JUCE from last August (2022, or 7.0.2 or 7.0.3 - somewhere around there): [JUCE/juce\_OpenGLContext.h at develop · juce-framework/JUCE · GitHub](https://github.com/juce-framework/JUCE/blob/develop/modules/juce_opengl/opengl/juce_OpenGLContext.h#L136-L143)

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 8:45pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/11 "2023-01-19T20:45:20Z")

</div>

I’m using 7.02. I don’t want to upgrade, or work with a ‘develop’ version, not at this stage of my plug-in.  
Thanks though. Never mind.

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [January 19, 2023, 8:54pm UTC](https://forum.juce.com/t/fr-make-juce-check-opengl-error-and-clearglerror-public/33127/12 "2023-01-19T20:54:17Z")

</div>

```auto
OpenGLHelpers::getErrors()

```

Would be a handy addition to resetErrorState() though,
