baobao
3/14/2018 - 2:25 PM

invalid_webgl.js

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
var vs = gl.createShader(gl.VERTEX_SHADER);
var fs = gl.createShader(gl.FRAGMENT_SHADER);

gl.shaderSource(vs, document.getElementById('vs'));
gl.shaderSource(fs, document.getElementById('fs'));
gl.compileShader(vs);
gl.compileShader(fs);

var prog = gl.createProgram();
gl.attachShader(prog, vs);
gl.attachShader(prog, fs);

gl.linkProgram(prog);

if (gl.getProgramParameter(prog, gl.LINK_STATUS))
{
    gl.useProgram(prog);
}else{
    console.log(gl.getProgramInfoLog(prog));
    return;
}