Struct BackendOpenXR

Source
pub struct BackendOpenXR;
Expand description

This class is NOT of general interest, unless you are trying to add support for some unusual OpenXR extension! StereoKit should do all the OpenXR work that most people will need. If you find yourself here anyhow for something you feel StereoKit should support already, please add a feature request on GitHub!

This class contains handles and methods for working directly with OpenXR. This may allow you to activate or work with OpenXR extensions that StereoKit hasn’t implemented or exposed yet. Check that Backend.XRType is OpenXR before using any of this.

These properties may best be used with some external OpenXR binding library, but you may get some limited mileage with the API as provided here. https://stereokit.net/Pages/StereoKit/Backend.OpenXR.html

see implementations in crate::tools::passthrough_fb_ext crate::tools::os_api

§Examples

use stereokit_rust::system::{Backend, BackendOpenXR, BackendXRType};

// This must be set before initializing StereoKit.
BackendOpenXR::use_minimum_exts(false);
BackendOpenXR::exclude_ext("XR_EXT_hand_tracking");
BackendOpenXR::request_ext("XR_EXT_hand_tracking");

stereokit_rust::test_init_sk!(); // !!!! Get a proper way to initialize sk !!!!


// These are result when not running in an OpenXR environment:
assert_eq!( Backend::xr_type(), BackendXRType::None);
assert_ne!( Backend::xr_type(), BackendXRType::OpenXR);

let eyes_sample_time = BackendOpenXR::eyes_sample_time();
assert_eq!(eyes_sample_time, 0);

let instance = BackendOpenXR::instance();
assert_eq!(instance, 0);

let session = BackendOpenXR::session();
assert_eq!(session, 0);

let space = BackendOpenXR::space();
assert_eq!(space, 0);

let system_id = BackendOpenXR::system_id();
assert_eq!(system_id, 0);

let time = BackendOpenXR::time();
assert_eq!(time, 0);

let ext_enabled = BackendOpenXR::ext_enabled("XR_EXT_hand_tracking");
assert_eq!(ext_enabled, false);

let get_function_ptr = BackendOpenXR::get_function_ptr("xrGetHandTrackerEXT");
assert_eq!(get_function_ptr, None);

let get_function = BackendOpenXR::get_function::<unsafe extern "C" fn()>("xrGetHandTrackerEXT");
assert_eq!(get_function, None);

BackendOpenXR::set_hand_joint_scale(1.0);

// using openxrs crate:
// let mut xr_composition_layer_x = XrCompositionLayerProjection{
//     ty: XrStructureType::XR_TYPE_COMPOSITION_LAYER_PROJECTION,
//     next: std::ptr::null(),
//     layer_flags: XrCompositionLayerFlags::empty(),
//     space: 0,
//     view_count: 0,
//     views: [XrCompositionLayerProjectionView::default(); 0],
// };
// BackendOpenXR::add_composition_layer(&mut xr_composition_layer_x, 0);

Implementations§

Source§

impl BackendOpenXR

Source

pub fn eyes_sample_time() -> i64

Type: XrTime. This is the OpenXR time of the eye tracker sample associated with the current value of. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/EyesSampleTime.html

see also backend_openxr_get_eyes_sample_time

Source

pub fn instance() -> OpenXRHandleT

Type: XrInstance. StereoKit’s instance handle, valid after Sk.initialize. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/Instance.html

see also backend_openxr_get_instance

Source

pub fn session() -> OpenXRHandleT

Type: XrSession. StereoKit’s current session handle, this will be valid after SK.Initialize, but the session may not be started quite so early. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/Session.html

see also backend_openxr_get_session

Source

pub fn space() -> OpenXRHandleT

Type: XrSpace. StereoKit’s primary coordinate space, valid after SK.Initialize, this will most likely be created from XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT or XR_REFERENCE_SPACE_TYPE_LOCAL. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/Space.html

see also backend_openxr_get_space

Source

pub fn system_id() -> OpenXRHandleT

Type: XrSystemId. This is the id of the device StereoKit is currently using! This is the result of calling xrGetSystem with XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/SystemId.html

