How to check if an OpenXR/headset is available on your system?

If I want to make an application that has an XR mode and a non-xr mode, I need to first do some kind of checks if openxr stuff is available, right?

Should I just try to set up a context, try to create an openxr instance xrCreateInstance and if that returns with XR_FAILED then I tell the user xr is not available? Is that the normal way to do it, or is there a way to detect this beforehand?

When xrCreateInstance returned failure, it tells the app that the openxr runtime is somehow not configured correctly or not satisfying to app’s request. However, even if the “instance” is successfully created, it only tells you the openxr runtime is up and running. It doesn’t tell you the device is available.

You should use xrGetSystem afterwards to detect if the form factor you are expecting is connected and available for you to use. If you get XR_ERROR_FORM_FACTOR_UNAVAILABLE, the runtime tells the app that it can handle the app’s request, but the headset is not currently available, probably not connected to the computer yet.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.