-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathWebGLExample01.htm
37 lines (30 loc) · 1.07 KB
/
WebGLExample01.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>WebGL Example</title>
</head>
<body>
<p>This only works in browsers that WebGL. The background is cleared to black.</p>
<canvas id="drawing" width="200" height="200">Your browser doesn't support the canvas tag.</canvas>
<script>
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(0,0,0,1);
gl.clear(gl.COLOR_BUFFER_BIT);
} else {
alert("WebGL context could not be created.");
}
}
};
</script>
</body>
</html>