aboutsummaryrefslogtreecommitdiffstats
path: root/examples/cursor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cursor.rs')
-rw-r--r--examples/cursor.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/examples/cursor.rs b/examples/cursor.rs
index 0dced66..d15deff 100644
--- a/examples/cursor.rs
+++ b/examples/cursor.rs
@@ -17,7 +17,7 @@ fn main() { println!("This example requires glutin to be compiled with the `wind
#[cfg(feature = "window")]
fn main() {
- let mut window = glutin::Window::new().unwrap();
+ let window = glutin::WindowBuilder::new().with_gl_profile(glutin::GlProfile::Compatibility).build().unwrap();
window.set_title("A fantastic window!");
unsafe { window.make_current() };
@@ -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;
- }
- },
- _ => (),
- }
-
- }
-
}
}