Specification

[1]

Compatibility

IE11+, Std

Syntax

1
2
<canvas id="canvas" height="150" width="300" style="border: 2px solid red"></canvas>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript">
    var canvas = document.getElementById("canvas");
 
    var gl = canvas.getContext("webgl") // for Std
        || canvas.getContext("experimental-webgl"); // for IE11+, Std
 
    if (gl) {
        gl.clearColor(0.0, 0.0, 0.0, 1.0);
        gl.enable(gl.DEPTH_TEST);
        gl.depthFunc(gl.LEQUAL);
        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    }
</script>

Example