Skip to content

How to limit frame rate and CPU usage without using RedrawEventsCleared? #3377

Closed Answered by kchibisov
maokwen asked this question in Q&A
Discussion options

You must be logged in to vote

WaitUntil works exactly as it should, it waits until the deadline or a new event, which is redraw requested.

To do what you want I'd suggest to register some Instant, then compute the future timestamps based on the target frame-rate you have, then you do WaitUntil and in a new events you compare the current time with the next timeout, and if's later you schedule the redraw via the redraw_requested. In the RedrawRequsted itself you don't ask for redraw, since that's not what you want, however you set the WaitUntil to the next timestamp.

In the end you'll render at the target frame rate, since you start rendering at the start of each timestamp. You may still not render at the start of each …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kchibisov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants