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:
- Nightshade - Game engine based on this boilerplate
- vulkan-example - Vulkan version
- opengl-example - OpenGL version
- freecs - ECS library used by Nightshade
Other languages (experimental):
| 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 (Desktop) | just run-openxr |
| OpenXR VR (Quest) | just build-android-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-android
Build and run:
just list-android # Find your device ID
just run-android DEVICE_ID # e.g., just run-android RFCY61DZZKT
Connect 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 (windowed app)
just build-android-all # Build for arm64 and x64
just build-android-openxr # Build for Meta Quest VR
just install-android DEVICE_ID # Install without running
just connect-android IP:PORT # Connect over wireless ADB
just list-android # List connected devices
Prerequisites:
- cross
- Docker (for cross-compilation)
First-time setup:
just init-steamdeck
Build and deploy:
just build-steamdeck # Cross-compiles to target/x86_64-unknown-linux-gnu/release/app
just deploy-steamdeck # Transfers to steamdeck.local:~/Downloads
Run on Steam Deck:
just steamdeck-ssh
cd ~/Downloads && ./app
The 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 via PCVR streaming.
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
Native standalone VR for Meta Quest 2, Quest Pro, Quest 3, and Quest 3S.
Prerequisites:
- All Android prerequisites (see above)
- Meta Quest device with Developer Mode enabled
Build:
just build-android-openxr
This produces an APK at target/x/release/android/app.apk.
Install on Quest:
adb install -r target/x/release/android/app.apk
Or use SideQuest to drag and drop the APK onto your Quest.
The app appears in your Quest library under "Unknown Sources".
Technical Notes
- Uses the
android-openxrfeature which combinesandroidandopenxrfeatures - Bundles Meta's OpenXR loader from
libs/arm64-v8a/libopenxr_loader.so - Manifest includes
com.oculus.intent.category.VRfor proper VR app handling - Supports Quest hand tracking and controller input
- Requires
manifest.yamlwithruntime_libsconfiguration for library bundling