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

[BUG] Framerate limiter always maintains 60 FPS for higher FPS targets #75

Open
beewyka819 opened this issue Jul 29, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@beewyka819
Copy link
Contributor

beewyka819 commented Jul 29, 2022

Describe the bug
On Windows, when enabling the frame limit at application.c:645, it will limit the framerate to approximately 60 FPS even when target_frame_seconds is smaller than 1.0f / 60. For example, when setting target_frame_seconds to 1.0f / 144, printing out 1.0f / delta, which should give the framerate (inverse of period), it will still yield approximately 60 FPS. Interestingly this does not occur for target_frame_seconds greather than 1.0f / 60 (i.e. 1.0f / 30), although the yielded FPS seems to be rather unstable. To be honest I'm having trouble figuring out exactly why this is occurring. The clock logic at least seems correct to me. I wonder if it's due to a technical detail with the Windows Sleep function.

To Reproduce
Steps to reproduce the behavior:

  1. In application.c, switch limit_frames on line 645 to true.
  2. Change target_frame_seconds to a different value (i.e. 1.0f / 144).
  3. Log the frequency each frame (1.0f / delta).
  4. Build and run the program and observe the logged frequency.

Expected behavior
When changing target_frame_seconds to 1.0f / X, then the FPS should attempt to maintain 'X' FPS while the limiter is enabled.

Desktop (please complete the following information):

  • OS: Windows
@beewyka819 beewyka819 added the bug Something isn't working label Jul 29, 2022
@beewyka819
Copy link
Contributor Author

Found a solution to this, it is related to the default accuracy of the windows Sleep function. This accuracy is normally tied to the interrupt ticks (64 per second), but can be adjusted manually with timeBeginPeriod(). Will create a PR that demonstrates the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants