JS-WebGL实例

window.onload = function(){
    var drawing = document.getElementById("drawing");
    //make sure <canvas> is completely supported
    if (drawing.getContext){
        var gl;
        try {
            gl = drawing.getContext("experimental-webgl");
        } catch (ex) {
            //noop
        }
        if (gl){
            gl.clearColor(255,0,0,1);
            gl.clear(gl.COLOR_BUFFER_BIT);
        } else {
            alert("WebGL context could not be created.");
        }
    }
};