2022-06-10 20:43:33 +10:00
|
|
|
#![allow(clippy::single_match)]
|
|
|
|
|
2020-09-10 11:58:30 +10:00
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-22 01:33:15 +10:00
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
2022-04-10 11:32:02 +10:00
|
|
|
event_loop::EventLoop,
|
2019-06-22 01:33:15 +10:00
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2014-07-27 18:55:37 +10:00
|
|
|
|
2023-06-20 04:46:38 +10:00
|
|
|
#[path = "util/fill.rs"]
|
|
|
|
mod fill;
|
|
|
|
|
2014-07-27 18:55:37 +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();
|
2017-01-29 01:01:59 +11:00
|
|
|
|
2019-06-19 01:15:55 +10:00
|
|
|
let window = WindowBuilder::new()
|
2016-11-11 22:08:46 +11:00
|
|
|
.with_title("A fantastic window!")
|
2019-06-20 06:49:43 +10:00
|
|
|
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
|
2019-02-06 02:30:33 +11:00
|
|
|
.build(&event_loop)
|
2016-11-11 22:08:46 +11:00
|
|
|
.unwrap();
|
2014-07-27 18:55:37 +10:00
|
|
|
|
2019-06-19 01:15:55 +10:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2022-04-10 11:32:02 +10:00
|
|
|
control_flow.set_wait();
|
2023-01-27 15:18:58 +11:00
|
|
|
println!("{event:?}");
|
2015-06-16 21:48:08 +10:00
|
|
|
|
|
|
|
match event {
|
2019-02-06 02:30:33 +11:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
2019-06-19 01:15:55 +10:00
|
|
|
window_id,
|
2022-04-10 11:32:02 +10:00
|
|
|
} if window_id == window.id() => control_flow.set_exit(),
|
2019-08-27 12:05:42 +10:00
|
|
|
Event::MainEventsCleared => {
|
|
|
|
window.request_redraw();
|
|
|
|
}
|
2023-06-20 04:46:38 +10:00
|
|
|
Event::RedrawRequested(_) => {
|
|
|
|
fill::fill_window(&window);
|
|
|
|
}
|
2020-01-05 18:12:03 +11:00
|
|
|
_ => (),
|
2015-06-16 21:48:08 +10:00
|
|
|
}
|
2017-01-29 01:01:59 +11:00
|
|
|
});
|
2014-07-27 18:55:37 +10:00
|
|
|
}
|