2022-06-10 13:43:33 +03:00
|
|
|
#![allow(clippy::single_match)]
|
|
|
|
|
2020-09-09 17:58:30 -08:00
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-21 11:33:15 -04:00
|
|
|
use winit::{
|
2020-01-05 02:12:03 -05:00
|
|
|
event::{ElementState, Event, WindowEvent},
|
2022-04-09 18:32:02 -07:00
|
|
|
event_loop::EventLoop,
|
2019-06-21 11:33:15 -04:00
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2019-02-05 10:30:33 -05:00
|
|
|
|
2023-06-19 11:46:38 -07:00
|
|
|
#[path = "util/fill.rs"]
|
|
|
|
mod fill;
|
|
|
|
|
2023-04-11 12:50:52 +01:00
|
|
|
fn main() -> Result<(), impl std::error::Error> {
|
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();
|
|
|
|
|
|
|
|
let window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
2020-01-05 02:12:03 -05:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2023-01-27 07:18:58 +03:00
|
|
|
println!("{event:?}");
|
2020-01-05 02:12:03 -05:00
|
|
|
|
2022-04-09 18:32:02 -07:00
|
|
|
control_flow.set_wait();
|
2020-01-05 02:12:03 -05:00
|
|
|
|
|
|
|
match event {
|
|
|
|
Event::WindowEvent { event, .. } => match event {
|
2022-04-09 18:32:02 -07:00
|
|
|
WindowEvent::CloseRequested => control_flow.set_exit(),
|
2020-01-05 02:12:03 -05:00
|
|
|
WindowEvent::MouseInput {
|
|
|
|
state: ElementState::Released,
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
window.request_redraw();
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
},
|
|
|
|
Event::RedrawRequested(_) => {
|
|
|
|
println!("\nredrawing!\n");
|
2023-06-19 11:46:38 -07:00
|
|
|
fill::fill_window(&window);
|
2020-01-05 02:12:03 -05:00
|
|
|
}
|
|
|
|
_ => (),
|
2019-02-05 10:30:33 -05:00
|
|
|
}
|
2023-04-11 12:50:52 +01:00
|
|
|
})
|
2019-02-05 10:30:33 -05:00
|
|
|
}
|