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