4 Pico OpenXR Development¶
4.1 Overview¶
In addition to the documentation from the Khronos Group, this section contains information needed to develop OpenXR applications for Pico devices. When setting up an OpenXR project, add the following meta-data to AndroidManifest.xml:
<meta-data android:name="pvr.app.type" android:value="vr" />
As OpenXR 1.0 did not include a standard Android loader, Pico has provided a custom Android loader. The loader library can be found in /OpenXR/Libs/Android/ in this SDK package.
On Android, the loader must be initialized with platform-specific parameters before it can be loaded. These parameters can be specified with the KHR extension XR_KHR_loader_init_android
.
The KHR extension XR_KHR_Loader_Init_Android
is currently defined in /OpenXR/Include/openxr_platform.h. Applications are required to first get the function pointer for xrInitializeLoaderKHR
via xrGetInstanceProcAddress
with a null instance pointer, and then call xrInitializeLoaderKHR
with the XrLoaderInitInfoAndroidKHR
struct defined in XR_KHR_loader_init_android
.
For how the runtime is loaded, the application is required to specify its JVM and Activity. This information is provided at xrCreateInstance
time via XR_KHR_android_create_instance
. However, OpenXR allows specific entry points to be called before xrCreateInstance
. In these cases, the application will be required to call xrInitializeLoaderKHR
first to provide valid JVM and Activity of the application.
4.2 Getting Started¶
This section will guide you to get started with hello_xr, a simple cross-platform OpenXR sample in the Khronos Group’s OpenXR-SDK-Source Github repository located at /OpenXR/Sample/HelloXR.
The following modifications must be made to the sample in order to load the OpenXR runtime on Pico systems:
- Link to the OpenXR loader library in this package at /OpenXR/Libs/Android.
- In /java/com/khronos/hello_xr/MainActivity.java, load the openxr_loader library before loading the application shared library:
System.loadLibrary("openxr_loader");
- Add the following meta-data to AndroidManifest.xml:
<meta-data android:name="pvr.app.type" android:value="vr" />
- Before running hello_xr, make sure to specify the graphic plugin to use with one of the following adb commands:
adb shell setprop debug.xr.graphicsPlugin OpenGLES
adb shell setprop debug.xr.graphicsPlugin Vulkan
- To reset the HMD sensor, you need to call Pico’s extension function
xrResetSensorPICO
. Before doing this, you need to turn on the related extensions atxrCreateInstance
as follows.
extensions.push_back(XR_PICO_CONFIGS_EXT_EXTENSION_NAME);
extensions.push_back(XR_PICO_RESET_SENSOR_EXTENSION_NAME);
Next, execute the following to get the extension function.
xrGetInstanceProcAddr(m_instance,"xrGetConfigPICO",
reinterpret_cast<PFN_xrVoidFunction *>(&pfnXrGetConfigPICO));
xrGetInstanceProcAddr(m_instance,"xrResetSensorPICO",
reinterpret_cast<PFN_xrVoidFunction *>(&pfnXrResetSensorPICO));
Then, use the extension pfnXrGetConfigPICO
to get ENABLE_6DOF
, and then call pfnXrResetSensorPICO
to reset the HMD pose.
For detailed information, please refer to HelloXR Sample, in which you can reset the HMD pose by pressing the A button of controller.
- Setting eyeLevel and floorLevel requires to call Pico’s extension function
xrSetConfigPICO
. To do this, you need to turn on the related extensions inXRCreateInstance
as follows:
extensions.push_back(XR_PICO_CONFIGS_EXT_EXTENSION_NAME);
Next, excute the following to get the extension function:
xrGetInstanceProcAddr(m_instance,"xrSetConfigPICO", reinterpret_cast<PFN_xrVoidFunction *>(&pfnXrSetConfigPICO));
Then, set eyeLevel/floorLevel using the extension pfnXrSetConfigPICO
after successfully creating an xrSession.
Set eyeLevel:
pfnXrSetConfigPICO(m_session,TRACKING_ORIGIN,"0");
Set floorLevel:
pfnXrSetConfigPICO(m_session,TRACKING_ORIGIN,"1");