2018-04-24 16:20:40 -04:00
|
|
|
use std::collections::HashMap;
|
2020-09-09 17:58:30 -08:00
|
|
|
|
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-21 11:33:15 -04:00
|
|
|
use winit::{
|
|
|
|
event::{ElementState, Event, KeyboardInput, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::Window,
|
|
|
|
};
|
2018-04-24 16:20:40 -04:00
|
|
|
|
2014-08-03 17:23:08 +02:00
|
|
|
fn main() {
|
2020-09-09 17:58:30 -08:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2019-02-05 10:30:33 -05:00
|
|
|
let event_loop = EventLoop::new();
|
2014-08-03 17:23:08 +02:00
|
|
|
|
2018-04-24 16:20:40 -04:00
|
|
|
let mut windows = HashMap::new();
|
|
|
|
for _ in 0..3 {
|
2019-02-05 10:30:33 -05:00
|
|
|
let window = Window::new(&event_loop).unwrap();
|
2018-04-24 16:20:40 -04:00
|
|
|
windows.insert(window.id(), window);
|
|
|
|
}
|
2014-12-23 17:12:29 +01:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
event_loop.run(move |event, event_loop, control_flow| {
|
|
|
|
*control_flow = ControlFlow::Wait;
|
2020-01-05 02:12:03 -05:00
|
|
|
|
2015-06-16 13:48:08 +02:00
|
|
|
match event {
|
2019-02-05 10:30:33 -05:00
|
|
|
Event::WindowEvent { event, window_id } => {
|
|
|
|
match event {
|
|
|
|
WindowEvent::CloseRequested => {
|
|
|
|
println!("Window {:?} has received the signal to close", window_id);
|
2018-04-24 16:20:40 -04:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
// This drops the window, causing it to close.
|
|
|
|
windows.remove(&window_id);
|
2017-01-28 15:45:01 +01:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
if windows.is_empty() {
|
|
|
|
*control_flow = ControlFlow::Exit;
|
|
|
|
}
|
2019-06-24 12:14:55 -04:00
|
|
|
}
|
2019-06-21 11:33:15 -04:00
|
|
|
WindowEvent::KeyboardInput {
|
|
|
|
input:
|
|
|
|
KeyboardInput {
|
|
|
|
state: ElementState::Pressed,
|
|
|
|
..
|
|
|
|
},
|
|
|
|
..
|
|
|
|
} => {
|
2019-02-05 10:30:33 -05:00
|
|
|
let window = Window::new(&event_loop).unwrap();
|
|
|
|
windows.insert(window.id(), window);
|
2019-06-24 12:14:55 -04:00
|
|
|
}
|
2019-06-21 11:33:15 -04:00
|
|
|
_ => (),
|
2017-01-28 15:45:01 +01:00
|
|
|
}
|
2019-06-24 12:14:55 -04:00
|
|
|
}
|
2017-01-28 15:45:01 +01:00
|
|
|
_ => (),
|
2015-06-16 13:48:08 +02:00
|
|
|
}
|
2017-01-28 15:45:01 +01:00
|
|
|
})
|
2014-08-03 17:23:08 +02:00
|
|
|
}
|