Basically what I have in my shader is a uniform vec2 array which gets its value in JS app.
I need to know the length of this array in order to act accordingly.
I tried array.length(), which gives me this error:
ERROR: 0:48: '' : methods supported in GLSL ES 3.00 and above only
In the JS side you can use getActiveUniform to receive WebGLActiveInfo as a result for each uniform. Each has a size field. According to the referenced page:
The size attribute of the return value corresponds to the length of the array for uniforms declared as arrays. Otherwise, it is 1 (this includes interface blocks instanced with arrays).
Something like this:
const max_uniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < max_uniforms; i++)
{
const uniform_info = gl.getActiveUniform(program, i);
console.log("uniform " + uniform_info.name + " length is " + uniform_info.size);
}