Struct openxr::FrameStream

source ·
pub struct FrameStream<G: Graphics> { /* private fields */ }
Expand description

Handle for managing frame presentation

This is a secondary interface to a Session object that exposes only the frame wait/begin/end operations. These are separated so that &mut self receivers can be used to statically guarantee that calls are synchronized as required by OpenXR, enabling a safe interface.

§Example

A typical presentation loop body should look roughly as follows:

let state = frame_waiter.wait().unwrap();
let image = swapchain.acquire_image().unwrap();
swapchain.wait_image(openxr::Duration::INFINITE).unwrap();

frame_stream.begin().unwrap();

if state.should_render {
    // draw scene...
}

let (view_flags, views) = session
    .locate_views(
        openxr::ViewConfigurationType::PRIMARY_STEREO,
        state.predicted_display_time,
        world_space,
    )
    .unwrap();

// set view matrices and submit to GPU...

swapchain.release_image().unwrap();
frame_stream
    .end(
        state.predicted_display_time,
        openxr::EnvironmentBlendMode::OPAQUE,
        &[&openxr::CompositionLayerProjection::new()
            .space(world_space)
            .views(&[
                openxr::CompositionLayerProjectionView::new()
                    .pose(views[0].pose)
                    .fov(views[0].fov)
                    .sub_image(
                        openxr::SwapchainSubImage::new()
                            .swapchain(swapchain)
                            .image_array_index(0)
                            .image_rect(openxr::Rect2Di {
                                offset: openxr::Offset2Di { x: 0, y: 0 },
                                extent: view_resolution[0],
                            }),
                    ),
                openxr::CompositionLayerProjectionView::new()
                    .pose(views[1].pose)
                    .fov(views[1].fov)
                    .sub_image(
                        openxr::SwapchainSubImage::new()
                            .swapchain(swapchain)
                            .image_array_index(1)
                            .image_rect(openxr::Rect2Di {
                                offset: openxr::Offset2Di { x: 0, y: 0 },
                                extent: view_resolution[1],
                            }),
                    ),
            ])],
    )
    .unwrap();

Implementations§

source§

impl<G: Graphics> FrameStream<G>

source

pub fn begin(&mut self) -> Result<()>

Indicate that graphics device work is beginning

source

pub fn end( &mut self, display_time: Time, environment_blend_mode: EnvironmentBlendMode, layers: &[&CompositionLayerBase<'_, G>] ) -> Result<()>

Indicate that all graphics work for the frame has been submitted

layers is an array of references to any type of composition layer, e.g. CompositionLayerProjection.

source

pub fn end_secondary( &mut self, display_time: Time, environment_blend_mode: EnvironmentBlendMode, layers: &[&CompositionLayerBase<'_, G>], secondary_info: SecondaryEndInfo<'_, '_, '_, G> ) -> Result<()>

Indicate that all graphics work for the frame has been submitted

layers is an array of references to any type of composition layer, e.g. CompositionLayerProjection.

secondary_info has the same information for the secondary layer

XR_MSFT_secondary_view_configuration must be loaded and the session must have been started with begin_secondary

Auto Trait Implementations§

§

impl<G> !RefUnwindSafe for FrameStream<G>

§

impl<G> Send for FrameStream<G>
where G: Send,

§

impl<G> Sync for FrameStream<G>
where G: Sync,

§

impl<G> Unpin for FrameStream<G>
where G: Unpin,

§

impl<G> !UnwindSafe for FrameStream<G>

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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>,

§

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>,

§

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.