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