winit-sonoma-fix/examples/fullscreen.rs

56 lines
1.4 KiB
Rust
Raw Normal View History

2014-09-11 18:13:50 +02:00
#![feature(phase)]
#![feature(tuple_indexing)]
2014-09-11 18:13:50 +02:00
#[cfg(target_os = "android")]
#[phase(plugin, link)]
extern crate android_glue;
2014-09-21 11:33:09 +02:00
extern crate glutin;
2014-07-31 09:56:53 +02:00
use std::io::stdio::stdin;
mod support;
2014-09-11 18:13:50 +02:00
#[cfg(target_os = "android")]
android_start!(main)
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")]
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() {
2014-07-31 09:56:53 +02:00
println!("Monitor #{}: {}", num, monitor.get_name());
}
print!("Please write the number of the monitor to use: ");
2014-07-31 10:52:05 +02:00
let num = from_str(stdin().read_line().unwrap().as_slice().trim())
.expect("Plase 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
println!("Using {}", monitor.get_name());
monitor
};
2014-09-21 11:33:09 +02:00
let window = glutin::WindowBuilder::new()
.with_title("Hello world!".to_string())
2014-08-02 11:04:48 +02:00
.with_fullscreen(monitor)
.build()
.unwrap();
2014-07-31 09:56:53 +02:00
unsafe { window.make_current() };
2014-08-07 09:32:13 +02:00
let context = support::load(&window);
2014-07-31 09:56:53 +02:00
while !window.is_closed() {
context.draw_frame((0.0, 1.0, 0.0, 1.0));
2014-07-31 09:56:53 +02:00
window.swap_buffers();
2014-08-07 09:32:13 +02:00
2014-09-21 11:33:09 +02:00
println!("{}", window.wait_events().collect::<Vec<glutin::Event>>());
2014-07-31 09:56:53 +02:00
}
}