2015-03-25 13:17:47 +01:00
|
|
|
#[cfg(target_os = "android")]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate android_glue;
|
|
|
|
|
|
|
|
extern crate glutin;
|
|
|
|
|
|
|
|
use glutin::{Event, ElementState};
|
|
|
|
|
|
|
|
mod support;
|
|
|
|
|
|
|
|
#[cfg(target_os = "android")]
|
|
|
|
android_start!(main);
|
|
|
|
|
|
|
|
fn main() {
|
2015-08-05 22:31:34 +02:00
|
|
|
let window = glutin::WindowBuilder::new().build().unwrap();
|
2015-03-25 13:17:47 +01:00
|
|
|
window.set_title("glutin - Cursor grabbing test");
|
2015-09-28 12:19:36 -04:00
|
|
|
let _ = unsafe { window.make_current() };
|
2015-03-25 13:17:47 +01:00
|
|
|
|
|
|
|
let context = support::load(&window);
|
|
|
|
let mut grabbed = false;
|
|
|
|
|
2015-06-16 13:48:08 +02:00
|
|
|
for event in window.poll_events() {
|
|
|
|
match event {
|
|
|
|
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
|
|
|
if grabbed {
|
|
|
|
grabbed = false;
|
|
|
|
window.set_cursor_state(glutin::CursorState::Normal)
|
|
|
|
.ok().expect("could not ungrab mouse cursor");
|
|
|
|
} else {
|
|
|
|
grabbed = true;
|
|
|
|
window.set_cursor_state(glutin::CursorState::Grab)
|
|
|
|
.ok().expect("could not grab mouse cursor");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
a @ Event::MouseMoved(_) => {
|
|
|
|
println!("{:?}", a);
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
|
2015-03-25 13:17:47 +01:00
|
|
|
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
2015-09-28 12:19:36 -04:00
|
|
|
let _ = window.swap_buffers();
|
2015-03-25 13:17:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|