Search code examples
arraysglslwebgl

Cannot declare an array in webgl 1.0


I'm trying to port a shader from glsl 300 es to glsl 100, so it works on more devices. I have an array, it works completly fine on glsl 300 es, but on glsl 100 it just does not work. To test if it's an issue with the rest of my shader, or an issue with the array I added a simple array to the most minimal shader.

#version 100
attribute vec2 Pos;

void main()
{
    float[2] test;
    gl_Position = vec4(Pos,0,0);
}

When this shader is compiled webgl gives me this error:

ERROR: 0:6: 'first-class array' : not supported


Solution

  • The correct syntax is

    float[2] test;

    float test[2];
    

    See also Data Type (GLSL) - Array