make app close when requested by os and other stuff (#61)

* idk

* mr stuff

* done

* fix windows

* add patches to Readme
This commit is contained in:
Schmarni
2024-01-01 00:35:59 +01:00
committed by GitHub
parent fcedb9c0c8
commit 65a30cac3c
22 changed files with 666 additions and 165 deletions

View File

@@ -1,6 +1,7 @@
use std::sync::atomic::AtomicBool;
use std::sync::Mutex;
// use crate::passthrough::XrPassthroughLayer;
use crate::resource_macros::*;
use bevy::prelude::*;
use openxr as xr;
@@ -58,6 +59,7 @@ impl Swapchain {
stage: &xr::Space,
resolution: UVec2,
environment_blend_mode: xr::EnvironmentBlendMode,
// passthrough_layer: Option<&XrPassthroughLayer>,
) -> xr::Result<()> {
match self {
Swapchain::Vulkan(swapchain) => swapchain.end(
@@ -66,6 +68,7 @@ impl Swapchain {
stage,
resolution,
environment_blend_mode,
// passthrough_layer,
),
}
}
@@ -125,6 +128,7 @@ impl<G: xr::Graphics> SwapchainInner<G> {
stage: &xr::Space,
resolution: UVec2,
environment_blend_mode: xr::EnvironmentBlendMode,
// passthrough_layer: Option<&XrPassthroughLayer>,
) -> xr::Result<()> {
let rect = xr::Rect2Di {
offset: xr::Offset2Di { x: 0, y: 0 },
@@ -138,6 +142,51 @@ impl<G: xr::Graphics> SwapchainInner<G> {
warn!("views are len of 0");
return Ok(());
}
// match passthrough_layer {
// Some(pass) => {
// // info!("Rendering with pass through");
// let passthrough_layer = xr::sys::CompositionLayerPassthroughFB {
// ty: CompositionLayerPassthroughFB::TYPE,
// next: ptr::null(),
// flags: CompositionLayerFlags::BLEND_TEXTURE_SOURCE_ALPHA,
// space: xr::sys::Space::NULL,
// layer_handle: pass.0,
// };
// self.stream.lock().unwrap().end(
// predicted_display_time,
// environment_blend_mode,
// &[
// &xr::CompositionLayerProjection::new()
// .layer_flags(CompositionLayerFlags::UNPREMULTIPLIED_ALPHA)
// .space(stage)
// .views(&[
// xr::CompositionLayerProjectionView::new()
// .pose(views[0].pose)
// .fov(views[0].fov)
// .sub_image(
// xr::SwapchainSubImage::new()
// .swapchain(&swapchain)
// .image_array_index(0)
// .image_rect(rect),
// ),
// xr::CompositionLayerProjectionView::new()
// .pose(views[1].pose)
// .fov(views[1].fov)
// .sub_image(
// xr::SwapchainSubImage::new()
// .swapchain(&swapchain)
// .image_array_index(1)
// .image_rect(rect),
// ),
// ]),
// unsafe {
// &*(&passthrough_layer as *const _ as *const CompositionLayerBase<G>)
// },
// ],
// )
// }
// None =>
self.stream.lock().unwrap().end(
predicted_display_time,
environment_blend_mode,
@@ -162,5 +211,6 @@ impl<G: xr::Graphics> SwapchainInner<G> {
),
])],
)
// }
}
}