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:

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:

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