Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There's a mistake in the event loop code in the mdbook #1979

Open
NoamDev opened this issue Dec 25, 2021 · 1 comment · Fixed by #2036
Open

There's a mistake in the event loop code in the mdbook #1979

NoamDev opened this issue Dec 25, 2021 · 1 comment · Fixed by #2036

Comments

@NoamDev
Copy link

NoamDev commented Dec 25, 2021

let next_frame_time = std::time::Instant::now() +
std::time::Duration::from_nanos(16_666_667);
*control_flow = glutin::event_loop::ControlFlow::WaitUntil(next_frame_time);
match event {
glutin::event::Event::WindowEvent { event, .. } => match event {
glutin::event::WindowEvent::CloseRequested => {
*control_flow = glutin::event_loop::ControlFlow::Exit;
return;
},
_ => return,
},
glutin::event::Event::NewEvents(cause) => match cause {
glutin::event::StartCause::ResumeTimeReached { .. } => (),
glutin::event::StartCause::Init => (),
_ => return,
},
_ => return,
}

The wait until is reset before checking the event, so in case there was some event before the resume event (usually), the next frame is postponed by 1/60 seconds again and again.

It is possible this mistake is present in other chapters of the mdbook, I do not know.

@est31
Copy link
Collaborator

est31 commented Dec 31, 2021

Good point! Further analysis of the issue and a PR are welcome :). Also don't forget keeping the mdbook itself up to date.

@Melchizedek6809 Melchizedek6809 linked a pull request Apr 8, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants