winit-sonoma-fix/examples/window.rs

38 lines
953 B
Rust
Raw Normal View History

2014-09-11 18:13:50 +02:00
#![feature(phase)]
#[cfg(target_os = "android")]
#[phase(plugin, link)]
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
2014-10-04 19:17:02 +02:00
#[cfg(not(feature = "window"))]
fn main() { println!("This example requires glutin to be compiled with the `window` feature"); }
#[cfg(feature = "window")]
fn resize_callback(width: uint, height: uint) {
println!("Window resized to {}x{}", width, height);
}
2014-10-04 19:17:02 +02:00
#[cfg(feature = "window")]
2014-07-27 10:55:37 +02:00
fn main() {
let mut window = glutin::Window::new().unwrap();
2014-11-10 20:12:32 +11:00
window.set_title("A fantastic window!");
2014-12-23 17:12:29 +01:00
window.set_window_resize_callback(Some(resize_callback as fn(uint, uint)));
2014-07-30 18:12:39 +02:00
unsafe { window.make_current() };
2014-07-27 10:55:37 +02:00
let context = support::load(&window);
2014-07-27 10:55:37 +02:00
2014-07-30 13:29:28 +02:00
while !window.is_closed() {
context.draw_frame((0.0, 1.0, 0.0, 1.0));
2014-07-27 10:55:37 +02:00
window.swap_buffers();
2014-08-07 08:53:21 +02:00
2014-09-21 11:33:09 +02:00
println!("{}", window.wait_events().collect::<Vec<glutin::Event>>());
2014-07-27 10:55:37 +02:00
}
}