From 85b70331fd57727221bda33829491965d0d37a11 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 19 Oct 2023 19:29:32 -0700 Subject: [PATCH] thread load file --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1494a8c..707ebf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,7 +193,12 @@ impl framework::Example for GlobalState { fn update(&mut self, window: &winit::window::Window, device: &wgpu::Device, queue: &wgpu::Queue, event: winit::event::WindowEvent) { let time=integer::Time::from_nanos(self.start_time.elapsed().as_nanos() as i64); match event { - winit::event::WindowEvent::DroppedFile(path) => self.load_file(path,device,queue), + winit::event::WindowEvent::DroppedFile(path)=>{ + std::thread::spawn(move ||{ + let indexed_model_instances=load_file(path); + self.render_thread.send(Instruction::Die(indexed_model_instances)); + }); + }, winit::event::WindowEvent::Focused(state)=>{ //pause unpause //recalculate pressed keys on focus