Closed floooh closed 7 months ago
@kassane fyi π(PR into master to keep track of what I'm adding... e.g. the black screen samples are working now...
@kassane fyi π(PR into master to keep track of what I'm adding... e.g. the black screen samples are working now...
Amazing!
Now with a shell.html which fills the whole client area :)
KC85 emulator running in browser (wasn't supported before, but quite trivial now):
On: https://github.com/floooh/sokol-zig/pull/51/commits/a2e4b461d6a78ab4f542e2aef391bde424175173
Does this do a recursive dependency lookup on libsokol? For example, if you had any examples that used cimgui, would it link it directly to sokol so that emcc would pull both of them?
The idea is that one could add additional C library compile steps (like for instance cimgui) to the top-level module (same as happens with the sokol C library), and the Emscripten linker step would pick those up automatically.
I don't actually know whether it's fully recursive, but for the cimgui case, I wouldn't add that dependency to the sokol module, but to the 'Zig main module' (obviously that loop which scans for dependencies isn't recursive, but I don't know if the 'dependency iterator' does that for me... from looking around in the stdlib where this dependency iterator is used, all places I saw don't have any sort of 'explicit recursion', but still seem to walk over all dependencies).
I haven't actually tested it though, only made sure that it discovers the sokol library dependency.
Whoop whoop!
@floooh Been tracing through these changes as I look to move my own sokol-based engine to work with wasm. If the intention is that sokol is being comsumed as a wasm module directly (DLL-like), is it sufficient to use wasm32-freestanding or does sokol always require the intermediate emscripten step (and hence the build.zig template here) for the EM_JS() stuff you mentioned in another thread?
@kkukshtel yeah, you'll need to compile the sokol C library as wasm32-emscripten
, and link the final executable (or WASM 'DLL' I guess) with the Emscripten linker.
Decoupling the sokol headers from Emscripten is currently not feasable unfortunately (since even without the use of EM_JS, it would require writing our own browser API shims and/or parts of the Emscripten helper functions).
-sUSE_OFFSET_CONVERTER
requirement for Emscripten linker option when using Zig allocators...not this time, but should be considered for an update