winit-sonoma-fix/examples/window.rs
2019-06-23 14:38:16 -07:00

30 lines
709 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,
_ => ()
}
});
}