47 lines
964 B
HTML
47 lines
964 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>go/render: hello wasm!</title>
|
|
<style>
|
|
#canvas {
|
|
position: fixed;
|
|
width: 100%;
|
|
height: 100%;
|
|
top: 0;
|
|
right: 0;
|
|
left: 0;
|
|
bottom: 0;
|
|
}
|
|
|
|
@font-face {
|
|
font-family: "DejaVuSans";
|
|
src: url("fonts/DejaVuSans.ttf") format("truetype");
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<script src="wasm_exec.js"></script>
|
|
<script>
|
|
if (!WebAssembly.instantiateStreaming) { // polyfill
|
|
WebAssembly.instantiateStreaming = async (resp, importObject) => {
|
|
const source = await (await resp).arrayBuffer();
|
|
return await WebAssembly.instantiate(source, importObject);
|
|
};
|
|
}
|
|
|
|
(function() {
|
|
const go = new Go();
|
|
WebAssembly.instantiateStreaming(fetch("hello.wasm"), go.importObject).then(result => {
|
|
console.clear();
|
|
go.run(result.instance);
|
|
WebAssembly.instantiate(result.module, go.importObject); // reset instance
|
|
})
|
|
})();
|
|
</script>
|
|
|
|
<canvas id="canvas"></canvas>
|
|
|
|
</body>
|
|
</html>
|