shader-core.js
function createShader(
    gl
  , vertSource
  , fragSource
  , uniforms
  , attributes) {
  
  //Compile vertex shader
  var vertShader = gl.createShader(gl.VERTEX_SHADER)
  gl.shaderSource(vertShader, vertSource)
  gl.compileShader(vertShader)
  if(!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) {
    var errLog = gl.getShaderInfoLog(vertShader)
    console.error('gl-shader: Error compling vertex shader:', errLog)
    throw new Error('gl-shader: Error compiling vertex shader:' + errLog)
  }
  
  //Compile fragment shader
  var fragShader = gl.createShader(gl.FRAGMENT_SHADER)
  gl.shaderSource(fragShader, fragSource)
  gl.compileShader(fragShader)
  if(!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) {
    var errLog = gl.getShaderInfoLog(fragShader)
    console.error('gl-shader: Error compiling fragment shader:', errLog)
    throw new Error('gl-shader: Error compiling fragment shader:' + errLog)
  }
  
  //Link program
  var program = gl.createProgram()
  gl.attachShader(program, fragShader)
  gl.attachShader(program, vertShader)

  //Optional default attriubte locations
  attributes.forEach(function(a) {
    if (typeof a.location === 'number') 
      gl.bindAttribLocation(program, a.location, a.name)
  })

  gl.linkProgram(program)
  if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
    var errLog = gl.getProgramInfoLog(program)
    console.error('gl-shader: Error linking shader program:', errLog)
    throw new Error('gl-shader: Error linking shader program:' + errLog)
  }
  
  //Return final linked shader object
  var shader = new Shader(
    gl,
    program,
    vertShader,
    fragShader
  )
  shader.updateExports(uniforms, attributes)

  return shader
}
function createShader(
    gl
  , vertSource
  , fragSource
  , uniforms
  , attributes) {
  
  //Compile vertex shader
  var vertShader = gl.createShader(gl.VERTEX_SHADER)
  gl.shaderSource(vertShader, vertSource)
  gl.compileShader(vertShader)
  if(!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) {
    var errLog = gl.getShaderInfoLog(vertShader)
    console.error('gl-shader: Error compling vertex shader:', errLog)
    throw new Error('gl-shader: Error compiling vertex shader:' + errLog)
  }
  
  //Compile fragment shader
  var fragShader = gl.createShader(gl.FRAGMENT_SHADER)
  gl.shaderSource(fragShader, fragSource)
  gl.compileShader(fragShader)
  if(!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) {
    var errLog = gl.getShaderInfoLog(fragShader)
    console.error('gl-shader: Error compiling fragment shader:', errLog)
    throw new Error('gl-shader: Error compiling fragment shader:' + errLog)
  }
  
  //Link program
  var program = gl.createProgram()
  gl.attachShader(program, fragShader)
  gl.attachShader(program, vertShader)

  //Optional default attriubte locations
  attributes.forEach(function(a) {
    if (typeof a.location === 'number') 
      gl.bindAttribLocation(program, a.location, a.name)
  })

  gl.linkProgram(program)
  if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
    var errLog = gl.getProgramInfoLog(program)
    console.error('gl-shader: Error linking shader program:', errLog)
    throw new Error('gl-shader: Error linking shader program:' + errLog)
  }
  
  //Return final linked shader object
  var shader = new Shader(
    gl,
    program,
    vertShader,
    fragShader
  )
  shader.updateExports(uniforms, attributes)

  return shader
}
function createShader ( gl , vertSource , fragSource , uniforms , attributes ) { //Compile vertex shader var vertShader = gl . createShader ( gl . VERTEX_SHADER ) gl . shaderSource ( vertShader , vertSource ) gl . compileShader ( vertShader ) if ( ! gl . getShaderParameter ( vertShader , gl . COMPILE_STATUS ) ) { var errLog = gl . getShaderInfoLog ( vertShader ) console . error ( 'gl-shader: Error compling vertex shader:' , errLog ) throw new Error ( 'gl-shader: Error compiling vertex shader:' + errLog ) } //Compile fragment shader var fragShader = gl . createShader ( gl . FRAGMENT_SHADER ) gl . shaderSource ( fragShader , fragSource ) gl . compileShader ( fragShader ) if ( ! gl . getShaderParameter ( fragShader , gl . COMPILE_STATUS ) ) { var errLog = gl . getShaderInfoLog ( fragShader ) console . error ( 'gl-shader: Error compiling fragment shader:' , errLog ) throw new Error ( 'gl-shader: Error compiling fragment shader:' + errLog ) } //Link program var program = gl . createProgram ( ) gl . attachShader ( program , fragShader ) gl . attachShader ( program , vertShader ) //Optional default attriubte locations attributes . forEach ( function ( a ) { if ( typeof a . location === 'number' ) gl . bindAttribLocation ( program , a . location , a . name ) } ) gl . linkProgram ( program ) if ( ! gl . getProgramParameter ( program , gl . LINK_STATUS ) ) { var errLog = gl . getProgramInfoLog ( program ) console . error ( 'gl-shader: Error linking shader program:' , errLog ) throw new Error ( 'gl-shader: Error linking shader program:' + errLog ) } //Return final linked shader object var shader = new Shader ( gl , program , vertShader , fragShader ) shader . updateExports ( uniforms , attributes ) return shader }
Compiles and links a shader program with the given attribute and vertex list
Compiles and links a shader program with the given attribute and vertex list