-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemscripten-shell.html
80 lines (74 loc) · 1.6 KB
/
emscripten-shell.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><!--TITLE--></title>
<style>
body {
font-size: 18px;
font-family: sans-serif;
padding: 0;
margin: 0;
}
input {
display: block;
margin-top: 1rem;
margin-left: auto;
margin-right: auto;
}
canvas {
display: block;
border: 1px solid;
padding-left: 0;
padding-right: 0;
margin-top: 1rem;
margin-bottom: 1rem;
margin-left: auto;
margin-right: auto;
}
textarea {
display: block;
font-family: monospace;
width: 80ch;
padding-left: 0;
padding-right: 0;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div>
<input type="button" value="FULLSCREEN" onclick="Module.requestFullscreen(false, false)">
</div>
<div>
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</div>
<script type="text/javascript">
const MakePrintFunction = (method) => {
return function(text) {
if (arguments.length > 1) {
text = Array.prototype.slice.call(arguments).join(" ");
}
method(text);
};
};
var Module = {
preRun: [],
postRun: [],
print: MakePrintFunction(console.log),
printErr: MakePrintFunction(console.error),
canvas: (() => {
const canvas = document.querySelector("#canvas");
canvas.addEventListener("webglcontextlost", function(e) {
alert("WebGL context lost. You will need to reload the page.");
e.preventDefault();
}, false);
return canvas;
})()
};
</script>
{{{ SCRIPT }}}
</body>
</html>