Skip to content

A minimal example of using Rust, wgpu, and egui without using eframe 🦀 Works on Windows/Linux/MacOS/Web/Android/OpenXR (Such as Quest 3 + Virtual Desktop)

Notifications You must be signed in to change notification settings

matthewjberger/wgpu-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust / Winit / Egui / Wgpu Triangle

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:

native

Quickstart

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

Platform Setup

Web (WebAssembly)

Prerequisites: trunk

Browser Support: All Chromium-based browsers (Chrome, Brave, Vivaldi) support WebGPU. Firefox supports WebGPU starting with version 141 (announcement).

Android

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
  1. Enable Developer options: Settings > About phone > tap Build number 7 times
  2. Disable auto-blocker if present (Samsung): Settings > Security > Auto Blocker
  3. Enable wireless debugging: Settings > Developer options > Wireless debugging
  4. Tap Pair device with pairing code and note the IP:port
  5. 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 devices

Steam Deck

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.

OpenXR VR Mode

Renders the spinning triangle with an infinite grid, procedural skybox, and hand tracking in VR.

Setup:

  1. Install SteamVR
  2. Install Virtual Desktop or another OpenXR-compatible runtime
  3. Start Virtual Desktop and stream your desktop to your VR headset
  4. Run just run-openxr on your desktop

Screenshots

webgl webgpu

About

A minimal example of using Rust, wgpu, and egui without using eframe 🦀 Works on Windows/Linux/MacOS/Web/Android/OpenXR (Such as Quest 3 + Virtual Desktop)

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Contributors 3

  •  
  •  
  •