getShaderErrors method

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

Implementation

String getShaderErrors(RenderingContext gl, WebGLShader shader, type) {
  final status = gl.getShaderParameter(shader.shader, WebGL.COMPILE_STATUS);
  final errors = (gl.getShaderInfoLog(shader.shader)??'').trim();

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

  final regExp = RegExp(r"ERROR: 0:(\d+)");
  final 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 ) );

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

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