2019-06-22 01:33:15 +10:00
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2014-07-27 18:55:37 +10:00
|
|
|
|
|
|
|
fn main() {
|
2019-02-06 02:30:33 +11:00
|
|
|
let event_loop = EventLoop::new();
|
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-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| {
|
2015-06-16 21:48:08 +10:00
|
|
|
println!("{:?}", event);
|
|
|
|
|
|
|
|
match event {
|
2019-02-06 02:30:33 +11:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
2019-06-19 01:15:55 +10:00
|
|
|
window_id,
|
|
|
|
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
2019-08-27 12:05:42 +10:00
|
|
|
Event::MainEventsCleared => {
|
|
|
|
window.request_redraw();
|
|
|
|
}
|
|
|
|
_ => *control_flow = ControlFlow::Poll,
|
2015-06-16 21:48:08 +10:00
|
|
|
}
|
2017-01-29 01:01:59 +11:00
|
|
|
});
|
2014-07-27 18:55:37 +10:00
|
|
|
}
|