really minimal emscripten shell
adapted from 91504884e8/src/shell_minimal.html
This commit is contained in:
parent
8a3913c74c
commit
47bca440d3
3 changed files with 52 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -5,4 +5,5 @@
|
||||||
!main.cpp
|
!main.cpp
|
||||||
!screenshot.png
|
!screenshot.png
|
||||||
!build.sh
|
!build.sh
|
||||||
!build-web.sh
|
!build-web.sh
|
||||||
|
!emscripten_shell.html
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
/usr/lib/emscripten/em++ -std=c++26 --use-port=sdl2 -O2 --emrun -sASSERTIONS -o index.html main.cpp
|
/usr/lib/emscripten/em++ -std=c++26 --use-port=sdl2 -O2 --emrun --shell-file emscripten_shell.html -sASSERTIONS -o index.html main.cpp
|
49
emscripten_shell.html
Normal file
49
emscripten_shell.html
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Randomwalk</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas id="canvas" tabindex=-1></canvas>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
|
||||||
|
var Module = {
|
||||||
|
canvas: (() => {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
|
||||||
|
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||||
|
// application robust, you may want to override this behavior before shipping!
|
||||||
|
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||||
|
canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
setStatus: (text) => { console.log(text); },
|
||||||
|
totalDependencies: 0,
|
||||||
|
monitorRunDependencies: (left) => {
|
||||||
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
|
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies - left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Module.setStatus('Downloading...');
|
||||||
|
window.onerror = () => {
|
||||||
|
Module.setStatus('Exception thrown, see JavaScript console');
|
||||||
|
spinnerElement.style.display = 'none';
|
||||||
|
Module.setStatus = (text) => {
|
||||||
|
if (text) console.error('[post-exception status] ' + text);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Reference in a new issue