Hacker News new | ask | show | jobs
by felipellrocha 3401 days ago
Does anyone have an example on how to get the SDL2 to compile using WebAssembly?
2 comments

There are several SDL2 Emscripten examples for compiling to ASM.js. You would follow the same process, except just direct Emscripten to generate WebAssembly using a "vanilla" LLVM's WebAssembly backend [1]. You will probably first need to compile LLVM yourself with WebAssembly experimental target enabled, as explained in the link.

[1] https://github.com/kripken/emscripten/wiki/New-WebAssembly-B...

There is already SDL2 support for emscripten, and emscripten can compile to WebAssembly with the WASM flag flipped on. So basically just use emcc with

-s WASM=1 -s USE_SDL=2

for WebAssembly + SDL2.

The test_sdl2* tests in emscripten's test suite have working samples in them,

https://github.com/kripken/emscripten/blob/master/tests/test...

A full SDL1 testcase is in the tutorial,

http://kripken.github.io/emscripten-site/docs/getting_starte...