add enabled extension and implement overlay plugin
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
use bevy::prelude::{Deref, DerefMut};
|
use bevy::{ecs::system::Resource, prelude::{Deref, DerefMut}};
|
||||||
use openxr::ExtensionSet;
|
use openxr::ExtensionSet;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Deref, DerefMut, Resource)]
|
||||||
|
pub struct OxrEnabledExtensions(pub OxrExtensions);
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Deref, DerefMut)]
|
#[derive(Clone, Debug, Eq, PartialEq, Deref, DerefMut)]
|
||||||
pub struct OxrExtensions(ExtensionSet);
|
pub struct OxrExtensions(ExtensionSet);
|
||||||
impl OxrExtensions {
|
impl OxrExtensions {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod handtracking;
|
pub mod handtracking;
|
||||||
#[cfg(feature = "passthrough")]
|
#[cfg(feature = "passthrough")]
|
||||||
pub mod passthrough;
|
pub mod passthrough;
|
||||||
|
pub mod overlay;
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ use bevy_xr::session::XrStatus;
|
|||||||
use bevy_xr::session::XrStatusChanged;
|
use bevy_xr::session::XrStatusChanged;
|
||||||
|
|
||||||
use crate::error::OxrError;
|
use crate::error::OxrError;
|
||||||
|
use crate::features::overlay::OxrOverlaySessionEvent;
|
||||||
use crate::graphics::*;
|
use crate::graphics::*;
|
||||||
|
use crate::openxr::exts::OxrEnabledExtensions;
|
||||||
use crate::resources::*;
|
use crate::resources::*;
|
||||||
use crate::session::OxrSession;
|
use crate::session::OxrSession;
|
||||||
use crate::session::OxrSessionCreateNextChain;
|
use crate::session::OxrSessionCreateNextChain;
|
||||||
@@ -97,7 +99,9 @@ impl Plugin for OxrInitPlugin {
|
|||||||
system_id,
|
system_id,
|
||||||
WgpuGraphics(device, queue, adapter_info, adapter, wgpu_instance),
|
WgpuGraphics(device, queue, adapter_info, adapter, wgpu_instance),
|
||||||
session_create_info,
|
session_create_info,
|
||||||
|
enabled_exts,
|
||||||
)) => {
|
)) => {
|
||||||
|
app.insert_resource(enabled_exts);
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
RenderPlugin {
|
RenderPlugin {
|
||||||
render_creation: RenderCreation::manual(
|
render_creation: RenderCreation::manual(
|
||||||
@@ -197,7 +201,15 @@ pub fn update_root_transform(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl OxrInitPlugin {
|
impl OxrInitPlugin {
|
||||||
fn init_xr(&self) -> Result<(OxrInstance, OxrSystemId, WgpuGraphics, SessionConfigInfo)> {
|
fn init_xr(
|
||||||
|
&self,
|
||||||
|
) -> Result<(
|
||||||
|
OxrInstance,
|
||||||
|
OxrSystemId,
|
||||||
|
WgpuGraphics,
|
||||||
|
SessionConfigInfo,
|
||||||
|
OxrEnabledExtensions,
|
||||||
|
)> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let entry = OxrEntry(openxr::Entry::linked());
|
let entry = OxrEntry(openxr::Entry::linked());
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@@ -236,7 +248,7 @@ impl OxrInitPlugin {
|
|||||||
|
|
||||||
let instance = entry.create_instance(
|
let instance = entry.create_instance(
|
||||||
self.app_info.clone(),
|
self.app_info.clone(),
|
||||||
exts,
|
exts.clone(),
|
||||||
// &["XR_APILAYER_LUNARG_api_dump"],
|
// &["XR_APILAYER_LUNARG_api_dump"],
|
||||||
&[],
|
&[],
|
||||||
backend,
|
backend,
|
||||||
@@ -274,6 +286,7 @@ impl OxrInitPlugin {
|
|||||||
OxrSystemId(system_id),
|
OxrSystemId(system_id),
|
||||||
graphics,
|
graphics,
|
||||||
session_create_info,
|
session_create_info,
|
||||||
|
OxrEnabledExtensions(exts),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,6 +508,7 @@ pub fn poll_events(
|
|||||||
mut status: ResMut<XrStatus>,
|
mut status: ResMut<XrStatus>,
|
||||||
mut changed_event: EventWriter<XrStatusChanged>,
|
mut changed_event: EventWriter<XrStatusChanged>,
|
||||||
mut session_status_events: EventWriter<OxrSessionStatusEvent>,
|
mut session_status_events: EventWriter<OxrSessionStatusEvent>,
|
||||||
|
mut overlay_writer: Option<ResMut<Events<OxrOverlaySessionEvent>>>,
|
||||||
) {
|
) {
|
||||||
let _span = info_span!("xr_poll_events");
|
let _span = info_span!("xr_poll_events");
|
||||||
let mut buffer = Default::default();
|
let mut buffer = Default::default();
|
||||||
@@ -534,6 +548,16 @@ pub fn poll_events(
|
|||||||
}
|
}
|
||||||
InstanceLossPending(_) => {}
|
InstanceLossPending(_) => {}
|
||||||
EventsLost(e) => warn!("lost {} XR events", e.lost_event_count()),
|
EventsLost(e) => warn!("lost {} XR events", e.lost_event_count()),
|
||||||
|
MainSessionVisibilityChangedEXTX(d) => {
|
||||||
|
if let Some(writer) = overlay_writer.as_mut() {
|
||||||
|
writer.send(OxrOverlaySessionEvent::MainSessionVisibilityChanged {
|
||||||
|
visible: d.visible(),
|
||||||
|
flags: d.flags(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
warn!("Overlay Event Recieved without the OverlayPlugin being added!");
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ pub mod graphics;
|
|||||||
pub mod helper_traits;
|
pub mod helper_traits;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
pub mod layer_builder;
|
pub mod layer_builder;
|
||||||
|
pub mod next_chain;
|
||||||
pub mod reference_space;
|
pub mod reference_space;
|
||||||
pub mod render;
|
pub mod render;
|
||||||
pub mod resources;
|
pub mod resources;
|
||||||
pub mod session;
|
pub mod session;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod next_chain;
|
|
||||||
|
|
||||||
pub fn add_xr_plugins<G: PluginGroup>(plugins: G) -> PluginGroupBuilder {
|
pub fn add_xr_plugins<G: PluginGroup>(plugins: G) -> PluginGroupBuilder {
|
||||||
plugins
|
plugins
|
||||||
@@ -49,6 +49,7 @@ pub fn add_xr_plugins<G: PluginGroup>(plugins: G) -> PluginGroupBuilder {
|
|||||||
.add(action_set_attaching::OxrActionAttachingPlugin)
|
.add(action_set_attaching::OxrActionAttachingPlugin)
|
||||||
.add(action_binding::OxrActionBindingPlugin)
|
.add(action_binding::OxrActionBindingPlugin)
|
||||||
.add(action_set_syncing::OxrActionSyncingPlugin)
|
.add(action_set_syncing::OxrActionSyncingPlugin)
|
||||||
|
.add(features::overlay::OxrOverlayPlugin)
|
||||||
// .add(XrActionPlugin)
|
// .add(XrActionPlugin)
|
||||||
// we should probably handle the exiting ourselfs so that we can correctly end the
|
// we should probably handle the exiting ourselfs so that we can correctly end the
|
||||||
// session and instance
|
// session and instance
|
||||||
|
|||||||
Reference in New Issue
Block a user