JUCE & Windows & OpenGL 3.x Support


#1

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.

https://github.com/jrlanglois/JUCE/commit/6b7b2c33f087097cc1133e41e411a9dbd27cd36d

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.

 


#2

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.


#3

.


#4

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)


#5

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.


#6

Seems this post has been grossly overlooked.


#7

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


#8

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.


#9
void OpenGLExtensionFunctions::initialise()
{
   #if JUCE_WINDOWS || JUCE_LINUX
    #define JUCE_INIT_GL_FUNCTION(name, returnType, params, callparams) \
        name = (type_ ## name) OpenGLHelpers::getExtensionFunction (#name);
    JUCE_GL_BASE_FUNCTIONS (JUCE_INIT_GL_FUNCTION)
    #undef JUCE_INIT_GL_FUNCTION

    #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));

    JUCE_GL_EXTENSION_FUNCTIONS (JUCE_INIT_GL_FUNCTION)

    #if JUCE_OPENGL3
     JUCE_GL_VERTEXBUFFER_FUNCTIONS (JUCE_INIT_GL_FUNCTION)
    #endif
    #undef JUCE_INIT_GL_FUNCTION

   #endif
}

#10

Cheers, will take care of that..


#11

Cheers