compileShader method

void compileShader(
  1. WebGLShader shader, [
  2. bool checkForErrors = true
])

Implementation

void compileShader(WebGLShader shader, [bool checkForErrors = true]) {
  startCheck('compileShader');
  gl.glCompileShader(shader.id);

  if (checkForErrors) {
    final compiled = calloc<Int32>();
    gl.glGetShaderiv(shader.id, GL_COMPILE_STATUS, compiled);
    if (compiled.value == 0) {
      final infoLen = calloc<Int32>();

      gl.glGetShaderiv(shader.id, GL_INFO_LOG_LENGTH, infoLen);

      String message = '';
      if (infoLen.value > 1) {
        final infoLog = calloc<Int8>(infoLen.value);

        gl.glGetShaderInfoLog(shader.id, infoLen.value, nullptr, infoLog);
        message = "\nError compiling shader:\n${infoLog.cast<Utf8>().toDartString()}";

        calloc.free(infoLog);
      }
      calloc.free(infoLen);
      throw OpenGLException(message, 0);
    }
    calloc.free(compiled);
  }
}