see also backend_openxr_get_system_id

Source

pub fn time() -> i64

Type: XrTime. This is the OpenXR time for the current frame, and is available after Sk.initialize. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/Time.html

see also backend_openxr_get_time

Source

pub fn use_minimum_exts(value: bool)

Tells StereoKit to request only the extensions that are absolutely critical to StereoKit. You can still request extensions via OpenXR.RequestExt, and this can be used to opt-in to extensions that StereoKit would normally request automatically. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/UseMinimumExts.html

see also backend_openxr_use_minimum_exts

Source

pub fn add_composition_layer<T>(xr_composition_layer_x: &mut T, sort_order: i32)

This allows you to add XrCompositionLayers to the list that StereoKit submits to xrEndFrame. You must call this every frame you wish the layer to be included. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/AddCompositionLayer.html

  • xr_composition_layer_x - A serializable XrCompositionLayer struct that follows the XrCompositionLayerBaseHeader data pattern.
  • sort_order - An sort order value for sorting with other composition layers in the list. The primary projection layer that StereoKit renders to is at 0, -1 would be before it, and +1 would be after.

see also backend_openxr_composition_layer

Source

pub fn add_end_frame_chain<T>(xr_base_header: &mut T)

This adds an item to the chain of objects submitted to StereoKit’s xrEndFrame call! https://stereokit.net/Pages/StereoKit/Backend.OpenXR/AddEndFrameChain.html

  • xr_base_header - An OpenXR object that will be chained into the xrEndFrame call.

see also backend_openxr_end_frame_chain

Source

pub fn exclude_ext(extension_name: impl AsRef<str>)

This ensures that StereoKit does not load a particular extension! StereoKit will behave as if the extension is not available on the device. It will also be excluded even if you explicitly requested it with RequestExt earlier, or afterwards. This MUST be called before SK.Initialize. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/ExcludeExt.html

  • extension_name - The extension name as listed in the OpenXR spec. For example: “XR_EXT_hand_tracking”.

see also backend_openxr_ext_exclude

Source

pub fn request_ext(extension_name: impl AsRef<str>)

Requests that OpenXR load a particular extension. This MUST be called before SK.Initialize. Note that it’s entirely possible that your extension will not load on certain runtimes, so be sure to check ExtEnabled to see if it’s available to use. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/RequestExt.html

  • extension_name - The extension name as listed in the OpenXR spec. For example: “XR_EXT_hand_tracking”.

see also backend_openxr_ext_request

Source

pub fn ext_enabled(extension_name: impl AsRef<str>) -> bool

This tells if an OpenXR extension has been requested and successfully loaded by the runtime. This MUST only be called after SK.Initialize. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/ExtEnabled.html

  • extension_name - The extension name as listed in the OpenXR spec. For example: “XR_EXT_hand_tracking”.

see also backend_openxr_ext_enabled

Source

pub fn get_function_ptr(function_name: impl AsRef<str>) -> Option<VoidFunction>

This is basically xrGetInstanceProcAddr from OpenXR, you can use this to get and call functions from an extension you’ve loaded. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/GetFunctionPtr.html

  • function_name - The name of the function to get the pointer for.

see also backend_openxr_get_function

Source

pub fn get_function<T>(function_name: impl AsRef<str>) -> Option<T>

This is basically xrGetInstanceProcAddr from OpenXR, you can use this to get and call functions from an extension you’ve loaded. https://stereokit.net/Pages/StereoKit/Backend.OpenXR/GetFunctionPtr.html

  • function_name - The name of the function to get the pointer for.

see also backend_openxr_get_function

Source

pub fn set_hand_joint_scale(joint_scale_factor: f32)

This sets a scaling value for joints provided by the articulated hand extension. Some systems just don’t seem to get their joint sizes right! https://stereokit.net/Pages/StereoKit/Backend.OpenXR/SetHandJointScale.html

  • joint_scale_factor - 1 being the default value, 2 being twice as large as normal, and 0.5 being half as big as normal.

see also backend_openxr_set_hand_joint_scale

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more