Merge branch '4-window-does-not-close' into 'dev'

Resolve "Window does not close"

See merge request Steins7/iv!7
This commit is contained in:
Steins7 2021-02-03 09:12:21 +01:00
commit 8e7bfc9cdd
4 changed files with 69 additions and 70 deletions

View File

@ -55,6 +55,7 @@ where
let mut input_keys: Vec<Key> = Vec::new(); let mut input_keys: Vec<Key> = Vec::new();
loop {
for pipeline in &mut self.pipelines { for pipeline in &mut self.pipelines {
for input in &pipeline.inputs { for input in &pipeline.inputs {
match input.borrow().read(Duration::from_millis(1)) { match input.borrow().read(Duration::from_millis(1)) {
@ -75,7 +76,10 @@ where
(((x + y)/2.0)/((1280.0 + 720.0)/2.0)) as f32, (((x + y)/2.0)/((1280.0 + 720.0)/2.0)) as f32,
]; ];
}, },
Key::Close => return, Key::Close => {
info!("Shutting down IV !");
return;
}
_ => (), _ => (),
}; };
} }
@ -111,6 +115,7 @@ where
}; };
} }
} }
}
//These tests are disabled because of some stange issue with cargo not waiting for the drop //These tests are disabled because of some stange issue with cargo not waiting for the drop
//functions to execute before executing the next test or something like that... //functions to execute before executing the next test or something like that...
#[cfg(test)] #[cfg(test)]

View File

@ -90,10 +90,7 @@ pub fn run() -> Result<(), &'static str> {
//running controller //running controller
let mut controller = Controller::new(vec![subengine_pipeline]); let mut controller = Controller::new(vec![subengine_pipeline]);
loop {
//for _i in 0..40 {
controller.run(); controller.run();
}
//let engine_pipelines = vec![ //let engine_pipelines = vec![
// EnginePipeline { // EnginePipeline {

View File

@ -189,11 +189,11 @@ where
//println!("Frame nb : {}", self.frames.len()); //println!("Frame nb : {}", self.frames.len());
//TODO frames number diminish sometimes at resize... //TODO frames number diminish sometimes at resize...
static mut id: i32 = 0; //static mut id: i32 = 0;
let mut frame = self.frames.pop_back().unwrap(); let mut frame = self.frames.pop_back().unwrap();
unsafe { //unsafe {
id = (id+1)%3; // id = (id+1)%3;
} //}
trace!("Waiting for Frame..."); trace!("Waiting for Frame...");
unsafe { unsafe {
@ -214,9 +214,10 @@ where
frame.command_buffer.reset(false); //TODO may be needed at some point... frame.command_buffer.reset(false); //TODO may be needed at some point...
}; };
unsafe { //unsafe {
trace!("Acquiring Frame {}...", id); // trace!("Acquiring Frame {}...", id);
} //}
trace!("Acquiring Frame...");
let image = unsafe { let image = unsafe {
match self.surface.acquire_image(core::u64::MAX) { match self.surface.acquire_image(core::u64::MAX) {
Ok((image, suboptimal)) => { Ok((image, suboptimal)) => {
@ -228,7 +229,7 @@ where
}}; }};
trace!("Creating Framebuffer..."); trace!("Creating Framebuffer...");
let mut framebuffer = unsafe { let framebuffer = unsafe {
use gfx_hal::device::Device; use gfx_hal::device::Device;
use std::borrow::Borrow; use std::borrow::Borrow;
@ -239,15 +240,12 @@ where
.unwrap() //TODO improve that .unwrap() //TODO improve that
}; };
unsafe { //unsafe {
use gfx_hal::{ // use gfx_hal::{device::Device};
device::Device,
command::CommandBuffer,
};
gpu.device() // gpu.device()
.set_framebuffer_name(&mut framebuffer, format!("frambuffer {}", id).as_str()); // .set_framebuffer_name(&mut framebuffer, format!("frambuffer {}", id).as_str());
} //}
frame.link_swapchain_image(gpu, image, framebuffer); frame.link_swapchain_image(gpu, image, framebuffer);

View File

@ -98,10 +98,9 @@ where
} }
pub fn link_swapchain_image(&mut self, pub fn link_swapchain_image(&mut self,
gpu: &Gpu<B>, _gpu: &Gpu<B>, //TODO clear that when framebuffer issue is fixed
image: <B::Surface as PresentationSurface<B>>::SwapchainImage, image: <B::Surface as PresentationSurface<B>>::SwapchainImage,
framebuffer: B::Framebuffer) { framebuffer: B::Framebuffer) {
use gfx_hal::device::Device;
self.framebuffer = Some(framebuffer); self.framebuffer = Some(framebuffer);
//match self.framebuffer.replace(framebuffer) { //match self.framebuffer.replace(framebuffer) {