Fixed functions calls and added VR_init

This commit is contained in:
Colin Sherratt
2015-06-15 21:29:48 -04:00
parent 7487541cae
commit a8f4425224
4 changed files with 206 additions and 136 deletions

View File

@ -1,3 +1,33 @@
extern crate openvr_sys;
extern crate openvr_sys;
#[derive(Debug)]
pub struct IVRSystem(*const ());
impl IVRSystem {
/// Initalize the IVR System
pub fn init() -> Result<IVRSystem, openvr_sys::HmdError> {
let mut err = openvr_sys::HmdError::None;
let ptr = unsafe {
openvr_sys::VR_Init(&mut err as *mut openvr_sys::HmdError)
};
if ptr.is_null() {
Err(err)
} else {
Ok(IVRSystem(ptr))
}
}
/// Get the window bounds
pub fn bounds(&self) -> ((i32, i32), (u32, u32)) {
unsafe {
let ((mut x, mut y), (mut w, mut h)) = ((0, 0), (0, 0));
openvr_sys::VR_IVRSystem_GetWindowBounds(
self.0, &mut x, &mut y, &mut w, &mut h
);
((x, y), (w, h))
}
}
}