rust-mobile / rust-android-examples

Various standalone Rust Android examples
112 stars 21 forks source link

Update to wgpu 0.19, cross-platform #16

Open fr-an-k opened 7 months ago

fr-an-k commented 7 months ago

It has been very difficult to get wgpu to work (especially on older devices), so I'm sharing my result. Now that Android and WASM support has improved in all crates, I managed to support all platforms with the latest crate versions.

I know the intention of this repository is Android, but I believe having a ready-to-go example with cross-platform instructions is critical to support both developers and libraries on this new platform.

Unfortunately I don't have time to update all examples, but I think it's best to at least update this one for now.

I'm not sure about the web-sys features but it seems to support webgl and webgpu like this.

I set present_mode to fifo and alpha_mode to opaque, because that's what worked on my Android 8.1 device and is probably more widely supported. I left the other options commented out.

I also moved the rendering to App. Perhaps App should also get an input(event) and tick/update() function.

I also introduced WGPU_BACKEND as a compile time variable.

I also commented out the unnecessary request_redraw, with a comment that one could use it for animation.