winit-sonoma-fix/examples/window.rs

38 lines
904 B
Rust
Raw Normal View History

2014-09-11 18:13:50 +02:00
#[cfg(target_os = "android")]
2015-01-08 09:28:22 +01:00
#[macro_use]
2014-09-11 18:13:50 +02:00
extern crate android_glue;
2014-09-21 11:33:09 +02:00
extern crate glutin;
mod support;
2014-07-27 10:55:37 +02:00
2014-09-11 18:13:50 +02:00
#[cfg(target_os = "android")]
android_start!(main);
2014-09-11 18:13:50 +02:00
fn resize_callback(width: u32, height: u32) {
println!("Window resized to {}x{}", width, height);
}
2014-07-27 10:55:37 +02:00
fn main() {
2015-08-05 22:31:34 +02:00
let mut window = glutin::WindowBuilder::new().build().unwrap();
2014-11-10 20:12:32 +11:00
window.set_title("A fantastic window!");
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
2015-09-28 12:19:36 -04:00
let _ = unsafe { window.make_current() };
2014-07-27 10:55:37 +02:00
println!("Pixel format of the window: {:?}", window.get_pixel_format());
let context = support::load(&window);
2014-07-27 10:55:37 +02:00
2015-06-16 13:48:08 +02:00
for event in window.wait_events() {
context.draw_frame((0.0, 1.0, 0.0, 1.0));
2015-09-28 12:19:36 -04:00
let _ = window.swap_buffers();
2014-08-07 08:53:21 +02:00
2015-06-16 13:48:08 +02:00
println!("{:?}", event);
match event {
glutin::Event::Closed => break,
_ => ()
}
2014-07-27 10:55:37 +02:00
}
}