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-07-31 17:56:53 +10:00
|
|
|
|
2015-04-24 17:25:39 +10:00
|
|
|
use std::io;
|
2014-07-31 17:56:53 +10:00
|
|
|
|
2014-09-12 16:50:54 +10:00
|
|
|
mod support;
|
|
|
|
|
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
|
|
|
|
2014-10-05 04:17:02 +11:00
|
|
|
#[cfg(not(feature = "window"))]
|
|
|
|
fn main() { println!("This example requires glutin to be compiled with the `window` feature"); }
|
|
|
|
|
|
|
|
#[cfg(feature = "window")]
|
2014-07-31 17:56:53 +10:00
|
|
|
fn main() {
|
|
|
|
// enumerating monitors
|
|
|
|
let monitor = {
|
2014-09-21 19:33:09 +10:00
|
|
|
for (num, monitor) in glutin::get_available_monitors().enumerate() {
|
2015-01-10 09:06:14 +11:00
|
|
|
println!("Monitor #{}: {:?}", num, monitor.get_name());
|
2014-07-31 17:56:53 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
print!("Please write the number of the monitor to use: ");
|
2015-04-24 17:25:39 +10: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 19:33:09 +10:00
|
|
|
let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID");
|
2014-07-31 17:56:53 +10:00
|
|
|
|
2015-01-10 09:06:14 +11:00
|
|
|
println!("Using {:?}", monitor.get_name());
|
2014-07-31 17:56:53 +10:00
|
|
|
|
|
|
|
monitor
|
|
|
|
};
|
|
|
|
|
2014-09-21 19:33:09 +10:00
|
|
|
let window = glutin::WindowBuilder::new()
|
2014-08-02 16:24:30 +10:00
|
|
|
.with_title("Hello world!".to_string())
|
2014-08-02 19:04:48 +10:00
|
|
|
.with_fullscreen(monitor)
|
2014-08-02 16:24:30 +10:00
|
|
|
.build()
|
|
|
|
.unwrap();
|
2014-07-31 17:56:53 +10:00
|
|
|
|
|
|
|
unsafe { window.make_current() };
|
|
|
|
|
2014-08-07 17:32:13 +10:00
|
|
|
|
2014-09-12 16:50:54 +10:00
|
|
|
let context = support::load(&window);
|
2014-07-31 17:56:53 +10:00
|
|
|
|
|
|
|
while !window.is_closed() {
|
2014-09-12 16:50:54 +10:00
|
|
|
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
2014-07-31 17:56:53 +10:00
|
|
|
window.swap_buffers();
|
2014-08-07 17:32:13 +10:00
|
|
|
|
2015-01-19 23:04:14 +11:00
|
|
|
println!("{:?}", window.wait_events().next());
|
2014-07-31 17:56:53 +10:00
|
|
|
}
|
|
|
|
}
|