mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Update readme info regarding WebAssembly and web target (#1726)
This commit is contained in:
parent
9d6b9797c0
commit
be2e17d605
23
README.md
23
README.md
|
@ -71,13 +71,24 @@ Winit provides the following features, which can be enabled in your `Cargo.toml`
|
||||||
|
|
||||||
#### WebAssembly
|
#### WebAssembly
|
||||||
|
|
||||||
Building a binary will yield a `.js` file. In order to use it in an HTML file, you need to:
|
Winit supports compiling to the `wasm32-unknown-unknown` target with either a
|
||||||
|
`stdweb` or a `web-sys` backend for use on web browsers. However, please note
|
||||||
|
that **the `stdweb` backend is being deprecated and may be removed in a future
|
||||||
|
release of Winit**. The `web-sys` backend is also more feature complete.
|
||||||
|
|
||||||
- Put a `<canvas id="my_id"></canvas>` element somewhere. A canvas corresponds to a winit "window".
|
On the web platform, a Winit window is backed by a `<canvas>` element. You can
|
||||||
- Write a Javascript code that creates a global variable named `Module`. Set `Module.canvas` to
|
either [provide Winit with a `<canvas>` element][web with_canvas], or [let Winit
|
||||||
the element of the `<canvas>` element (in the example you would retrieve it via `document.getElementById("my_id")`).
|
create a `<canvas>` element which you can then retrieve][web canvas getter] and
|
||||||
More information [here](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
|
insert it into the DOM yourself.
|
||||||
- Make sure that you insert the `.js` file generated by Rust after the `Module` variable is created.
|
|
||||||
|
For example code using Winit with WebAssembly, check out the [web example]. For
|
||||||
|
information on using Rust on WebAssembly, check out the [Rust and WebAssembly
|
||||||
|
book].
|
||||||
|
|
||||||
|
[web with_canvas]: https://docs.rs/winit/latest/wasm32-unknown-unknown/winit/platform/web/trait.WindowBuilderExtWebSys.html#tymethod.with_canvas
|
||||||
|
[web canvas getter]: https://docs.rs/winit/latest/wasm32-unknown-unknown/winit/platform/web/trait.WindowExtWebSys.html#tymethod.canvas
|
||||||
|
[web example]: ./examples/web.rs
|
||||||
|
[Rust and WebAssembly book]: https://rustwasm.github.io/book/
|
||||||
|
|
||||||
#### Android
|
#### Android
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue