Function ovr_sys::ovr_Initialize [] [src]

pub unsafe extern "C" fn ovr_Initialize(
    params: *const ovrInitParams
) -> ovrResult

Initializes LibOVR

Initialize LibOVR for application usage. This includes finding and loading the LibOVRRT shared library. No LibOVR API functions, other than ovr_GetLastErrorInfo and ovr_Detect, can be called unless ovr_Initialize succeeds. A successful call to ovr_Initialize must be eventually followed by a call to ovr_Shutdown. ovr_Initialize calls are idempotent. Calling ovr_Initialize twice does not require two matching calls to ovr_Shutdown. If already initialized, the return value is ovr_Success.

LibOVRRT shared library search order:

  • Current working directory (often the same as the application directory).
  • Module directory (usually the same as the application directory, but not if the module is a separate shared library).
  • Application directory
  • Development directory (only if OVR_ENABLE_DEVELOPER_SEARCH is enabled, which is off by default).
  • Standard OS shared library search location(s) (OS-specific).

params Specifies custom initialization options. May be NULL to indicate default options when using the CAPI shim. If you are directly calling the LibOVRRT version of ovr_Initialize in the LibOVRRT DLL then this must be valid and include ovrInit_RequestVersion.

Returns an ovrResult indicating success or failure. In the case of failure, use ovr_GetLastErrorInfo to get more information. Example failed results include:

  • ovrError_Initialize: Generic initialization error.
  • ovrError_LibLoad: Couldn't load LibOVRRT.
  • ovrError_LibVersion: LibOVRRT version incompatibility.
  • ovrError_ServiceConnection: Couldn't connect to the OVR Service.
  • ovrError_ServiceVersion: OVR Service version incompatibility.
  • ovrError_IncompatibleOS: The operating system version is incompatible.
  • ovrError_DisplayInit: Unable to initialize the HMD display.
  • ovrError_ServerStart: Unable to start the server. Is it already running?
  • ovrError_Reinitialization: Attempted to re-initialize with a different version.

Example code

let initParams = ovrInitParams {
    Flags: ovrInit_RequestVersion,
    RequestedMinorVersion: OVR_MINOR_VERSION,
    LogCallback: None,
    UserData: 0,
    ConnectionTimeoutMS: 0,
    .. mem::uninitialized()
};
let result = ovr_Initialize(&initParams as *const _);
if OVR_FAILURE(result) {
    let mut error_info: ovrErrorInfo = mem::zeroed();
    ovr_GetLastErrorInfo(&mut error_info as *mut _);
    let error_string = CStr::from_ptr(&error_info.ErrorString as *const c_char)
        .to_str().unwrap();
    return Err(format!("ovr_Initialize failed: {}", error_string));
}

see ovr_Shutdown