JUCE & Windows & OpenGL 3.x Support


Since JUCE naively relied on the Windows API to expose the available OpenGL functions, it couldn't compile with OpenGL 3.x enabled (ie: JUCE_OPENGL3).

Below is a commit on my (remade) fork, with some comments, enabling this functionality on Windows.


You won't see much of a performance gain using the JUCE Demo versus the 2.x support - but the goal here is just to kick the process off.



Sadly, Windows' API isn't extended any further for OpenGL - mostly to leave it up to the driver manufacturers. So 3rd party libraries have been built to essentially achieve the same thing JUCE does here: load the functions manually.

If it's not obvious; the added functions will be null if the driver doesn't support them, so be careful! Modern GPUs tend to support the latest OpenGL (4.5 at the time of this post - hopefully we can get there with JUCE one day), and they usually have full backwards compatibility.

An alternative route is to manually define these functions (instead of adding them to the context's list), load them (probably with some initialisation function somewhere), and pass the parameters down (if available). That way they would be part of the global namespace and you would be able to use them normally.




It's been a bit tricky to follow what people are actually asking for on this thread.. Do you just want more functions added to OpenGLExtensionFunctions? (I don't think it'd be a good idea to add them to the global namespace as someone suggested above)


What I'm asking for is the ability to compile JUCE on Windows with OpenGL 3.x ; which I'm suprised hasn't been done already.

Essentially, yes, it's a matter of loading more functions, but also enabling JUCE_OPENGL3.

My reason for suggesting to load them in the global namespace (only if they're missing) is to give the user-programmers the sense that they're using OpenGL out of the box, and not need to search for/create/initialise the OpenGLExtensionFunctions. This would be more inline with the regular OpenGL ways.


Seems this post has been grossly overlooked.


Thanks - looks like it was just missing 3 functions - have added them now and it seems to work for me.


Now that you've added those functions, JUCE applications (e.g.: the JUCE demo) can be compiled with JUCE_OPENGL3=1 on Windows. Cool!

Problem now is that context.extensions.initialise(); needs to be called before context.extensions.glGenVertexArrays(); is called in juce_OpengGlContext.cpp - otherwise, the app will just get nullptr derefs and never run.

If you revisit my commit (https://github.com/jrlanglois/JUCE/commit/6b7b2c33f087097cc1133e41e411a9dbd27cd36d), you'll notice that I've done that there.

void OpenGLExtensionFunctions::initialise()
    #define JUCE_INIT_GL_FUNCTION(name, returnType, params, callparams) \
        name = (type_ ## name) OpenGLHelpers::getExtensionFunction (#name);

    #define JUCE_INIT_GL_FUNCTION(name, returnType, params, callparams) \
        name = (type_ ## name) OpenGLHelpers::getExtensionFunction (#name); \
        if (name == nullptr) \
            name = (type_ ## name) OpenGLHelpers::getExtensionFunction (JUCE_STRINGIFY (name ## EXT));


    #if JUCE_OPENGL3



Cheers, will take care of that..