Use ControlFlow:Poll in event loop

ControlFlow::Wait is more efficient but doesn't appear to currently work
well on all platforms. Removed entirely from the earlier examples to
keep them as simple as possible, but noted `ControlFlow::Wait` in the
last example

Closes #542
This commit is contained in:
dbr 2021-10-03 12:20:47 +10:00 committed by Jonathan Spira
parent cfb9a671ec
commit 6eb56529da
4 changed files with 5 additions and 4 deletions

View File

@ -29,7 +29,6 @@ fn main() {
// Standard winit event loop
event_loop.run(move |event, _, control_flow| {
*control_flow = glutin::event_loop::ControlFlow::Wait;
match event {
glutin::event::Event::NewEvents(_) => {
let now = Instant::now();

View File

@ -17,7 +17,6 @@ fn main() {
let mut last_frame = Instant::now();
event_loop.run(move |event, _, control_flow| {
*control_flow = glutin::event_loop::ControlFlow::Wait;
match event {
glutin::event::Event::NewEvents(_) => {
let now = Instant::now();

View File

@ -32,7 +32,6 @@ fn main() {
let mut last_frame = Instant::now();
event_loop.run(move |event, _, control_flow| {
*control_flow = glutin::event_loop::ControlFlow::Wait;
match event {
glutin::event::Event::NewEvents(_) => {
let now = Instant::now();

View File

@ -36,7 +36,11 @@ fn main() {
let mut last_frame = Instant::now();
event_loop.run(move |event, _, control_flow| {
*control_flow = glutin::event_loop::ControlFlow::Wait;
// Note we can potentially make the loop more efficient by
// changing the `Poll` (default) value to `ControlFlow::Poll`
// but be careful to test on all target platforms!
*control_flow = glutin::event_loop::ControlFlow::Poll;
match event {
glutin::event::Event::NewEvents(_) => {
let now = Instant::now();