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

[rcore] Fix SUPPORT_WINMM_HIGHRES_TIMER for PLATFORM_DESKTOP_SDL #3679

Merged
merged 1 commit into from Dec 28, 2023
Merged

[rcore] Fix SUPPORT_WINMM_HIGHRES_TIMER for PLATFORM_DESKTOP_SDL #3679

merged 1 commit into from Dec 28, 2023

Conversation

ghost
Copy link

@ghost ghost commented Dec 27, 2023

Context

  • During the Christmas holidays a visiting relative was playing a game I've made with my kernel library on his very up-to-date notebook, but there were (low) framerates issues. Upon inspection the issue was the frame sleep time being too long on Windows. The problem was solved with SDL_HINT_TIMER_RESOLUTION which is kind of equivalent to Windows timeBeginPeriod()/timeEndPeriod().

  • Since raylib's PLATFORM_DESKTOP_SDL doesn't use rcore.c's InitTimer() (L3040-L3047), it ends up having the same issue. And since this looks relevant enough, I'm sending this PR.

  • This issue is more noticeable when vsync is turned off and a given frame cap is enforced.

Changes

  1. Adds a SDL_HINT_TIMER_RESOLUTION hint to InitPlatform() (R1430-R1432) for PLATFORM_DESKTOP_SDL to handle the SUPPORT_WINMM_HIGHRES_TIMER option.

  2. This is similar to how PLATFORM_DESKTOP handles it using Windows timeBeginPeriod()/timeEndPeriod() (L66-L70, L3040-L3047, L1590-L1596).

Edits

  • 1: editing, added line marks.

@raysan5 raysan5 merged commit 43b4f90 into raysan5:master Dec 28, 2023
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Dec 28, 2023

@ubkp Great improvement! Thank you very much!

@ghost ghost deleted the fix/sdl-timer branch December 28, 2023 19:33
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 this pull request may close these issues.

1 participant