-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebGL.html
31 lines (25 loc) · 834 Bytes
/
WebGL.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebGl and Canvas Introduction</title>
</head>
<body>
<canvas id="myCanvas" width="200" height="100"></canvas>
<script>
// Get the canvas
const canvas = document.getElementById("myCanvas");
// Initialize the GL context
const gl = canvas.getContext("webgl");
// Only continue if WebGL is available
if (!gl) {
alert("Your browser does not support WebGL.");
}
// Set color buffer to red (1,0,0) and opaque (1)
gl.clearColor(1, 0, 0, 1);
//Set the color with the color buffer
gl.clear(gl.COLOR_BUFFER_BIT);
</script>
</body>
</html>