From e8244ae5e3fe8d5c8bb474ec1f3472b55307c6db Mon Sep 17 00:00:00 2001 From: Christophe Massolin Date: Fri, 24 Apr 2020 15:42:15 +0200 Subject: [PATCH] [rs] Update README.md for running examples on the web (#275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [readme] add details for running on wasm32 target * [readme] update * [readme] [web] Running instruction on webgpu.io --- wgpu/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wgpu/README.md b/wgpu/README.md index a904dc6915..281f894cc8 100644 --- a/wgpu/README.md +++ b/wgpu/README.md @@ -35,6 +35,8 @@ cargo run --example hello-compute 1 2 3 4 #### Run Examples on the Web (`wasm32-unknown-unknown`) +Running on the web is still work-in-progress. You may need to enable experimental flags on your browser. Check browser implementation status on [webgpu.io](https://webgpu.io). + To run examples on the `wasm32-unknown-unknown` target, first build the example as usual, then run `wasm-bindgen`: ```bash @@ -46,6 +48,27 @@ RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build --target wasm32-unknown-unknow wasm-bindgen --out-dir target/generated --web target/wasm32-unknown-unknown/debug/examples/hello-triangle.wasm ``` +Create an `index.html` file into `target/generated` directory and add the following code: + +```html + + + + + + hello-triangle + + + + + +``` + +Now run a web server locally inside the `target/generated` directory to see the `hello-triangle` in the browser. + ## Friends Shout out to the following projects that work best with wgpu-rs: