You are currently viewing archived documentation. Use the left navigation to return to the latest.

LibOVR Integration

The Oculus SDK is designed to be as easy to integrate as possible. This section outlines a basic Oculus integration with a C++ game engine or application.

We’ll discuss initializing the LibOVR, HMD device enumeration, head tracking, frame timing, and rendering for the Rift.

Many of the code samples below are taken directly from the OculusRoomTiny demo source code (available in Oculus/LibOVR/Samples/OculusRoomTiny). OculusRoomTiny and OculusWorldDemo are great places to view sample integration code when in doubt about a particular system or feature.

Integrating LibOVR

To add Oculus support to a new application, do the following:

  1. Initialize LibOVR.

  2. Enumerate Oculus devices, create the ovrHmd object, and start sensor input.

  3. Integrate head-tracking into your application’s view and movement code. This involves:

    1. Reading data from the Rift sensors through or ovrHmd_GetTrackingStateorovrHmd_GetEyePose.

    2. Applying Rift orientation and position to the camera view, while combining it with other application controls.

    3. Modifying movement and game play to consider head orientation.

  4. Initialize rendering for the HMD.

    1. Select rendering parameters such as resolution and field of view based on HMD capabilities.

    2. For SDK rendered distortion, configure rendering based on system rendering API pointers and viewports.

    3. For client rendered distortion, create the necessary distortion mesh and shader resources.

  5. Modify application frame rendering to integrate HMD support and proper frame timing:

    1. Make sure your engine supports multiple rendering views.

    2. Add frame timing logic into the render loop to ensure that motion prediction and timewarp work correctly.

    3. Render each eye’s view to intermediate render targets.

    4. Apply distortion correction to render target views to correct for the optical characteristics of the lenses (only necessary for client rendered distortion).

  6. Customize UI screens to work well inside of the headset.