2019-07-11 00:54:54 +02:00
|
|
|
use instant::Instant;
|
|
|
|
use std::time::Duration;
|
2019-02-05 10:30:33 -05:00
|
|
|
|
2019-06-21 11:33:15 -04:00
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2019-02-05 10:30:33 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
|
|
|
let window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
2019-07-09 00:22:10 -04:00
|
|
|
event_loop.run(move |event, _, control_flow| match event {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
} => *control_flow = ControlFlow::Exit,
|
2019-07-30 23:31:12 -07:00
|
|
|
Event::MainEventsCleared => {
|
2019-07-09 00:22:10 -04:00
|
|
|
window.request_redraw();
|
|
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0))
|
|
|
|
}
|
2019-07-30 23:31:12 -07:00
|
|
|
Event::RedrawRequested(_) => {
|
2019-07-09 00:22:10 -04:00
|
|
|
println!("{:?}", event);
|
2019-02-05 10:30:33 -05:00
|
|
|
}
|
2019-07-09 00:22:10 -04:00
|
|
|
_ => (),
|
2019-02-05 10:30:33 -05:00
|
|
|
});
|
|
|
|
}
|