blob: 95ab5a6a7c6a05955807ef708d9af4613f2d1a03 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<html>
<head>
<title>Emscripten-Generated Code</title>
<body>
<center>
<canvas id='canvas' width='256' height='256'></canvas>
</center>
<hr>
<div id='output'></div>
<hr>
<script type='text/javascript'>
// connect to canvas
var Module = {
print: (function() {
var element = document.getElementById('output');
return function(text) {
element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>';
};
})(),
canvas: document.getElementById('canvas')
};
// Define the 2D and WebGL contexts lazily, because a canvas can only
// have one context type.
Module.__defineGetter__("ctx2D", function() {
try {
var ctx = Module.canvas.getContext('2d');
if (!ctx) throw 'Could not create canvas :(';
delete Module["ctxGL"];
Module.__defineGetter__("ctxGL", function() {
throw 'Could not create a WebGL context for a 2D canvas :(';
});
delete Module["ctx2D"];
return Module["ctx2D"] = ctx;
} catch (e) {
Module.print('(canvas not available)');
return null;
}
});
Module.__defineGetter__("ctxGL", function() {
try {
var ctx = Module.canvas.getContext('experimental-webgl');
if (!ctx) throw 'Could not create canvas :(';
delete Module["ctx2D"];
Module.__defineGetter__("ctx2D", function() {
throw 'Could not create a 2D context for a WebGL canvas :(';
});
delete Module["ctxGL"];
return Module["ctxGL"] = ctx;
} catch (e) {
Module.print('(canvas not available)');
return null;
}
});
// The compiled code
{{{ SCRIPT_CODE }}}
</script>
</body>
</html>
|