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