A modern OpenXR wrapper library written in C++20 that streamlines XR development while maintaining OpenXR's full capabilities. Built with native Vulkan support, it abstracts complex API interactions without sacrificing performance or flexibility.
The library features an optional physically-based rendering (PBR) engine specifically optimized for mixed reality applications, enabling developers to create high-fidelity immersive experiences with minimal boilerplate code.
Developers can also quickly bootstrap immersive experiences by inheriting from XrApp (link to demos), or leverage the library's individual components for custom implementations.
Explore xrlib's capabilities through a collection of example applications available at xrlib-demos. These demos showcase:
- checkxr - Runtime capability querying and inspection
- displayxr - Basic XR visualization and rendering
- passthroughxr - Meta Quest Passthrough implementation
- handtrackingxr - Hand tracking visualization
- inputxr - Full-featured input handling, multi-threading via xrlib's xr dynamic thread pool manager, and PBR rendering
- interactionsxr - Demonstrates the EXT Hand Interaction extension, including passthrough and simultaneous hand/controller tracking, and system properties querying.
Each demo provides clear, practical implementation examples designed to highlight specific xrlib features. Desktop (Windows, Linux) and Android builds are supported for all demos.
-
Required Tools
- CMake 3.22 or higher
- C++20 compatible compiler
- Vulkan SDK (from https://vulkan.lunarg.com/)
- glslc (Vulkan shader compiler, included in Vulkan SDK)
-
Optional Tools
- RenderDoc (if building with debug features)
-
Clone the Repository
git clone [repository-url] cd xrlib -
Configure Build Options
The following CMake options are available:
- `BUILD_AS_STATIC`: Build as static library (default: OFF)
- `BUILD_SHADERS`: Build shaders in resource directory (default: ON)
- `ENABLE_XRVK`: Compile xrvk - PBR render module (default: ON)
- `ENABLE_RENDERDOC`: Enable RenderDoc for render debugging (default: ON)
- `ENABLE_VULKAN_DEBUG`: Enable Vulkan debugging (default: OFF)
- `EXCLUDE_KHR_VISIBILITY_MASK`: Exclude KHR visibility mask extension (default: OFF)
- `EXCLUDE_EXT_HAND_TRACKING`: Exclude hand tracking extension (default: OFF)
- `EXCLUDE_FB_DISPLAY_REFRESH`: Exclude display refresh rate extension (default: OFF)
- `EXCLUDE_FB_PASSTHROUGH`: Exclude passthrough extension (default: OFF)
- Configure and Build
```bash
# Create build directory
mkdir build
cd build
# Configure with CMake
cmake ..
# Build
cmake --build . --config Release
```
```bash
# Create build directory
mkdir build
cd build
# Configure with CMake
cmake ..
# Build
make
```
Additional requirements: - Android NDK - Android native app glue
```bash
# Create build directory
mkdir build
cd build
# Configure with CMake (adjust paths as needed)
cmake .. -DANDROID=ON -DANDROID_NDK=/path/to/ndk
# Build
cmake --build .
```
- Output Locations
After successful build, you'll find the outputs in:
- Binaries: ./bin/
- Libraries: ./lib/
- Shader binaries (if enabled): ./res/shaders/bin/
cmake .. \
-DBUILD_AS_STATIC=ON \
-DENABLE_VULKAN_DEBUG=ON \
-DEXCLUDE_FB_PASSTHROUGH=ON# Configure debug build
cmake .. -DCMAKE_BUILD_TYPE=Debug
# Build
cmake --build . --config DebugTo verify your build:
- Check that the library files exist in the
libdirectory - If building with shaders enabled, verify shader
.spvfiles exist inres/shaders/bin - For debug builds, ensure debug symbols are present
-
Vulkan SDK Not Found
- Ensure Vulkan SDK is installed
- Verify
VULKAN_SDKenvironment variable is set correctly
-
Shader Compilation Fails
- Verify
glslcis in your PATH - Check shader source files in
res/shaders/src
- Verify
-
Android Build Issues
- Verify NDK path is correct
- Ensure native app glue is available in NDK
When developing with the library:
- Header files are in include directory
- Source files are in src directory
- Shader sources are in res/shaders/src
- Build artifacts are placed in bin and lib directories