.. _4 Pico OpenXR Development: 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: .. code-block:: java 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: (1) Link to the OpenXR loader library in this package at **/OpenXR/Libs/Android**. (2) In **/java/com/khronos/hello_xr/MainActivity.java**, load the openxr_loader library before loading the application shared library: .. code-block:: java System.loadLibrary("openxr_loader"); (3) Add the following meta-data to AndroidManifest.xml: .. code-block:: java (4) Before running hello_xr, make sure to specify the graphic plugin to use with one of the following adb commands: .. code-block:: java adb shell setprop debug.xr.graphicsPlugin OpenGLES adb shell setprop debug.xr.graphicsPlugin Vulkan (5) 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 at ``xrCreateInstance`` as follows. .. code-block:: java 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. .. code-block:: java xrGetInstanceProcAddr(m_instance,"xrGetConfigPICO", reinterpret_cast(&pfnXrGetConfigPICO)); xrGetInstanceProcAddr(m_instance,"xrResetSensorPICO", reinterpret_cast(&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. (6) Setting **eyeLevel** and **floorLevel** requires to call Pico’s extension function ``xrSetConfigPICO``. To do this, you need to turn on the related extensions in ``XRCreateInstance`` as follows: .. code-block:: java extensions.push_back(XR_PICO_CONFIGS_EXT_EXTENSION_NAME); Next, excute the following to get the extension function: .. code-block:: java xrGetInstanceProcAddr(m_instance,"xrSetConfigPICO", reinterpret_cast(&pfnXrSetConfigPICO)); Then, set **eyeLevel/floorLevel** using the extension ``pfnXrSetConfigPICO`` after successfully creating an **xrSession**. Set **eyeLevel**: .. code-block:: java pfnXrSetConfigPICO(m_session,TRACKING_ORIGIN,"0"); Set **floorLevel**: .. code-block:: java pfnXrSetConfigPICO(m_session,TRACKING_ORIGIN,"1");