Skip to content

Commit d4dd014

Browse files
add an openxr backend
1 parent 4ae764f commit d4dd014

File tree

9 files changed

+1750
-22
lines changed

9 files changed

+1750
-22
lines changed

Cargo.lock

Lines changed: 104 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ name = "app_core"
1111

1212
[dependencies]
1313
bytemuck = { version = "1.24.0", features = ["derive"] }
14+
clap = { version = "4.5", features = ["derive"] }
1415
egui = "0.33.0"
1516
egui-wgpu = { version = "0.33.0", features = ["winit"] }
1617
futures = "0.3.31"
@@ -19,14 +20,18 @@ nalgebra-glm = { version = "0.20.0", features = [
1920
"convert-bytemuck",
2021
"serde-serialize",
2122
] }
23+
openxr = { version = "0.19", features = ["static", "loaded"], optional = true }
2224
web-time = "1.1.0"
2325
wgpu = { version = "27.0.1", default-features = false }
2426
winit = "0.30.12"
2527

2628
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
29+
ash = { version = "0.38", optional = true }
2730
env_logger = "0.11.8"
2831
egui-winit = "0.33.0"
32+
gpu-allocator = { version = "0.27", optional = true }
2933
pollster = "0.4.0"
34+
wgpu-hal = { version = "27.0.4", optional = true }
3035

3136
[target.'cfg(target_arch = "wasm32")'.dependencies]
3237
console_error_panic_hook = "0.1.7"
@@ -37,5 +42,6 @@ wasm-bindgen-futures = "0.4.55"
3742

3843
[features]
3944
default = ["wgpu/default"]
45+
openxr = ["dep:openxr", "dep:ash", "dep:wgpu-hal", "dep:gpu-allocator"]
4046
webgl = ["wgpu/webgl"]
4147
webgpu = ["wgpu/webgpu"]

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This project demonstrates how to setup a [rust](https://www.rust-lang.org/) proj
44
that uses [wgpu](https://wgpu.rs/) to render a spinning triangle, supporting
55
both webgl and webgpu [wasm](https://webassembly.org/) as well as native.
66

7+
It also includes an [OpenXR](https://www.khronos.org/openxr/) VR mode with hand tracking, procedural skybox, and infinite grid.
8+
79
> If you're looking for a Vulkan example, check out [the vulkan-example repo](https://github.com/matthewjberger/vulkan-example)
810
>
911
> If you're looking for an OpenGL example, check out [the opengl-example repo](https://github.com/matthewjberger/opengl-example)
@@ -12,7 +14,7 @@ both webgl and webgpu [wasm](https://webassembly.org/) as well as native.
1214

1315
## Quickstart
1416

15-
```
17+
```bash
1618
# native
1719
cargo run -r
1820

@@ -21,11 +23,26 @@ trunk serve --features webgpu --open
2123

2224
# webgl
2325
trunk serve --features webgl --open
26+
27+
# OpenXR VR mode
28+
just run-openxr
2429
```
2530

2631
> All chromium-based browsers like Brave, Vivaldi, Chrome, etc support wgpu.
2732
> Firefox also [supports wgpu](https://mozillagfx.wordpress.com/2025/07/15/shipping-webgpu-on-windows-in-firefox-141/) now starting with version `141`.
2833
34+
## OpenXR VR Mode
35+
36+
The OpenXR VR mode renders a spinning triangle, infinite grid, and procedural skybox in virtual reality with hand tracking.
37+
38+
### Setup
39+
40+
1. Install [SteamVR](https://store.steampowered.com/app/250820/SteamVR/)
41+
2. Install [Virtual Desktop](https://www.vrdesktop.net/) (or another OpenXR-compatible VR runtime)
42+
3. Start Virtual Desktop and stream your desktop to your VR headset
43+
4. On your desktop, run `just run-openxr`
44+
5. The application will appear in VR
45+
2946
## Prerequisites (web)
3047

3148
* [trunk](https://trunkrs.dev/)

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ lint:
4141
run:
4242
cargo run -r
4343

44+
# Run the desktop app in OpenXR mode
45+
run-openxr:
46+
cargo run -r --features openxr -- --openxr
47+
4448
# Build the app with wgpu + WebGL
4549
build-webgl:
4650
trunk build --features webgl

0 commit comments

Comments
 (0)