How do I enable and use glsl #version 300 es shaders with emscripten C++ and latest firefox nightly?

and of course other browsers I am using the emscripten C++ compiler to build a GL app.

Whenever I put the first line "#version 300 es" in either a vertex or fragment shader and try to run the app I get

"ERROR: unsupported shader version"

in the shader compile log.

My compile/link flags to the js binding generator phase of the emscripten build are:

 -s "FETCH=1" -s "ALLOW_MEMORY_GROWTH=1" -s "USE_WEBGL2=1" 

Which supposedly enable webGL2 apis ( and by inference glsl version 300 es )

This happens even when I make the shaders almost completely empty.

I am using the firefox Nightly browser so it is the most up to date.

All the docs just sort of say "do this and it works" - frustrated :|


It's not documented as well as it should be in samples etc, but you have to EXPLICITLY request a WebGL2 context when calling emscripten_webgl_create_context() by setting minorVerson and majorVerson on the setup argument. Otherwise it defaults to WebGL1.0 at runtime no matter what the linker flags are set for.