diff --git a/wasm/Makefile b/wasm/Makefile index 01a7949..eacf515 100644 --- a/wasm/Makefile +++ b/wasm/Makefile @@ -25,9 +25,10 @@ CFLAGS+=-DWASM -nostdlib --target=wasm32 \ WOFLAGS:=--asyncify --pass-arg=asyncify-imports@bynsyncify.* --pass-arg=asyncify-ignore-indirect opt.js : template.js main.wasm - bash -c 'export BLOB=$$(cat main.wasm | base64 | sed -e "$$ ! {/./s/$$/ \\\\/}" ); envsubst < template.js > opt.js' + bash -c 'export BLOB=$$(cat main.wasm | base64 | sed -e "$$ ! {/./s/$$/ \\\\/}" ); envsubst < template.js > mid.js' #Comment the below line out if you don't want to uglify the javascript. - $(TERSER) $(TERSERFLAGS) opt.js -o opt.js + $(TERSER) $(TERSERFLAGS) mid.js -o opt.js + rm mid.js index.html : template.ht opt.js bash -c 'export JAVASCRIPT_DATA=$$(cat opt.js); envsubst < template.ht > $@' diff --git a/wasm/README.md b/wasm/README.md index 334309d..bb3fe1e 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -1,5 +1,17 @@ # rawdrawwasm +rawdrawwasm + +## Prerequisites + +``` +sudo apt-get install npm binaryen clang +sudo npm install terser -g +``` + + +## Old Notes + My stab at rawdraw on wasm. This is based on: https://github.com/zNoctum/wasm-tool and has inspiration from: diff --git a/wasm/template.js b/wasm/template.js index 9852b66..971ab02 100644 --- a/wasm/template.js +++ b/wasm/template.js @@ -2,14 +2,14 @@ //Global memory for application. let memory = new WebAssembly.Memory({initial:200}); -//slet HEAP8 = new Int8Array(memory.buffer); +let HEAP8 = new Int8Array(memory.buffer); let HEAPU8 = new Uint8Array(memory.buffer); let HEAP16 = new Int16Array(memory.buffer); -//let HEAPU16 = new Uint16Array(memory.buffer); -//let HEAP32 = new Uint32Array(memory.buffer); +let HEAPU16 = new Uint16Array(memory.buffer); +let HEAP32 = new Uint32Array(memory.buffer); let HEAPU32 = new Uint32Array(memory.buffer); let HEAPF32 = new Float32Array(memory.buffer); -//let HEAPF64 = new Float64Array(memory.buffer); +let HEAPF64 = new Float64Array(memory.buffer); let toUtf8Decoder = new TextDecoder( "utf-8" ); function toUTF8(ptr) { @@ -26,6 +26,11 @@ let fullscreen = false; //Configure WebGL Stuff (allow to be part of global context) let canvas = document.getElementById('canvas'); let wgl = canvas.getContext('webgl'); +if( !wgl ) +{ + //Janky - on Firefox 83, with NVIDIA GPU, you need to ask twice. + wgl = canvas.getContext('webgl'); +} let wglShader = null; //Standard flat color shader let wglABV = null; //Array buffer for vertices let wglABC = null; //Array buffer for colors.