Skip to content

Commit

Permalink
add back XrGraphicsContext impl
Browse files Browse the repository at this point in the history
now running into

thread '<unnamed>' panicked at 'Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.', C:\Users\kevin\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\android\mod.rs:598:13

perhaps this is related to bevyengine#2432
  • Loading branch information
kcking committed Jan 23, 2022
1 parent b297a05 commit c3d253a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ default = [
"vorbis",
"x11",
"filesystem_watcher",
"bevy_openxr", # todo: remove
"bevy_openxr", # todo: remove
]


Expand Down
25 changes: 12 additions & 13 deletions crates/bevy_openxr/src/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ pub fn create_graphics_context(
.map_err(Box::new)?
};

// let wgpu_instance = unsafe { wgpu::Instance::from_hal::<hal::api::Vulkan>(hal_instance) };
// let wgpu_adapter = unsafe { wgpu_instance.adapter_from_hal(hal_exposed_adapter) };
// let (wgpu_device, wgpu_queue) = unsafe {
// wgpu_adapter
// .device_from_hal(hal_device, &device_descriptor, None)
// .map_err(Box::new)?
// };
let wgpu_instance = unsafe { wgpu::Instance::from_hal::<hal::api::Vulkan>(hal_instance) };
let wgpu_adapter = unsafe { wgpu_instance.create_adapter_from_hal(hal_exposed_adapter) };
let (wgpu_device, wgpu_queue) = unsafe {
wgpu_adapter
.create_device_from_hal(hal_device, &device_descriptor, None)
.map_err(Box::new)?
};

Ok((
GraphicsContextHandles::Vulkan {
Expand All @@ -193,12 +193,11 @@ pub fn create_graphics_context(
queue_family_index,
queue_index,
},
todo!(),
// XrGraphicsContext {
// instance: wgpu_instance,
// device: Arc::new(wgpu_device),
// queue: wgpu_queue,
// },
XrGraphicsContext {
instance: wgpu_instance,
device: Arc::new(wgpu_device),
queue: wgpu_queue,
},
))
} else {
#[cfg(windows)]
Expand Down
10 changes: 5 additions & 5 deletions examples/xr/vr_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use bevy::{
XrReferenceSpaceType, XrSessionMode, XrSystem, XrTrackingSource, XrVibrationEvent,
XrVibrationEventType,
},
DefaultPlugins, PipelinedDefaultPlugins,
DefaultPlugins,
};

#[bevy_main]
fn main() {
App::new()
.add_plugin(XrPlugin)
.add_plugin(OpenXrPlugin)
.add_plugins(PipelinedDefaultPlugins)
.add_plugins(DefaultPlugins)
.add_startup_system(startup)
.add_system(interaction)
.run();
Expand All @@ -42,7 +42,7 @@ fn startup(mut xr_system: ResMut<XrSystem>, mut app_exit_events: EventWriter<App
name: "left_squeeze".into(),
action_type: XrActionType::Scalar,
};
let right_button = XrActionDescriptor {
let right_squeeze = XrActionDescriptor {
name: "right_squeeze".into(),
action_type: XrActionType::Scalar,
};
Expand Down Expand Up @@ -88,7 +88,7 @@ fn interaction(
"right_squeeze".to_owned(),
),
] {
if action_set.button_just_pressed(button) {
if action_set.button_just_pressed(&button) {
// Short haptic click
vibration_events.send(XrVibrationEvent {
hand,
Expand All @@ -99,7 +99,7 @@ fn interaction(
},
});
} else {
let squeeze_value = action_set.scalar_value(squeeze);
let squeeze_value = action_set.scalar_value(&squeeze);
if squeeze_value > 0.0 {
// Low frequency rumble
vibration_events.send(XrVibrationEvent {
Expand Down

0 comments on commit c3d253a

Please sign in to comment.