loadProgram = function (gl, shaders, optAttribs, optLocations) {
  var program = gl.createProgram();
  for (var i = 0; i < shaders.length; ++i) {
    gl.attachShader(program, shaders[i]);
  }
  if (optAttribs) {
    for (var i = 0; i < optAttribs.length; ++i) {
      gl.bindAttribLocation(
          program,
          optLocations ? optLocations[i] : i,
          optAttribs[i]);
    }
  }
  gl.linkProgram(program);

  // Check the link status
  const linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  if (!linked) {
    // something went wrong with the link
    const lastError = gl.getProgramInfoLog(program);
    error('Error in program linking:' + lastError);

    gl.deleteProgram(program);
    return null;
  }
  return program;
}
Creates a program, attaches shaders, binds attrib locations, links the
program and calls useProgram.
@param {!Array.<!WebGLShader>} shaders The shaders to attach
@param {!Array.<string>} optAttribs The attribs names.
@param {!Array.<number>} optLocations The locations for the attribs.