linkProgram method

void linkProgram(
  1. Program program, [
  2. bool checkForErrors = true
])

Implementation

void linkProgram(Program program, [bool checkForErrors = true]) {
  startCheck('linkProgram');
  gl.glLinkProgram(program.id);
  if (checkForErrors) {
    final linked = calloc<Int32>();
    gl.glGetProgramiv(program.id, GL_LINK_STATUS, linked);
    if (linked.value == 0) {
      final infoLen = calloc<Int32>();

      gl.glGetProgramiv(program.id, GL_INFO_LOG_LENGTH, infoLen);

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

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

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