2020-09-09 17:58:30 -08:00
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-21 11:33:15 -04:00
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2014-07-27 10:55:37 +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();
|
2017-01-28 15:01:59 +01:00
|
|
|
|
2019-06-18 11:15:55 -04:00
|
|
|
let window = WindowBuilder::new()
|
2016-11-11 22:08:46 +11:00
|
|
|
.with_title("A fantastic window!")
|
2019-06-19 16:49:43 -04:00
|
|
|
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
|
2019-02-05 10:30:33 -05:00
|
|
|
.build(&event_loop)
|
2016-11-11 22:08:46 +11:00
|
|
|
.unwrap();
|
2014-07-27 10:55:37 +02:00
|
|
|
|
2019-06-18 11:15:55 -04:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2020-01-05 02:12:03 -05:00
|
|
|
*control_flow = ControlFlow::Wait;
|
2015-06-16 13:48:08 +02:00
|
|
|
println!("{:?}", event);
|
|
|
|
|
|
|
|
match event {
|
2019-02-05 10:30:33 -05:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
2019-06-18 11:15:55 -04:00
|
|
|
window_id,
|
|
|
|
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
2019-08-26 22:05:42 -04:00
|
|
|
Event::MainEventsCleared => {
|
|
|
|
window.request_redraw();
|
|
|
|
}
|
2020-01-05 02:12:03 -05:00
|
|
|
_ => (),
|
2015-06-16 13:48:08 +02:00
|
|
|
}
|
2017-01-28 15:01:59 +01:00
|
|
|
});
|
2014-07-27 10:55:37 +02:00
|
|
|
}
|