forked from juj/wasm_webgpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.html
60 lines (51 loc) · 1.61 KB
/
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
<!doctype html><html lang="en-us"><head><meta charset="utf-8"></head>
<body style='margin:0'>
<canvas style='display:block; margin:auto;'></canvas>
<script>
#if !MODULARIZE
var Module = {
#if USE_PTHREADS
worker: '{{{ PTHREAD_WORKER_FILE }}}'
#endif
};
#endif
var canvas = document.querySelector('canvas');
function resizeCanvas() {
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';
canvas.width = Math.round(window.innerWidth * window.devicePixelRatio);
canvas.height = Math.round(window.innerHeight * window.devicePixelRatio);
}
if (!location.search.includes('windowed')) {
resizeCanvas();
onresize = resizeCanvas;
}
if (location.search.includes('thumbnail')) {
// Save the canvas to file when clicking on it.
// Not working: https://bugs.chromium.org/p/chromium/issues/detail?id=1175665
canvas.onclick = function() {
var img = canvas.toDataURL("image/png");
var a = document.createElement('a');
a.href = img;
a.download = 'canvas.png';
a.click();
}
}
#if WASM == 2
var supportsWasm = window.WebAssembly && location.search.indexOf('_rwasm=0') < 0;
#endif
// Depending on the build flags that one uses, different files need to be downloaded
// to load the compiled page. The right set of files will be expanded to be downloaded
// via the directive below.
{{{ DOWNLOAD_JS_AND_WASM_FILES }}}
#if SINGLE_FILE
// If we are doing a SINGLE_FILE=1 build, inlined JS runtime code follows here:
{{{ JS_CONTENTS_IN_SINGLE_FILE_BUILD }}}
#if MODULARIZE
// Launch the MODULARIZEd build.
{{{ EXPORT_NAME }}}({});
#endif
#endif
</script>
</body>
</html>