winit-sonoma-fix/examples/window.rs
2019-03-09 21:54:29 -05:00

30 lines
741 B
Rust

extern crate winit;
#[macro_use]
extern crate stdweb;
use winit::window::WindowBuilder;
use winit::event::{Event, WindowEvent};
use winit::event_loop::{EventLoop, ControlFlow};
fn main() {
let event_loop = EventLoop::new();
let _window = WindowBuilder::new()
.with_title("A fantastic window!")
.build(&event_loop)
.unwrap();
console!(log, "Built window!");
event_loop.run(|event, _, control_flow| {
console!(log, format!("{:?}", event));
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => *control_flow = ControlFlow::Exit,
_ => *control_flow = ControlFlow::Wait,
}
});
}