Skip to content

Commit

Permalink
Update Emscripten build of TinyEXR loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Nov 5, 2022
1 parent 22be731 commit 4e25424
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
5 changes: 4 additions & 1 deletion experimental/js/compile_to_js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ EMCC=em++
# TODO: export more functions
# DEMANGLE_SUPPORT=1
#${EMCC} -std=c++11 --bind -O2 -I../../ binding.cc --memory-init-file 0 -s TOTAL_MEMORY=67108864 -s DEMANGLE_SUPPORT=1 -s EXPORTED_FUNCTIONS="['_ParseEXRHeaderFromMemory', '_LoadEXRFromMemory']" -o tinyexr.js
${EMCC} --bind -Os -I../../ binding.cc --memory-init-file 0 -s TOTAL_MEMORY=67108864 -o tinyexr.js
#${EMCC} --bind -Os -I../../ -I../../deps/miniz binding.cc ../../deps/miniz/miniz.c --memory-init-file 0 -s TOTAL_MEMORY=67108864 -o tinyexr.js

${EMCC} --bind -Os -I../../ -I../../deps/miniz binding.cc ../../deps/miniz/miniz.c -s ALLOW_MEMORY_GROWTH=1 -o tinyexr.js

28 changes: 12 additions & 16 deletions experimental/js/test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
var fs = require('fs');
var tinyexr = require('./tinyexr.js')
var Module = require('./tinyexr.js')

var data = new Uint8Array(fs.readFileSync("../../asakusa.exr"))
console.log(data.length)

var instance = new tinyexr.EXRLoader(data);
Module.onRuntimeInitialized = async function(){

console.log(instance.ok())
console.log(instance.width())
console.log(instance.height())
var data = new Uint8Array(fs.readFileSync("../../asakusa.exr"))

var image = instance.getBytes()
console.log(image[0])
console.log(image[1])
console.log(image[2])
console.log(image[3])
console.log(image[4])
console.log(image[5])
console.log(image[6])
console.log(image[7])
console.log('Module loaded: ', Module);

var instance = new Module.EXRLoader(data);
console.log(instance.ok())
console.log(instance.width())
console.log(instance.height())

var image = instance.getBytes()
}
20 changes: 1 addition & 19 deletions experimental/js/tinyexr.js

Large diffs are not rendered by default.

0 comments on commit 4e25424

Please sign in to comment.