Skip to content

Commit

Permalink
Fix winit event loop in the triangle example
Browse files Browse the repository at this point in the history
  • Loading branch information
psincf authored Apr 22, 2019
1 parent f5ad767 commit e70b01c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions examples/hello_triangle_rust/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ fn main() {
});

use wgpu::winit::{
ControlFlow, ElementState, Event, EventsLoop, KeyboardInput, VirtualKeyCode, Window,
WindowEvent,
ElementState, Event, EventsLoop, KeyboardInput, VirtualKeyCode, Window, WindowEvent,
};

let mut events_loop = EventsLoop::new();
Expand All @@ -81,9 +80,9 @@ fn main() {
height: size.height.round() as u32,
},
);

events_loop.run_forever(|event| {
match event {
let mut running = true;
while running {
events_loop.poll_events(|event| match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::KeyboardInput {
input:
Expand All @@ -94,14 +93,14 @@ fn main() {
},
..
} => match code {
VirtualKeyCode::Escape => return ControlFlow::Break,
VirtualKeyCode::Escape => running = false,
_ => {}
},
WindowEvent::CloseRequested => return ControlFlow::Break,
WindowEvent::CloseRequested => running = false,
_ => {}
},
_ => {}
}
});

let frame = swap_chain.get_next_texture();
let mut encoder =
Expand All @@ -122,7 +121,5 @@ fn main() {
}

device.get_queue().submit(&[encoder.finish()]);

ControlFlow::Continue
});
}
}

0 comments on commit e70b01c

Please sign in to comment.