From f81a1c82bfc9685f355626fcff38de79b046ed73 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 24 Oct 2023 23:27:35 -0700 Subject: [PATCH] run_event_loop function --- src/setup.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/setup.rs b/src/setup.rs index ddf5614..c119bee 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -232,10 +232,19 @@ impl SetupContextSetup{ let run=crate::run::RunContextSetup::new(&setup_context,window); //the thread that spawns the physics thread - let mut run_thread=run.into_worker(setup_context); + let run_thread=run.into_worker(setup_context); println!("Entering event loop..."); let root_time=std::time::Instant::now(); + run_event_loop(event_loop,run_thread,root_time).unwrap(); + } +} + +fn run_event_loop( + event_loop:winit::event_loop::EventLoop<()>, + mut run_thread:crate::compat_worker::QNWorker>, + root_time:std::time::Instant + )->Result<(),winit::error::EventLoopError>{ event_loop.run(move |event,elwt|{ let time=crate::integer::Time::from_nanos(root_time.elapsed().as_nanos() as i64); // *control_flow=if cfg!(feature="metal-auto-capture"){ @@ -287,6 +296,5 @@ impl SetupContextSetup{ }, _=>{} } - }).unwrap(); - } + }) } \ No newline at end of file