Additional compositor methods and docs

This commit is contained in:
Benjamin Saunders
2017-07-17 21:36:04 -07:00
parent 0c3affc00d
commit d6d3b40fc3
2 changed files with 22 additions and 6 deletions

View File

@ -92,6 +92,14 @@ impl<'a> Compositor<'a> {
}
}
/// Call immediately after presenting your app's window (i.e. companion window) to unblock the compositor.
///
/// This is an optional call, which only needs to be used if you can't instead call `wait_get_poses` immediately
/// after submitting frames. For example, if your engine's render and game loop are not on separate threads, or
/// blocking the render thread until 3ms before the next vsync would introduce a deadlock of some sort. This
/// function tells the compositor that you have finished all rendering after having Submitted buffers for both eyes,
/// and it is free to start its rendering work. This should only be called from the same thread you are rendering
/// on.
pub fn post_present_handoff(&self) {
unsafe { (self.0.PostPresentHandoff.unwrap())() };
}
@ -100,6 +108,13 @@ impl<'a> Compositor<'a> {
pub fn is_fullscreen(&self) -> bool {
unsafe { (self.0.IsFullscreen.unwrap())() }
}
/// Clears the frame that was sent with the last call to `submit.
///
/// This will cause the compositor to show the grid until `submit` is called again.
pub fn clear_last_submitted_frame(&self) {
unsafe { self.0.ClearLastSubmittedFrame.unwrap()() }
}
}
#[derive(Debug, Copy, Clone)]

View File

@ -38,8 +38,7 @@ impl<'a> RenderModels<'a> {
/// Get the names of available components.
///
/// `component` does not correlate to a tracked device index, but is only used for iterating over all available
/// components. If it's out of range, this function will return None. Otherwise, it will return the size of the
/// buffer required for the name.
/// components. If it's out of range, this function will return None.
pub fn component_name(&self, model: &CStr, component: u32) -> Option<CString> {
unsafe { get_string(|ptr, n| self.0.GetComponentName.unwrap()(model.as_ptr() as *mut _, component, ptr, n)) }
}
@ -50,7 +49,7 @@ impl<'a> RenderModels<'a> {
(0..n).map(|i| self.component_name(model, i).expect("inconsistent component presence reported by OpenVR")).collect::<Vec<_>>().into_iter()
}
/// Use this to get the render model name for the specified rendermode/component combination, to be passed to
/// Use this to get the render model name for the specified rendermodel/component combination, to be passed to
/// `load_render_model`.
///
/// If the component name is out of range, this function will return None.
@ -64,10 +63,12 @@ impl<'a> RenderModels<'a> {
/// Use this to query information about the component, as a function of the controller state.
///
/// Returns None if the component is invalid or should not be rendered in the current state.
/// Returns None if the component is invalid.
///
/// For dynamic controller components (ex: trigger) values will reflect component motions
/// For static components this will return a consistent value independent of the VRControllerState_t
/// Check `ComponentState::is_visible()` to determine whether the returned component should be rendered.
///
/// For dynamic controller components (ex: trigger) values will reflect component motions.
/// For static components this will return a consistent value independent of the `ControllerState`.
pub fn component_state(&self, model: &CStr, component: &CStr, state: &ControllerState, mode: &ControllerMode) -> Option<ComponentState> {
unsafe {
let mut out = mem::uninitialized();