A cross-platform Rust graphics demo using wgpu to render a spinning triangle. Supports native desktop, WebGL/WebGPU (WASM), Android, Steam Deck, and OpenXR VR with hand tracking.
Related Projects:
- vulkan-example - Vulkan version
- opengl-example - OpenGL version
- Nightshade - Game engine based on this boilerplate
- freecs - ECS library used by Nightshade
| Platform | Command |
|---|---|
| Native Desktop | cargo run -r |
| WebGPU | trunk serve --features webgpu --open |
| WebGL | trunk serve --features webgl --open |
| Android | just run-android DEVICE_ID |
| Steam Deck | just build-steamdeck && just deploy-steamdeck |
| OpenXR VR | just run-openxr |
Prerequisites: trunk
Browser Support: All Chromium-based browsers (Chrome, Brave, Vivaldi) support WebGPU. Firefox supports WebGPU starting with version 141 (announcement).
Prerequisites:
- xbuild
- Android SDK and NDK
- Connected Android device or emulator (API level 24+)
First-time setup:
just init-androidBuild and run:
just list-android # Find your device ID
just run-android DEVICE_ID # e.g., just run-android RFCY61DZZKTConnect via USB with USB debugging enabled, or use wireless debugging (see below).
The build uses --features android which enables wgpu's Vulkan backend.
Wireless Debugging Setup
- Enable Developer options: Settings > About phone > tap Build number 7 times
- Disable auto-blocker if present (Samsung): Settings > Security > Auto Blocker
- Enable wireless debugging: Settings > Developer options > Wireless debugging
- Tap Pair device with pairing code and note the IP:port
- Pair and connect:
just pair-android 192.168.1.100:37000 # Enter pairing code when prompted just list-android # Get device ID just run-android DEVICE_ID
Additional Android Commands
just build-android # Build only
just build-android-all # Build for arm64 and x64
just install-android DEVICE_ID # Install without running
just connect-android IP:PORT # Connect over wireless ADB
just list-android # List connected devicesPrerequisites:
- cross
- Docker (for cross-compilation)
First-time setup:
just init-steamdeckBuild and deploy:
just build-steamdeck # Cross-compiles to target/x86_64-unknown-linux-gnu/release/app
just deploy-steamdeck # Transfers to steamdeck.local:~/DownloadsRun on Steam Deck:
just steamdeck-ssh
cd ~/Downloads && ./appThe Cross.toml file configures system libraries for graphics and windowing support.
Renders the spinning triangle with an infinite grid, procedural skybox, and hand tracking in VR.
Setup:
- Install SteamVR
- Install Virtual Desktop or another OpenXR-compatible runtime
- Start Virtual Desktop and stream your desktop to your VR headset
- Run
just run-openxron your desktop