shader not getting compiled in Chrome OS, openglES 3.0

167 Views Asked by At

i have an app built using webgl support of emscripten, the app runs perfectly find in windows, linux and macOS, but for some reason its giving error in line 3 chrome OS.


1: function _glEnableVertexAttribArray(index) {
2:  var cb = GL.currentContext.clientBuffers[index];
3:  cb.enabled = true;
4:  GLctx.enableVertexAttribArray(index);
5: }


on debugging i found that the value of index is -1 at the time of error.

so i am guessing there is some issue with my shader program.

below is one sample vertex shader i am using.

R"glsl(
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec3 vertex_normal;
layout (location = 3) in vec2 uv;

out vec3 oFragPosition;
out vec3 oNormal;
out vec2 oUV;
out vec3 overtexNormal;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

out float flogz;

void main()
{
   oFragPosition = vec3(model * vec4(position, 1.0f));
   oNormal = (model * vec4(normal, 1.0)).xyz;
   vec4 t = vec4(0.0f, 0.0f, 0.0f, 1.0f);
   t = model * t;
   oNormal.x = oNormal.x - t.x;
   oNormal.y = oNormal.y - t.y;
   oNormal.z = oNormal.z - t.z;
   oNormal = normalize(oNormal);
   oUV = uv;
   overtexNormal = vertex_normal;

   gl_Position = projection * view * model * vec4(position, 1.0);
}

)glsl"

in my system the chrome://gpu gave the following gpu configuration: GPU config chrome os

as you can see, it has openglES 3.2. and pixel and fragment shader version 3.2

in code i am asking to make a opengles 3.0 context. also my shader version is 300 es. is the error is due the version mismatch?

or what could be the issue here?

EDIT: i checked my linux system, its also has the same configuration openGL ES 3.20 and glsl version is 3.20.

1

There are 1 best solutions below

0
vishal kumar On

apparently https://stackoverflow.com/a/45154357/13407557 helped,

my overtexNormal attribute was not used anywhere in fragment shader and hence it was stripped from my shader program after compilation, so upon querying for the location of the attribute it returned -1, this was causing glEnableVertexAttribArray to fail.