vsg::Window event invalid when limited frame rate #1078
Answered
by
robertosfield
Brucewu998
asked this question in
Q&A
-
vsg::Window event will invalid when limited the frame rate in render loop, such as key ("ESC" close) or button(close button) event. The code like:
Anyone idea? |
Beta Was this translation helpful? Give feedback.
Answered by
robertosfield
Jan 23, 2024
Replies: 1 comment 3 replies
-
Your code is very awkward, and you explanation of what might be not working correctly leaves more questions. Could you take a step back and tell us what you are trying to achieve, then we can suggest ways of implementing what you need. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spinlocks are really not something you want in your code except for exceptional circumstances. The simplest way, and most power efficient, would be to add a sleep to the main loop:
If you want to be more sophisticated you could measure how long you have left in the frame after doing all the viewer calls then sleep for the rest of the frame time you have left. You can be conservative with the sleep as vsync will cause the frame to sleep…