Closed Zentendo closed 3 years ago
Hi!
The first issue that comes to mind is how the example code blocks on wgpu
futures: it uses the pollster
crate, which doesn't seem to be compatible with WASM. The wgpu
examples use wasm-bindgen-futures
instead when running on WASM (code).
I'll implement and test this change in a few hours when I have time.
Another problem on WASM will be loading images from disk—right now the example code expects them to be stored in the assets
directory. In the browser, though, we can't access files, so they have to be loaded from a URL.
It took a bit longer than expected, but I got the experimental
branch working on WASM now.
Besides the aforementioned problems, it turns out WebGL doesn't support storage buffers, which I was using to pass colors to the path shader. So I changed the shader to load color data from a 1D texture emulating a storage buffer.
Let me know how it works!
@caelunshun Hi, I'm very interested in this library for a nice canvas-like 2D rendering API for
wgpu
, and would like to use it for the web target (WebGL 2 / WebGPU) forwgpu
in WASM.What currently needs to be done to run this library in WebAssembly?
The example runs fine with
cargo run --example testbed
on the experimental branch.However, I'm getting these errors when running the compiled WASM in the browser:
I've tried changing the Cargo.toml to this:
And then running: