Skip to content

Commit

Permalink
Update build for Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Nov 24, 2020
1 parent 9efd2f4 commit 3bb96db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 3 additions & 2 deletions wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 > $@'
Expand Down
12 changes: 12 additions & 0 deletions wasm/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
13 changes: 9 additions & 4 deletions wasm/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.
Expand Down

0 comments on commit 3bb96db

Please sign in to comment.