Some OpenGL functions not available in Windows?

My app works great in Mac but isn’t working in Windows. At first, it wouldn’t compile until I added JUCE_OPENGL3=1 as a preprocessor macro but now it just crashes and what seems to be happening is that in OpenGlExtensionsFunctions, there are a couple functions not being made available which should be loaded dynamically (I guess?). These appear to be the JUCE_GL_VERTEXBUFFER_FUNCTIONS.

Here’s a shot from my code:

And I trace it back to where these functions are loaded.

It looks like since I added JUCE_OPENGL3=1, these functions should be available but they are not. I would super grateful for any help with this.

Are you using the OpenGLExtensionFunctions member provided by the active OpenGLContext or are you using your own declaration of the struct? In the latter case, you must call the initialise() function for the struct which performs the dynamic loading, as seen here:

1 Like

I was doing it as my own declaration. If I start with initialize(), I now get an exception thrown in the function initializeOnThread().

I tried it both ways, same error in the same place.

I would go with using the extension function struct included with the OpenGLContext, since it does the initialisation for you, in essence:

void renderOpenGL()
{
    OpenGLContext &gl = *OpenGLContext::getCurrentContext();
    gl.extensions.glGenBuffers(...);
}

Okay let me try that

Also bear in mind that the large majority of the OpenGL functions and macros are not wrangled within OpenGLExtensionFunctions. In fairness, there are a shit load of em but it’s totally feasible to do…

I made a feature request for that: FR: Wrangle a comprehensive set of OpenGL functions & macros

2 Likes

I replaced it my “gl” with that snippet everywhere but it still throws an exception on the initializeOnThread function.

Does that mean anything to you? In xCode, I can usually see more detail about what’s going on with the debugger than this so I apologize if I just am not seeing certain details.

Did you find a way to resolve this issue? I am currently running into the same thing with the windows build of my new plugin which uses OpenGL 3 and glBindVertexArray.

I’m not 100% sure, since I never tested it myself. On Windows all OpenGL functions are provided via the wgl context functions. I think the one used in JUCE loads one of the oldest GL versions (2.1?) possible. This call is used:

Now isn’t it necessary to explicitly request a higher GL version (e.g. 3.1) to actually load the newer GL functions?

It seems for this purpose the WGL_ARB_create_context extension is provided. Similar to the pixel format extension, you have to query/load the extension first. Read more about it here:

https://www.khronos.org/opengl/wiki/Creating_an_OpenGL_Context_(WGL)#Create_Context_with_Attributes

And here an example:
https://www.khronos.org/opengl/wiki/Tutorial:OpenGL_3.1_The_First_Triangle(C%2B%2B/Win)#Rendering_Context_Creation

Especially this part:

...
int attribs[] =
{
	WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
	WGL_CONTEXT_MINOR_VERSION_ARB, 1,
	WGL_CONTEXT_FLAGS_ARB, 0,
	0
};

if(wglewIsSupported("WGL_ARB_create_context") == 1)
{
	m_hrc = wglCreateContextAttribsARB(pDC->m_hDC,0, attribs);
	
...