title: Emscripten OpenGL (3) gives versions errors
body: <p>OS X - Chrome.</p>
  
  <p>Im new to OpenGL / emscripten and trying to setup a simple script that uses WebGL 2, OpenGL 3+ and gets build through emscripten into webassembly. </p>
  
  <p>Compiling of WebGL 1 / OpenGL 2 worked without a problem. And setting the canvas to WebGL 2 / OpenGL 3 also seems to work. When I check the current version that is running,  it informs me about OpenGL 3.0 and WebGL2 (but maybe its not using it..?). </p>
  
  <p>But, emcc still screams errors about the shader im giving being only compatible from version 3.0+ and thus implying im running openGL 1/2 ?</p>
  
  <p><em>Setting a new context through emscripten</em></p>
  
  <pre><code>EmscriptenWebGLContextAttributes ctxAttrs;
  emscripten_webgl_init_context_attributes(&amp;ctxAttrs);
  ctxAttrs.alpha = GL_TRUE;
  ctxAttrs.depth = GL_TRUE;
  ctxAttrs.stencil = GL_TRUE;
  ctxAttrs.antialias = 4;
  ctxAttrs.premultipliedAlpha = false;
  ctxAttrs.preserveDrawingBuffer = false;
  ctxAttrs.minorVersion = 0;
  ctxAttrs.majorVersion = 2; // WebGL2
  
  this-&gt;context = emscripten_webgl_create_context(0, &amp;ctxAttrs);
  assert(this-&gt;context &gt; 0); // Must have received a valid context.
  int res = emscripten_webgl_make_context_current(this-&gt;context);
  assert(res == EMSCRIPTEN_RESULT_SUCCESS);
  assert(emscripten_webgl_get_current_context() == this-&gt;context);
  </code></pre>
  
  <p><em>Shaders</em> : </p>
  
  <pre><code>const char *vertexShaderSource = "#version 300 core\n"
          "layout (location = 0) in vec3 aPos;\n"
          "void main()\n"
          "{\n"
          "   gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
          "}\0";
  
  const char *fragmentShaderSource = "#version 300 core\n"
          "out vec4 FragColor;\n"
          "void main()\n"
          "{\n"
          "   FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
          "}\n\0";
  </code></pre>
  
  <p>When I do a log of the current OpenGL version right after the creation of the context,</p>
  
  <pre><code>printf("OpenGL version supported by this platform : %s\n", glGetString(GL_VERSION));
  </code></pre>
  
  <p>I get this :</p>
  
  <blockquote>
    <p>OpenGL version supported by this platformOpenGL ES 3.0 (WebGL 2.0
    (OpenGL ES 3.0 Chromium))</p>
  </blockquote>
  
  <p>Chrome console says this</p>
  
  <pre><code>ERROR::SHADER::VERTEX::COMPILATION_FAILEDERROR: 0:1: 'core' : invalid version directive
  00:53:19.828 index.js:1 ERROR: 0:2: 'layout' : syntax error
  00:53:19.829 index.js:1
  00:53:19.830 index.js:1 ERROR::SHADER::FRAGMENT::COMPILATION_FAILEDERROR: 0:1: 'core' : invalid version directive
  00:53:19.831 index.js:1 ERROR: 0:2: 'out' : storage qualifier supported in GLSL ES 3.00 and above only
  00:53:19.832 index.js:1 ERROR: 0:2: '' : No precision specified for (float)
  00:53:19.833 index.js:1 ERROR: 0:5: '1.0f' : Floating-point suffix unsupported prior to GLSL ES 3.00
  00:53:19.834 index.js:1 ERROR: 0:5: '1.0f' : syntax error
  00:53:19.835 
  </code></pre>
  
  <p>I call emscripten like this, with FULL_ES3 and WEBGL2 enabled.</p>
  
  <pre><code>emcc src/main.cpp src/lib/Chart.cpp -s SAFE_HEAP=1 --bind  -s WASM=1 -O3 -o index.js -s LEGACY_GL_EMULATION=0  -s GL_UNSAFE_OPTS=0 --pre-js pre-module.js --post-js post-module.js -s GL_ASSERTIONS=1 -s INVOKE_RUN=0  -std=c++11 -s USE_WEBGL2=1 -s FULL_ES3=1 -s USE_GLFW=3 -s OFFSCREENCANVAS_SUPPORT=1
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/cosYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cosYs.png" alt="enter image description here"></a></p>
  
  <p>Thanks!</p>