src/programs.js
function createProgramInfo(
    gl, shaderSources, opt_attribs, opt_locations, opt_errorCallback) {
  const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
  let good = true;
  shaderSources = shaderSources.map(function(source) {
    // Lets assume if there is no \n it's an id
    if (source.indexOf("\n") < 0) {
      const script = getElementById(source);
      if (!script) {
        progOptions.errorCallback("no element with id: " + source);
        good = false;
      } else {
        source = script.text;
      }
    }
    return source;
  });
  if (!good) {
    return null;
  }
  const program = createProgramFromSources(gl, shaderSources, progOptions);
  if (!program) {
    return null;
  }
  return createProgramInfoFromProgram(gl, program);
}
function createProgramInfo(
    gl, shaderSources, opt_attribs, opt_locations, opt_errorCallback) {
  const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
  let good = true;
  shaderSources = shaderSources.map(function(source) {
    // Lets assume if there is no \n it's an id
    if (source.indexOf("\n") < 0) {
      const script = getElementById(source);
      if (!script) {
        progOptions.errorCallback("no element with id: " + source);
        good = false;
      } else {
        source = script.text;
      }
    }
    return source;
  });
  if (!good) {
    return null;
  }
  const program = createProgramFromSources(gl, shaderSources, progOptions);
  if (!program) {
    return null;
  }
  return createProgramInfoFromProgram(gl, program);
}
function createProgramInfo ( gl , shaderSources , opt_attribs , opt_locations , opt_errorCallback ) { const progOptions = getProgramOptions ( opt_attribs , opt_locations , opt_errorCallback ) ; let good = true ; shaderSources = shaderSources . map ( function ( source ) { // Lets assume if there is no \n it's an id if ( source . indexOf ( "\n" ) < 0 ) { const script = getElementById ( source ) ; if ( ! script ) { progOptions . errorCallback ( "no element with id: " + source ) ; good = false ; } else { source = script . text ; } } return source ; } ) ; if ( ! good ) { return null ; } const program = createProgramFromSources ( gl , shaderSources , progOptions ) ; if ( ! program ) { return null ; } return createProgramInfoFromProgram ( gl , program ) ; }
Creates a ProgramInfo from 2 sources.

A ProgramInfo contains

programInfo = {
program: WebGLProgram,
uniformSetters: object of setters as returned from createUniformSetters,
attribSetters: object of setters as returned from createAttribSetters,
}

NOTE: There are 4 signatures for this function

twgl.createProgramInfo(gl, [vs, fs], options);
twgl.createProgramInfo(gl, [vs, fs], opt_errFunc);
twgl.createProgramInfo(gl, [vs, fs], opt_attribs, opt_errFunc);
twgl.createProgramInfo(gl, [vs, fs], opt_attribs, opt_locations, opt_errFunc);

@param {WebGLRenderingContext} gl The WebGLRenderingContext
to use.
@param {string[]} shaderSources Array of sources for the
shaders or ids. The first is assumed to be the vertex shader,
the second the fragment shader.
@param {module:twgl.ProgramOptions|string[]|module:twgl.ErrorCallback} [opt_attribs] Options for the program or an array of attribs names or an error callback. Locations will be assigned by index if not passed in
@param {number[]} [opt_locations|module:twgl.ErrorCallback] The locations for the. A parallel array to opt_attribs letting you assign locations or an error callback.
@param {module:twgl.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.
@return {module:twgl.ProgramInfo?} The created ProgramInfo or null if it failed to link or compile
@memberOf module:twgl/programs
Creates a ProgramInfo from 2 sources .