Messing around with wgpu 🦀🔺
This repo uses Trunk to target the browser, checkout the list of commands: https://trunkrs.dev/commands/
The default target is defined in /.cargo/config.toml
as wasm32-unknown-unknown
so if you want to build for your platform you must use --target
One last thing! check the shaders with cargo wgsl
In most cases using Trunk would be better, building the project w/o Trunk, requires WASM to be loaded manually:
<script type="module">
import init from "./bin/wgpu_intro.js";
init().then( () => console.log( "WASM Loaded" ) );
</script>
then build specifying the target:
cargo build --target=wasm32-unknown-unknown --release
create the bindings:
wasm-bindgen ./target/wasm32-unknown-unknown/release/wgpu_intro.wasm --out-dir ./bin --target web
serve the files with you favorite localserver, eg. cargo-server
cargo server --open
Note: the default target can also be specified in .cargo/config.toml
as
[build]
target = "wasm32-unknown-unknown"