This repository contains OpenXR code samples tailored for developers who are familiar with and using the Visual Studio toolchain, e.g. HoloLens 2 developers.
These OpenXR samples use C++17 and D3D11. The same source code works across UWP applications running on HoloLens 2 and Win32 applications running on Windows Desktop with Windows Mixed Reality immersive headsets.
-
Understand what is OpenXR and why OpenXR. Read the latest OpenXR 1.0 spec (HTML) and the latest openxr.h header file (Khronos GitHub).
-
Update to Windows 10 May 2019 Update (1903) or later and Visual Studio 2017 or 2019. If you will be deploying to a HoloLens 2, you should install Visual Studio 2019 16.2 or later.
-
Prepare a HoloLens 2 device or Windows Mixed Reality device.
-
Clone the samples repo:
git clone https://github.com/microsoft/OpenXR-MixedReality.git
- The repo has been renamed from
OpenXR-SDK-VisualStudio
since 03/06/2020. If you cloned the repo before this, redirect your local repo using this command:git remote set-url origin https://github.com/microsoft/OpenXR-MixedReality.git
- The repo has been renamed from
-
Open the
BasicXrApp.sln
orSamples.sln
file in Visual Studio. F5 to build and run the sample. You typically choose ARM64 platform when running on HoloLens 2 devices, or choose x64 platform when running on a Windows Desktop PC with the HoloLens 2 Emulator or a Windows Mixed Reality immersive headset (or simulator). -
The core OpenXR API usage patterns can be found in the OpenXRProgram.cpp file. The Run() function at the beginning captures a typical OpenXR app code flow for session initialization, event handling, the frame loop and input actions.
The BasicXrApp demonstrates the best practices for an OpenXR app to achieve full frame rate and low latency.
For more detailed information on getting the best visual quality and performance on HoloLens 2, see the best practices for HoloLens 2.
The openxr_preview folder contains a set of preview header files containing the following preview OpenXR extensions:
- XR_MSFT_hand_interaction_preview
- XR_MSFT_hand_tracking_preview
- XR_MSFT_hand_tracking_mesh_preview
- XR_MSFT_secondary_view_configuration_preview
- XR_MSFT_first_person_observer_preview
- XR_MSFT_spatial_graph_bridge_preview
For sample code demonstrating how to use the preview extensions above, see the SampleSceneUwp, ThreeCubes and XrSceneLib preview extensions. Please file feedback on these preview extensions as GitHub issues. We are planning to incorporate your feedback and finalize these extensions as vendor extensions (MSFT) or cross-vendor extensions (EXT) in the central Khronos OpenXR headers and spec over the coming months.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.