src/program.js
/**
   * Initialize the shader
   *
   * Parses out shader parameters, compiles the shader, and binds it to
   * the context.
   *
   * @return {void}
   */
Initialize the shader
Parses out shader parameters, compiles the shader, and binds it to
the context.

@return {void}
Initialize the shader Parses out shader parameters compiles the shader and binds it to the context . @return { void }
init() {
    var gl = this._gl, vertex, fragment;
    vertex = gl.createShader(gl.VERTEX_SHADER);
    gl.shaderSource(vertex, this.vertexSource);
    gl.compileShader(vertex);
    if(!gl.getShaderParameter(vertex, gl.COMPILE_STATUS))
    {
      console.warn(gl.getShaderInfoLog(vertex)); 
      console.error('could not compile vertex shader: ' + this.vertexSource); 
      throw 'Vertex shader compile error!';
    }
    fragment = gl.createShader(gl.FRAGMENT_SHADER);
    gl.shaderSource(fragment, this.fragmentSource);
    gl.compileShader(fragment);
    if(!gl.getShaderParameter(fragment, gl.COMPILE_STATUS))
    {
      console.warn(gl.getShaderInfoLog(fragment)); 
      console.error('could not compile fragment shader: ' + this.fragmentSource); 
      throw 'Fragment shader compile error!';
    }
    this.program = gl.createProgram();
    gl.attachShader(this.program, vertex);
    gl.attachShader(this.program, fragment);
    gl.linkProgram(this.program);
    if(!gl.getProgramParameter(this.program, gl.LINK_STATUS))
    {
      throw 'Could not link program';
    }
    gl.useProgram(this.program);
    this._setupLocations();
  }
init ( ) { var gl = this . _gl , vertex , fragment ; vertex = gl . createShader ( gl . VERTEX_SHADER ) ; gl . shaderSource ( vertex , this . vertexSource ) ; gl . compileShader ( vertex ) ; if ( ! gl . getShaderParameter ( vertex , gl . COMPILE_STATUS ) ) { console . warn ( gl . getShaderInfoLog ( vertex ) ) ; console . error ( 'could not compile vertex shader: ' + this . vertexSource ) ; throw 'Vertex shader compile error!' ; } fragment = gl . createShader ( gl . FRAGMENT_SHADER ) ; gl . shaderSource ( fragment , this . fragmentSource ) ; gl . compileShader ( fragment ) ; if ( ! gl . getShaderParameter ( fragment , gl . COMPILE_STATUS ) ) { console . warn ( gl . getShaderInfoLog ( fragment ) ) ; console . error ( 'could not compile fragment shader: ' + this . fragmentSource ) ; throw 'Fragment shader compile error!' ; } this . program = gl . createProgram ( ) ; gl . attachShader ( this . program , vertex ) ; gl . attachShader ( this . program , fragment ) ; gl . linkProgram ( this . program ) ; if ( ! gl . getProgramParameter ( this . program , gl . LINK_STATUS ) ) { throw 'Could not link program' ; } gl . useProgram ( this . program ) ; this . _setupLocations ( ) ; }
Initialize the shader
 Parses out shader parameters, compiles the shader, and binds it to
 the context.
Initialize the shader Parses out shader parameters compiles the shader and binds it to the context .
// eslint-disable-line no-console // eslint-disable-line no-console // eslint-disable-line no-console // eslint-disable-line no-console // TODO: verbose like above