getShaderErrors method

dynamic getShaderErrors(
  1. dynamic gl,
  2. WebGLShader shader,
  3. dynamic type
)

Implementation

getShaderErrors(dynamic gl, WebGLShader shader, type) {
  var status = gl.getShaderParameter(shader.shader, gl.COMPILE_STATUS);
  var errors = gl.getShaderInfoLog(shader.shader).trim();

  if (status && errors == '') return '';

  var regExp = RegExp(r"ERROR: 0:(\d+)");
  var match = regExp.firstMatch(errors);

  int errorLine = int.parse(match!.group(1)!);

  // --enable-privileged-webgl-extension
  // console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );

  var source = gl.getShaderSource(shader.shader);

  return 'three.WebGLShader: gl.getShaderInfoLog() $type\n$errors\n${handleSource(source, errorLine)}';
}