This is just the wgpu-rs
triangle example with a handful of small changes, which I'll outline below:
- Annotated
main
with#[mobile_entry_point]
, which generates all theextern
functions we need for mobile. Note that the name of the function doesn't actually matter for this. - Changes conditionally compiled on Android:
- Use
android_logger
instead ofwgpu-subscriber
- Use
Rgba8UnormSrgb
instead ofBgra8UnormSrgb
(ideally, the supported format would be detected dynamically instead) - Use
std::thread::sleep
to shoddily workaroundraw_window_handle
requirements - Render directly upon
MainEventsCleared
instead of callingrequest_redraw
, since winit doesn't implement that method on Android yet
- Use
To run this on desktop, just do cargo run
like normal! For mobile, use cargo android run
and cargo apple run
respectively (or use cargo android open
/cargo apple open
to open in Android Studio and Xcode respectively).