Remove the is_closed function
This commit is contained in:
parent
eb73c2514e
commit
39128dd7e1
17 changed files with 72 additions and 176 deletions
|
|
@ -25,25 +25,22 @@ fn main() {
|
|||
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand, MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text, MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress, MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::NoneCursor, MouseCursor::Cell, MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy, MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing, MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut, MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize, MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize, MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize, MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize, MouseCursor::ColResize, MouseCursor::RowResize];
|
||||
let mut cursor_idx = 0;
|
||||
|
||||
while !window.is_closed() {
|
||||
for event in window.wait_events() {
|
||||
match event {
|
||||
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
||||
println!("Setting cursor to \"{:?}\"", cursors[cursor_idx]);
|
||||
window.set_cursor(cursors[cursor_idx]);
|
||||
if cursor_idx < cursors.len() - 1 {
|
||||
cursor_idx += 1;
|
||||
} else {
|
||||
cursor_idx = 0;
|
||||
}
|
||||
},
|
||||
Event::Closed => break,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers();
|
||||
|
||||
for event in window.wait_events() {
|
||||
match event {
|
||||
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
||||
println!("Setting cursor to \"{:?}\"", cursors[cursor_idx]);
|
||||
window.set_cursor(cursors[cursor_idx]);
|
||||
if cursor_idx < cursors.len() - 1 {
|
||||
cursor_idx += 1;
|
||||
} else {
|
||||
cursor_idx = 0;
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,15 @@ fn main() {
|
|||
|
||||
let context = support::load(&window);
|
||||
|
||||
while !window.is_closed() {
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers();
|
||||
|
||||
println!("{:?}", window.wait_events().next());
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,33 +23,29 @@ fn main() {
|
|||
let context = support::load(&window);
|
||||
let mut grabbed = false;
|
||||
|
||||
while !window.is_closed() {
|
||||
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);
|
||||
},
|
||||
|
||||
_ => (),
|
||||
}
|
||||
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers();
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
_ => (),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,13 @@ fn run(window: glutin::Window, color: (f32, f32, f32, f32)) {
|
|||
|
||||
let context = support::load(&window);
|
||||
|
||||
while !window.is_closed() {
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame(color);
|
||||
window.swap_buffers();
|
||||
|
||||
window.wait_events().next();
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,15 @@ fn main() {
|
|||
|
||||
let context = support::load(&window);
|
||||
|
||||
while !window.is_closed() {
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame((0.0, 0.0, 0.0, 0.0));
|
||||
window.swap_buffers();
|
||||
|
||||
println!("{:?}", window.wait_events().next());
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
#[cfg(target_os = "android")]
|
||||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate clock_ticks;
|
||||
extern crate glutin;
|
||||
|
||||
mod support;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
#[cfg(not(feature = "window"))]
|
||||
fn main() { println!("This example requires glutin to be compiled with the `window` feature"); }
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
fn resize_callback(width: u32, height: u32) {
|
||||
println!("Window resized to {}x{}", width, height);
|
||||
}
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
fn main() {
|
||||
println!("Vsync example. This example may panic if your driver or your system forces \
|
||||
you out of vsync. This is intended when `build_strict` is used.");
|
||||
|
||||
let mut window = glutin::WindowBuilder::new().with_gl_profile(glutin::GlProfile::Compatibility)
|
||||
.with_vsync()
|
||||
.build_strict().unwrap();
|
||||
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
|
||||
unsafe { window.make_current() };
|
||||
|
||||
let context = support::load(&window);
|
||||
|
||||
while !window.is_closed() {
|
||||
let before = clock_ticks::precise_time_ns();
|
||||
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers();
|
||||
|
||||
for ev in window.poll_events() {
|
||||
println!("{:?}", ev);
|
||||
}
|
||||
|
||||
let after = clock_ticks::precise_time_ns();
|
||||
println!("Vsync example - Time of previous frame: {}ms",
|
||||
(after - before) as f32 / 1000000.0);
|
||||
}
|
||||
}
|
||||
|
|
@ -28,10 +28,15 @@ fn main() {
|
|||
|
||||
let context = support::load(&window);
|
||||
|
||||
while !window.is_closed() {
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers();
|
||||
|
||||
println!("{:?}", window.wait_events().next());
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue