Created
June 9, 2014 21:54
-
-
Save verma/6b4e9e8f7d4ce3f124aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <emscripten/bind.h> | |
using namespace emscripten; | |
class LASZip { | |
public: | |
LASZip() {} | |
void open(const char *buf, size_t len) { | |
printf("Got buffer: %p, size: %i", buf, len); | |
} | |
}; | |
float lerp(float a, float b, float t) { | |
return (1 - t) * a + t * b; | |
} | |
EMSCRIPTEN_BINDINGS(my_module) { | |
function("lerp", &lerp); | |
class_<LASZip>("LASZip") | |
.constructor() | |
.function("open", &LASZip::open, allow_raw_pointers()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<script src="laz-perf.js"></script> | |
<script> | |
document.write('lerp result: ' + Module.lerp(1, 2, 0.5)); | |
var x = new Module.LASZip(); | |
var a = new Int8Array(1024); | |
var buf = Module._malloc(a.length*a.BYTES_PER_ELEMENT); | |
Module.HEAPU8.set(a, buf); | |
x.open(buf, a.length); | |
Module._free(buf); | |
x.delete(); | |
console.log("Done with deletion"); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment