Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-bindgen #54

Open
PSteinhaus opened this issue Sep 14, 2021 · 8 comments
Open

wasm-bindgen #54

PSteinhaus opened this issue Sep 14, 2021 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@PSteinhaus
Copy link
Member

Apparently some dependencies used require wasm-bindgen to get them to work on WASM.

Since I've never worked with WebAssembly or Javascript before it's safe to say that I'm the wrong person for this job, though.

Therefore I hereby humbly ask for help.

@PSteinhaus PSteinhaus added bug Something isn't working help wanted Extra attention is needed labels Sep 14, 2021
@not-fl3
Copy link
Collaborator

not-fl3 commented Sep 14, 2021

The recommended way to interop with JS: https://github.com/not-fl3/miniquad/wiki/JavaScript-interop

I am not a huge fan of using any third-party binaries for wasm and prefer just do cargo build --target wasm32-unknown-unknown. In case of gwg the only dependency requiring wasm-bindgen is getrandom (https://github.com/ggez/good-web-game/blob/master/Cargo.toml#L37). I would recommend switching to oorandom

However, if you really want to bring wasm-bindgen binary into the gwg build process here there is a good example for it: https://github.com/smokku/gwg-bindgen

@PSteinhaus
Copy link
Member Author

Hmm, I removed getrandom, but the problem remains:
Unbenannt

@PSteinhaus
Copy link
Member Author

However, if you really want to bring wasm-bindgen binary into the gwg build process here there is a good example for it: https://github.com/smokku/gwg-bindgen

If I try to follow the example (using current good-web-game instead of the example repo and using the latest gl.js) I run into the following:

Unbenannt

@PSteinhaus
Copy link
Member Author

Ah, it seems to be gilrs that's dependent on wasm-bindgen: https://gitlab.com/gilrs-project/gilrs#wasm

@PSteinhaus
Copy link
Member Author

PSteinhaus commented Sep 15, 2021

Ok, using conditional compilation I managed to keep gamepad support, while only disabling it for web and mobile.
It's probably not very elegant, but it works, good-web-game finally runs on the web once again!

But since gilrs is really the only dependency needing wasm-bindgen shouldn't it be possible to write my own bindings for it, keeping users from having to struggle with wasm-bindgen? As I said I'm a wasm and js noob, so I've no idea really, but in theory this should be possible, right? Or perhaps the more sensible way would be to just get wasm-bindgen to work once and then store the generated bindings somewhere, so that users don't have to generate them themselves when after building their projects?

@not-fl3
Copy link
Collaborator

not-fl3 commented Sep 15, 2021

yes, @Bombfuse made a gamepad library that works without wasm-bindgen: github.com/bombfuse/gamepad/

@Bombfuse
Copy link

Gamepad currently doesnt support WASM but I was in the middle of completing it previously. It is planned eventually to support WASM controllers without bindgen though

@PSteinhaus
Copy link
Member Author

Yeah, I stumbled over that library and was close to asking whether you plan on continuing it, because it'd be really useful for gwg.
Good to hear that you do : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants