You can develop using OpenXR on a HoloLens 2 or Windows Mixed Reality immersive headset on the desktop. If you don’t have access to a headset, you can use the HoloLens 2 Emulator or the Windows Mixed Reality Simulator instead.
To start developing OpenXR applications for HoloLens 2:
That’s it! The OpenXR API runtime is preinstalled on HoloLens 2 devices, and you’ll receive automatic updates through the Store.
To make sure you’ve got the latest OpenXR runtime with all extensions present, you can launch the Store app from the HoloLens device or emulator. Open the menu in the upper-right of the Store app, select Downloads and updates, and choose Get updates.
[!NOTE] If you’re using the emulator, the emulator image will reset each time you start it, and so your best bet is to just make sure that you have the latest version of the HoloLens 2 emulator image.
To start developing OpenXR applications for immersive Windows Mixed Reality headsets:
That’s it! The Windows Mixed Reality OpenXR runtime is installed and made active automatically for all Windows Mixed Reality users. The Microsoft Store then keeps the runtime up to date.
If you’ve been using multiple VR headsets on your PC, keep in mind that the active OpenXR runtime may be changed by another vendor’s system software. To reactivate the Windows Mixed Reality OpenXR Runtime, on the Start menu, launch “Mixed Reality Portal” and then select “Fix it” at the top of the window. If that button is missing, the OpenXR runtime is already active.
If you’re developing OpenXR applications for HoloLens 2 or PC VR, you might find this OpenXR Tools for Windows Mixed Reality app useful. It provides a demo of various OpenXR features and an OpenXR Runtime page that contains key information about the active runtime and current headset.
To find and install the OpenXR Tools app, on your HoloLens 2, go to the Store app and search for “OpenXR.”
When using the HoloLens 2 emulator, the easiest way to install the OpenXR Tools for Windows Mixed Reality is through the Windows Device Portal. In the Portal, navigate to the “OpenXR” page and then, under Developer Features, select the Install button. This also works on physical HoloLens 2 devices.
Be sure to install the tools you’ll need for OpenXR development if you haven’t already.
The BasicXrApp project shows a simple OpenXR sample with Win32 and UWP HoloLens 2 project files in Visual Studio. Because the solution contains a HoloLens UWP project, you’ll need the Universal Windows Platform development workload installed in Visual Studio to fully open it.
While the Win32 and UWP project files are separate because of differences in packaging and deployment, the app code inside each project is almost exactly the same!
For a tour of the OpenXR API, check out this 60-minute video of the BasicXrApp sample in Visual Studio. The video shows how each of the major components of the OpenXR API can be used in your own engine, and also demonstrates some of the applications built on OpenXR today:
[!VIDEO https://aka.ms/docs/player?show=mixed-reality&ep=openxr-cross-platform-native-mixed-reality]
After building an OpenXR Win32 desktop .EXE, you can use it with a VR headset on any desktop VR platform that supports OpenXR, whatever the headset type.
After building an OpenXR UWP app package, you can deploy that package to either a HoloLens 2 device or the HoloLens 2 Emulator.
To get started with OpenXR in an existing project, you’ll include the OpenXR loader. The loader discovers the active OpenXR runtime on the device and provides access to the core functions and extension functions that it implements.
You can reference the official OpenXR NuGet package from your Visual Studio project or include the official OpenXR loader source from the Khronos GitHub repo. Either approach will give you access to OpenXR 1.0 core features, plus published KHR
, EXT
and MSFT
extensions.
If you’re interested to experiment with MSFT_preview
extensions as well, you can copy in preview OpenXR headers from the Mixed Reality GitHub repo.
The OpenXR.Loader NuGet package is the easiest way to reference a prebuilt OpenXR loader .DLL in your Visual Studio C++ solution. This will give you access to OpenXR 1.0 core features, plus published KHR
, EXT
and MSFT
extensions.
To add an OpenXR.Loader NuGet package reference to your Visual Studio C++ solution:
#include <openxr/openxr.h>
to a source file to start using the OpenXR API.To see an example of the OpenXR API in action, check out the BasicXrApp sample app.
If you want to build the loader yourself, for example to avoid the extra loader .DLL, you can pull the official Khronos OpenXR loader sources into your project. This will give you access to OpenXR 1.0 core features, plus published KHR
, EXT
and MSFT
extensions.
To get started here, follow the instructions in the Khronos OpenXR-SDK repo on GitHub. The project is set up to build with CMake - if you’re using MSBuild, you’ll need to copy the code into your own project.
The MSFT_preview
extensions listed in the extension roadmap are experimental vendor extensions being previewed to gather feedback. These extensions are for developer devices only and will be removed when the real extension ships.
If you’re interested to try out the available MSFT_preview
extensions, go through the following steps to update your project:
To then activate preview extension support on your target HoloLens 2 or desktop PC:
See the Mixed Reality OpenXR repo for documentation of these preview extensions and samples of how to use them.
If you have trouble getting up and running with OpenXR development, check out our troubleshooting tips.