# Some OpenGL functions not available in Windows?

**URL:** <https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770>\
**Category:** General JUCE discussion\
**Created:** [June 6, 2019, 4:59pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770 "2019-06-06T16:59:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ComposerShield](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/composershield/32/6655_2.png) [@ComposerShield](https://forum.juce.com/u/ComposerShield)\
**Post date:** [June 6, 2019, 4:59pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/1 "2019-06-06T16:59:53Z")

</div>

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:

 ![first](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/3/3151df413165675ccf50eac9123b99d90ab7894d.png)

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

 ![second](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/1/172b312db3cda13e52b028002ab15e8dee5b4c91.png)

 ![13%20AM](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/b/b101793c3e8a2f414e476856dd448c3d2355251c.png)

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.

---

<div class="post-metadata">

**Author:** ![alassandro](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/alassandro/32/4297_2.png) [@alassandro](https://forum.juce.com/u/alassandro)\
**Post date:** [June 6, 2019, 5:14pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/2 "2019-06-06T17:14:14Z")

</div>

> [@ComposerShield](#):
>
> 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?)

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()`](https://github.com/WeAreROLI/JUCE/blob/master/modules/juce_opengl/native/juce_OpenGLExtensions.h#L105) function for the struct which performs the dynamic loading, as seen here:

> <https://github.com/juce-framework/JUCE/blob/master/modules/juce_opengl/juce_opengl.cpp#L91>

---

<div class="post-metadata">

**Author:** ![ComposerShield](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/composershield/32/6655_2.png) [@ComposerShield](https://forum.juce.com/u/ComposerShield)\
**Post date:** [June 6, 2019, 5:23pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/3 "2019-06-06T17:23:00Z")

</div>

> [@TonyAtHarrison](#):
>
> OpenGLExtensionFunctions

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

---

<div class="post-metadata">

**Author:** ![ComposerShield](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/composershield/32/6655_2.png) [@ComposerShield](https://forum.juce.com/u/ComposerShield)\
**Post date:** [June 6, 2019, 5:24pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/4 "2019-06-06T17:24:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alassandro](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/alassandro/32/4297_2.png) [@alassandro](https://forum.juce.com/u/alassandro)\
**Post date:** [June 6, 2019, 5:24pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/5 "2019-06-06T17:24:55Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![ComposerShield](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/composershield/32/6655_2.png) [@ComposerShield](https://forum.juce.com/u/ComposerShield)\
**Post date:** [June 6, 2019, 5:26pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/6 "2019-06-06T17:26:23Z")

</div>

Okay let me try that

---

<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:** [June 6, 2019, 5:47pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/7 "2019-06-06T17:47:19Z")

</div>

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](https://forum.juce.com/t/fr-wrangle-a-comprehensive-set-of-opengl-functions-macros/33158)

---

<div class="post-metadata">

**Author:** ![ComposerShield](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/composershield/32/6655_2.png) [@ComposerShield](https://forum.juce.com/u/ComposerShield)\
**Post date:** [June 6, 2019, 5:47pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/8 "2019-06-06T17:47:27Z")

</div>

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

 ![07%20PM](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/1/106c0a068e4f08f0aedd03a8c14a71382acdb9d2.png)

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.

---

<div class="post-metadata">

**Author:** ![Bgraf](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bgraf/32/7204_2.png) [@Bgraf](https://forum.juce.com/u/Bgraf)\
**Post date:** [May 22, 2021, 2:46pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/9 "2021-05-22T14:46:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![parawave](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/parawave/32/5292_2.png) [@parawave](https://forum.juce.com/u/parawave)\
**Post date:** [May 22, 2021, 8:46pm UTC](https://forum.juce.com/t/some-opengl-functions-not-available-in-windows/33770/10 "2021-05-22T20:46:20Z")

</div>

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:

> **[wglCreateContext function (wingdi.h) - Win32 apps](https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-wglcreatecontext)**
>
> The wglCreateContext function creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by hdc. The rendering context has the same pixel format as the device context.

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](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](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);
	
...
```
