2016-03-27 04:07:52 +11:00
|
|
|
extern crate winit;
|
2014-07-31 17:56:53 +10:00
|
|
|
|
2015-10-25 12:32:46 +11:00
|
|
|
use std::io::{self, Write};
|
2014-07-31 17:56:53 +10:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// enumerating monitors
|
|
|
|
let monitor = {
|
2016-03-27 04:07:52 +11:00
|
|
|
for (num, monitor) in winit::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-10-25 12:32:46 +11:00
|
|
|
io::stdout().flush().unwrap();
|
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");
|
2016-03-27 04:07:52 +11:00
|
|
|
let monitor = winit::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
|
|
|
|
};
|
|
|
|
|
2016-03-27 04:07:52 +11:00
|
|
|
let window = winit::WindowBuilder::new()
|
2016-05-08 17:28:42 +10:00
|
|
|
.with_title("Hello world!")
|
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
|
|
|
|
2015-06-16 21:48:08 +10:00
|
|
|
for event in window.wait_events() {
|
|
|
|
println!("{:?}", event);
|
|
|
|
|
|
|
|
match event {
|
2016-03-27 04:07:52 +11:00
|
|
|
winit::Event::Closed => break,
|
|
|
|
winit::Event::KeyboardInput(_, _, Some(winit::VirtualKeyCode::Escape)) => break,
|
2015-06-16 21:48:08 +10:00
|
|
|
_ => ()
|
|
|
|
}
|
2014-07-31 17:56:53 +10:00
|
|
|
}
|
|
|
|
}
|