FR: Make JUCE_CHECK_OPENGL_ERROR and clearGLError() public

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

1 Like

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.

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.

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.

Oh ok, thanks man. What about on Mac?

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

Cheers, so JUCE_CHECK_OPENGL_ERROR exists on Mac OS? I haven’t tried it yet.

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

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…

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.

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

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.

OpenGLHelpers::getErrors()

Would be a handy addition to resetErrorState() though,