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;
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2015-10-24 21:32:46 -04:00
|
|
|
use std::io::{self, Write};
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2014-09-12 08:50:54 +02:00
|
|
|
mod support;
|
|
|
|
|
2014-09-11 18:13:50 +02:00
|
|
|
#[cfg(target_os = "android")]
|
2014-12-19 21:34:20 -08:00
|
|
|
android_start!(main);
|
2014-09-11 18:13:50 +02:00
|
|
|
|
2014-07-31 09:56:53 +02:00
|
|
|
fn main() {
|
|
|
|
// enumerating monitors
|
|
|
|
let monitor = {
|
2014-09-21 11:33:09 +02:00
|
|
|
for (num, monitor) in glutin::get_available_monitors().enumerate() {
|
2015-01-09 23:06:14 +01:00
|
|
|
println!("Monitor #{}: {:?}", num, monitor.get_name());
|
2014-07-31 09:56:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print!("Please write the number of the monitor to use: ");
|
2015-10-24 21:32:46 -04:00
|
|
|
io::stdout().flush().unwrap();
|
2015-04-24 09:25:39 +02:00
|
|
|
|
|
|
|
let mut num = String::new();
|
|
|
|
io::stdin().read_line(&mut num).unwrap();
|
|
|
|
let num = num.trim().parse().ok().expect("Please enter a number");
|
2014-09-21 11:33:09 +02:00
|
|
|
let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID");
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2015-01-09 23:06:14 +01:00
|
|
|
println!("Using {:?}", monitor.get_name());
|
2014-07-31 09:56:53 +02:00
|
|
|
|
|
|
|
monitor
|
|
|
|
};
|
|
|
|
|
2014-09-21 11:33:09 +02:00
|
|
|
let window = glutin::WindowBuilder::new()
|
2014-08-02 08:24:30 +02:00
|
|
|
.with_title("Hello world!".to_string())
|
2014-08-02 11:04:48 +02:00
|
|
|
.with_fullscreen(monitor)
|
2014-08-02 08:24:30 +02:00
|
|
|
.build()
|
|
|
|
.unwrap();
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2015-09-28 12:19:36 -04:00
|
|
|
let _ = unsafe { window.make_current() };
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2014-08-07 09:32:13 +02:00
|
|
|
|
2014-09-12 08:50:54 +02:00
|
|
|
let context = support::load(&window);
|
2014-07-31 09:56:53 +02:00
|
|
|
|
2015-06-16 13:48:08 +02:00
|
|
|
for event in window.wait_events() {
|
2014-09-12 08:50:54 +02:00
|
|
|
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 09:32:13 +02:00
|
|
|
|
2015-06-16 13:48:08 +02:00
|
|
|
println!("{:?}", event);
|
|
|
|
|
|
|
|
match event {
|
|
|
|
glutin::Event::Closed => break,
|
2015-10-24 21:39:13 -04:00
|
|
|
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) => break,
|
2015-06-16 13:48:08 +02:00
|
|
|
_ => ()
|
|
|
|
}
|
2014-07-31 09:56:53 +02:00
|
|
|
}
|
|
|
|
}
|