Not-Nik / raylib-zig

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
MIT License
473 stars 101 forks source link

Building for WebAssembly #24

Closed tupini07 closed 11 months ago

tupini07 commented 2 years ago

As the title says, is there any possibility building a project using raylib-zig to wasm ? Any examples of how to accomplish this?

Not-Nik commented 2 years ago

Should be possible, at least with some hacks. Raylib currently uses emscripten for web apps iirc. I'll check on this when I get back from vacation later this week.

Akselmo commented 1 year ago

I'd also like to know. I would like to try Zig in a gamejam but I think WASM is essential for that.

Any news on this front?

Not-Nik commented 1 year ago

Currently not possible, since raylib's build.zig only offers support for Windows, Linux, macOS and *BSD. I have created an issue on its repository: https://github.com/raysan5/raylib/issues/2884

Not-Nik commented 1 year ago

raylib now has support for building for emscripten since https://github.com/raysan5/raylib/pull/2901 was merged, but Zig can't generate the required extra files that create the required JS functions (for OpenGL etc.) so at least the link step for the final "executable" has to be done with emscripten.

On the Zig side https://github.com/ziglang/zig/issues/10836 tracks this issue.

bluesillybeard commented 11 months ago

I was able to get it to work: https://github.com/bluesillybeard/ZigAndRaylibSetup

It's a hassle to set up and it's also pretty janky, but it does work.

Edit: Forgot to mention, I didn't use this wrapper, but instead used Raylib by itself

Not-Nik commented 11 months ago

If you can neatly integrate it into the current build script, don't hesitate to open a PR

Not-Nik commented 11 months ago

Fixed in #52