diff --git a/README.md b/README.md index fc2ed919..86a31b9b 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,24 @@ Winit provides the following features, which can be enabled in your `Cargo.toml` #### 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 `` element somewhere. A canvas corresponds to a winit "window". -- Write a Javascript code that creates a global variable named `Module`. Set `Module.canvas` to - the element of the `` element (in the example you would retrieve it via `document.getElementById("my_id")`). - More information [here](https://kripken.github.io/emscripten-site/docs/api_reference/module.html). -- Make sure that you insert the `.js` file generated by Rust after the `Module` variable is created. +On the web platform, a Winit window is backed by a `` element. You can +either [provide Winit with a `` element][web with_canvas], or [let Winit +create a `` element which you can then retrieve][web canvas getter] and +insert it into the DOM yourself. + +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