How is it that the GLFW OpenGL ES example works on Windows? (I thought Windows didn't natively support OpenGL ES.)

I’m working on a game engine to support Emscripten, Windows desktop, and (possibly in the future) Android. I got some basics working using SDL, but I decided I want to use shaders instead and go straight to OpenGL. Since WebGL is modeled after OpenGL ES, I thought I’d program to the “ES” subset of the API even on desktop, and then I could be sure my shaders and API use would work for all platforms.

Unfortunately upon further research (and explaining why I couldn’t find one example that cross-compiles between Emscripten and desktop for using OpenGL with an SDL context), I discovered Windows never added native OpenGL ES support, and also I’d have to slightly change my shader code. I discovered the existence of the ANGLE project, but it seemed more heavyweight than I need.

So I was quite surprised when I compiled GLFW, and not only the native OpenGL example but also the OpenGL ES example both work on my Windows laptop. How is it that this is working, given that I read elsewhere that OpenGL ES doesn’t work on Windows?

Edit: by the way I’m using Msys2/MinGW64, gcc, and CMake. I downloaded the ANGLE source code, but I didn’t install it. I found online a reference to a mingw-w64-angleproject, but I can’t find that package (either installed or available) on my actual MSys2 install. So I’m confused whether GLFW is finding and using a copy of ANGLE I didn’t know I had, or if it doesn’t need ANGLE to support OpenGL ES on Windows, or if GLFW (or GLAD) is able to translate both the API and the GLSL to something else?

OpenGL context is created with WGL Windows API, and WGL has extension to create GLES capable context:

Whether your GPU supports it or not depends on your GPU driver, not all of them do. You can see list of drivers/GPU’s that support or not support here: OpenGL Hardware Database by Sascha Willems (search for extension name). SDL knows how to use this extension.

if this GL extension is not supported, you can use ANGLE - as I believe that will work on any D3D11 capable GPU/driver (or older version on D3D9). If you want to use ANGLE with mingw-w64-angleproject package in msys2, then you need to install it with pacman: pacman -S mingw-w64-angleproject Then run .exe from msys2 terminal (so mingw dll files are in PATH). Otherwise you can build ANGLE project yourself, or use build that somebody else did. For example, I have ANGLE builds available on my github: (download .zip file from Releases).

1 Like