-
Notifications
You must be signed in to change notification settings - Fork 10
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
Using wasm-bindgen for games #51
Comments
Okay, I think I get the state of things now (please correct me if I'm wrong!) - you can use |
I wouldn't characterize it this way. It has a
This is because there fundamentally is no
We have some ideas around this stuff, but unfortunately haven't gotten around to it yet: rustwasm/rfcs#10 |
That's true, but even the Having used both, I (and many others) have found that There's a lot that wasm-bindgen (and wasm-pack) need to learn from
That's not the reason we don't support bin crates. After all, The reason we don't support bin crates is because it bloats up the file size by a lot. After that is fixed in |
Maybe it would benefit the rust-gamedev WG if we could try to clarify the following points:
This clarification would be super useful to improve the documentation for gfx-hal's quad example and glow. |
To add a small experience report to this discussion. I'm not using wasm-bindgen for games, but am writing an application using it. It's been a few months since I started it, but I too remember some confusion about how to use the tooling for applications instead of libraries. At some point I had been messing with it for a while and decided to look into I'm not sure if that's still the case with the recent convergence, but at some point I got things to "just work" using wasm-bindgen but without using wasm-pack, and haven't really looked into the pipeline since, so long as things keep working. My current set-up now runs several tools in succession to build a release binary, including I have very little experience with the build ecosystem that exists around JavaScript, and didn't want to spend too much time on that for this project, so the goal was to not have to deal with anything related to that, which in the end seems possible, but it took some digging and experimenting to make it all work. |
I'm using wasm-pack for my web-based multiplayer game https://SneakySnake.io. A couple thoughts:
If I ever have time to open source any of my work on SneakySnake, maybe I'll make one of these for others to benefit from. But all my code is currently highly specialized to this project's particular needs, i.e. decoupled network/update tick and render tick rates.
|
I'm strongly in favor of the handmade hero approach, and I think it's one place where we can easily get a win out of this WG. |
rustwasm/wasm-bindgen#1630 has been closed, making binary crates Just Work in |
I've noticed while working on the
wasm-bindgen
backend for Tetra that there's a few rough edges around the tooling from a game dev perspective. Sincewasm-bindgen
seems to be the 'blessed' tool for WASM in Rust, having a tracking issue for some of these papercuts seems like a good idea. Maybe we can work with the WASM WG on some of these?(Also, since some of said WG have been tagged in - aside from these issues, porting to WASM has gone ridiculously smoothly, kudos for all your hard work!)
Support for binary crates
wasm-bindgen
doesn't currently supportmain
- you have to use thewasm_bindgen(start)
attribute on a public function instead, and that function can't bemain
(rustwasm/wasm-bindgen#1630). This means that it's not possible to have a binary crate 'just work' without some glue code.My current approach is to have a macro that automatically creates awasm_main
wrapper, but I'd be interested to hear how other libraries (e.g. Winit) are planning on approaching this.The above info is now out of date -
wasm-bindgen
supports binary crates now.Most likely as a consequence of the above,
wasm-pack
is also currently quite heavily focused on usage for libraries that are intended for publishing to NPM. There's an RFC for a--no-pack
mode (rustwasm/wasm-pack#691) that looks like it might work better for our use cases, but it seems to have stalled a little bit.No
cargo web
counterpartThe
stdweb
ecosystem hascargo web
, which is a really nice tool that offers a HTTP server, auto-reloading, static file packaging, etc. Unfortunately, it doesn't currently support wasm-bindgen projects (koute/cargo-web#92).There are templates for projects that call into
wasm-pack
from Webpack and offer similar features in that way, but I feel like this is overkill for most gamedev needs - 99% of the time, you just want a HTML page with a canvas on it that you can hook into.EDIT:
Actually, it looks likeNope, it wascargo web
might have added wasm-bindgen support of some kind since I last tried it! Need to give that a proper try.stdweb
that added support, my mistake!The text was updated successfully, but these errors were encountered: