-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
39 lines (38 loc) · 1.01 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Testing WebAssembly</title>
<script src="wasm_exec.js"></script>
<script type="text/javascript">
function fetchAndInstantiate(url, importObject) {
return fetch(url)
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, importObject))
.then(results => results.instance);
}
var go = new Go();
var mod = fetchAndInstantiate("/main.wasm", go.importObject);
window.onload = function() {
mod.then(function(instance) {
go.run(instance);
// const buffer = new ArrayBuffer(18);
const a = new Uint8Array(20);
a[1] = 99;
const t = new Test(a);
console.log(t.buf[0]);
t.change();
console.log(t.buf[0]);
});
};
</script>
<style>
#canvas {
width: 500px;
height: 300px;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
</html>