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;
|
|
|
|
|
2023-04-11 21:50:52 +10:00
|
|
|
fn main() -> Result<(), impl std::error::Error> {
|
2020-09-10 11:58:30 +10:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2023-08-14 05:20:09 +10:00
|
|
|
let event_loop = EventLoop::new().unwrap();
|
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 {
|
2023-08-28 00:15:09 +10:00
|
|
|
Event::WindowEvent { event, window_id } if window_id == window.id() => match event {
|
|
|
|
WindowEvent::CloseRequested => control_flow.set_exit(),
|
|
|
|
WindowEvent::RedrawRequested => {
|
|
|
|
// Notify the windowing system that we'll be presenting to the window.
|
|
|
|
window.pre_present_notify();
|
|
|
|
fill::fill_window(&window);
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
},
|
2023-07-29 02:37:56 +10:00
|
|
|
Event::AboutToWait => {
|
2019-08-27 12:05:42 +10:00
|
|
|
window.request_redraw();
|
|
|
|
}
|
2023-08-28 00:15:09 +10:00
|
|
|
|
2020-01-05 18:12:03 +11:00
|
|
|
_ => (),
|
2015-06-16 21:48:08 +10:00
|
|
|
}
|
2023-04-11 21:50:52 +10:00
|
|
|
})
|
2014-07-27 18:55:37 +10:00
|
|
|
}
|