mach: wasm: initial implementation of Core, added js polyfill and

application html
This commit is contained in:
iddev5 2022-05-22 12:43:21 +05:30 committed by Stephen Gutekanst
parent ccb1063e3f
commit c8c6dab65b
3 changed files with 145 additions and 5 deletions

38
www/template.html Normal file
View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
canvas {
border: 1px solid;
}
</style>
</head>
<body>
<script type="module">
import { mach } from "./mach.js";
let imports = {
env: mach,
};
fetch("application.wasm")
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.instantiate(buffer, imports))
.then(results => results.instance)
.then(instance => {
mach.init(instance);
instance.exports.wasmInit();
let update = function() {
const r = instance.exports.wasmUpdate();
if (r) requestAnimationFrame(update)
else instance.exports.wasmDeinit();
};
requestAnimationFrame(update);
})
.catch(err => console.log(err));
</script>
</body>
</html>