mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
Add an alternative winit runner that can be started when not on the main thread (#1063)
This commit is contained in:
parent
0a51a26aba
commit
d3d6c35789
1 changed files with 25 additions and 2 deletions
|
@ -22,6 +22,15 @@ use winit::{
|
||||||
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
|
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
))]
|
||||||
|
use winit::platform::unix::EventLoopExtUnix;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WinitPlugin;
|
pub struct WinitPlugin;
|
||||||
|
|
||||||
|
@ -157,8 +166,22 @@ where
|
||||||
panic!("Run return is not supported on this platform!")
|
panic!("Run return is not supported on this platform!")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn winit_runner(mut app: App) {
|
pub fn winit_runner(app: App) {
|
||||||
let mut event_loop = EventLoop::new();
|
winit_runner_with(app, EventLoop::new());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
))]
|
||||||
|
pub fn winit_runner_any_thread(app: App) {
|
||||||
|
winit_runner_with(app, EventLoop::new_any_thread());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn winit_runner_with(mut app: App, mut event_loop: EventLoop<()>) {
|
||||||
let mut create_window_event_reader = EventReader::<CreateWindow>::default();
|
let mut create_window_event_reader = EventReader::<CreateWindow>::default();
|
||||||
let mut app_exit_event_reader = EventReader::<AppExit>::default();
|
let mut app_exit_event_reader = EventReader::<AppExit>::default();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue