Search code examples
glslwebgl

What do the numbers in WebGL shader compile error message mean?


For example,

ERROR: 0:137: 'blend2' : no matching overloaded function found
ERROR: 0:137: '=' : dimension mismatch
ERROR: 0:137: '=' : cannot convert from 'const mediump float' to 'highp 3-component vector of float'

What is 0 in 0:137?
What is 137 in 0:137?
Why is all the error messages begin with 0:? Why isn't it 1: or 2:?

Note I'm not asking why I got those error. Answers with reference to some official spec or documentation are preferred if there is one. I'm using Chrome 63.0.3239.132.


Solution

  • What is 0 in 0:137?

    It's the index of the shader string that produced the error. In regular OpenGL, glShaderSource allows you to provide multiple strings. They are compiled as if they were concatenated together. But this means that error messages have to identify the particular string in the shader that is responsible for the error. The first number is a zero-based index into the array of strings provided to glShaderSource.

    Of course, WebGL's equivalent gl.shaderSource function doesn't allow you to provide multiple shader strings. So if the WebGL implementation ultimately calls into an OpenGL or OpenGL ES implementation directly, then the errors that OpenGL produces will have the string index in them, even though they technically don't need it.

    What is 137 in 0:137?

    It's the line number at which the error occurred.