src/graphics/webgl-layer.js
function(shader) {
        var gl = this.context;
        var fragmentShader = this._compileShader(
            shader.fragmentCode,
            gl.FRAGMENT_SHADER
        );
        var vertexShader = this._compileShader(
            shader.vertexCode,
            gl.VERTEX_SHADER
        );

        var shaderProgram = gl.createProgram();
        gl.attachShader(shaderProgram, vertexShader);
        gl.attachShader(shaderProgram, fragmentShader);
        gl.linkProgram(shaderProgram);

        if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
            throw "Could not initialise shaders";
        }

        shaderProgram.viewport = gl.getUniformLocation(
            shaderProgram,
            "uViewport"
        );
        return shaderProgram;
    }
function(shader) {
        var gl = this.context;
        var fragmentShader = this._compileShader(
            shader.fragmentCode,
            gl.FRAGMENT_SHADER
        );
        var vertexShader = this._compileShader(
            shader.vertexCode,
            gl.VERTEX_SHADER
        );

        var shaderProgram = gl.createProgram();
        gl.attachShader(shaderProgram, vertexShader);
        gl.attachShader(shaderProgram, fragmentShader);
        gl.linkProgram(shaderProgram);

        if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
            throw "Could not initialise shaders";
        }

        shaderProgram.viewport = gl.getUniformLocation(
            shaderProgram,
            "uViewport"
        );
        return shaderProgram;
    }
function ( shader ) { var gl = this . context ; var fragmentShader = this . _compileShader ( shader . fragmentCode , gl . FRAGMENT_SHADER ) ; var vertexShader = this . _compileShader ( shader . vertexCode , gl . VERTEX_SHADER ) ; var shaderProgram = gl . createProgram ( ) ; gl . attachShader ( shaderProgram , vertexShader ) ; gl . attachShader ( shaderProgram , fragmentShader ) ; gl . linkProgram ( shaderProgram ) ; if ( ! gl . getProgramParameter ( shaderProgram , gl . LINK_STATUS ) ) { throw "Could not initialise shaders" ; } shaderProgram . viewport = gl . getUniformLocation ( shaderProgram , "uViewport" ) ; return shaderProgram ; }
Create and return a complete, linked shader program, given the source for the fragment and vertex shaders. Will compile the two shaders and then link them together
Create and return a complete linked shader program given the source for the fragment and vertex shaders . Will compile the two shaders and then link them together