Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
package-lock.json

# Typescript v1 declaration files
typings/
Expand Down
16 changes: 11 additions & 5 deletions app/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import CounterWA from '../build/counter.wasm';

export class Counter {
counterModule;
counterInstance;

constructor() {
this.insertCounterGUI();
Expand All @@ -13,7 +14,7 @@ export class Counter {
document.querySelector('#app').insertAdjacentHTML('afterbegin', '<button id="count">Click me</button><div>Count: <span id="counter"></span></div>');
const count = document.getElementById('count');
count.addEventListener('click', () => {
document.getElementById('counter').innerHTML = this.counterModule.exports.__ZN7Counter5countEv(); // @TODO why does WASM do this for class methods??
document.getElementById('counter').innerHTML = this.counterInstance.exports.__ZN7Counter5countEv(); // @TODO why does WASM do this for class methods??
});
}

Expand All @@ -24,12 +25,17 @@ export class Counter {
'memoryBase': 0,
'tableBase': 0,
'memory': new WebAssembly.Memory({initial: 256}),
'table': new WebAssembly.Table({initial: 0, element: 'anyfunc'}),
'table': new WebAssembly.Table({initial: 4, element: 'anyfunc'}),
'abort': function(msg) { console.error(msg); }
}
};
this.counterModule = new CounterWA(importObject);
console.log('Counter Module', this.counterModule);
}
new CounterWA(importObject).then(result => {
this.counterModule = result.module;
this.counterInstance = result.instance;

console.log('Counter Module', this.counterModule);
console.log('Counter Instance', this.counterInstance);
});
}
}

7 changes: 5 additions & 2 deletions app/opengl-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ export class OpenGLDemo {

loadDemoWasm() {
this.module = Module({
wasmBinaryFile: '/wasm/module.wasm',
canvas: document.getElementById('canvas')
wasmBinaryFile: 'module.wasm',
canvas: document.getElementById('canvas'),
locateFile: function(s) {
return 'wasm/' + s;
}
});
console.log(this.module);
}
Expand Down