design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js
function createProgram(
      gl, shaders, opt_attribs, opt_locations, opt_errorCallback) {
    var errFn = opt_errorCallback || error;
    var program = gl.createProgram();
    shaders.forEach(function(shader) {
      gl.attachShader(program, shader);
    });
    if (opt_attribs) {
      opt_attribs.forEach(function(attrib, ndx) {
        gl.bindAttribLocation(
            program,
            opt_locations ? opt_locations[ndx] : ndx,
            attrib);
      });
    }
    gl.linkProgram(program);

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

        gl.deleteProgram(program);
        return null;
    }
    return program;
  }
function createProgram(
      gl, shaders, opt_attribs, opt_locations, opt_errorCallback) {
    var errFn = opt_errorCallback || error;
    var program = gl.createProgram();
    shaders.forEach(function(shader) {
      gl.attachShader(program, shader);
    });
    if (opt_attribs) {
      opt_attribs.forEach(function(attrib, ndx) {
        gl.bindAttribLocation(
            program,
            opt_locations ? opt_locations[ndx] : ndx,
            attrib);
      });
    }
    gl.linkProgram(program);

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

        gl.deleteProgram(program);
        return null;
    }
    return program;
  }
function createProgram ( gl , shaders , opt_attribs , opt_locations , opt_errorCallback ) { var errFn = opt_errorCallback || error ; var program = gl . createProgram ( ) ; shaders . forEach ( function ( shader ) { gl . attachShader ( program , shader ) ; } ) ; if ( opt_attribs ) { opt_attribs . forEach ( function ( attrib , ndx ) { gl . bindAttribLocation ( program , opt_locations ? opt_locations [ ndx ] : ndx , attrib ) ; } ) ; } gl . linkProgram ( program ) ; // Check the link status var linked = gl . getProgramParameter ( program , gl . LINK_STATUS ) ; if ( ! linked ) { // something went wrong with the link var lastError = gl . getProgramInfoLog ( program ) ; errFn ( "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 {WebGLShader[]} shaders The shaders to attach
@param {string[]} [opt_attribs] An array of attribs names. Locations will be assigned by index if not passed in
@param {number[]} [opt_locations] The locations for the. A parallel array to opt_attribs letting you assign locations.
@param {module:webgl-utils.ErrorCallback} opt_errorCallback callback for errors. By default it just prints an error to the console
on error. If you want something else pass an callback. It's passed an error message.
@memberOf module:webgl-utils
Creates a program attaches shaders binds attrib locations links the program and calls useProgram .