forked from play-co/webgl-2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-multi.html
41 lines (30 loc) · 1.07 KB
/
example-multi.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
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html>
<head>
<title>WebGL-2D Example</title>
<script src="webgl-2d.js" type="text/javascript"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", init, false);
var cvs1, cvs2,
ctx1, ctx2;
function init() {
cvs1 = document.getElementById("canvas1");
cvs2 = document.getElementById("canvas2");
WebGL2D.enable(cvs1); // adds new context "webgl-2d" to cvs
WebGL2D.enable(cvs2); // adds new context "webgl-2d" to cvs
// Easily switch between regular canvas 2d context and webgl-2d
//ctx = cvs.getContext("2d");
ctx1 = cvs1.getContext("webgl-2d");
ctx2 = cvs2.getContext("webgl-2d");
ctx1.fillStyle = "rgba(255, 128, 64, 1.0)";
ctx1.fillRect(0, 0, cvs1.width, cvs1.height);
ctx2.fillStyle = "rgba(0, 128, 255, 1.0)";
ctx2.fillRect(0, 0, cvs2.width, cvs2.height);
}
</script>
</head>
<body>
<canvas id="canvas1"></canvas>
<canvas id="canvas2"></canvas>
</body>
</html>