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] uncapped framerate not working properly with SDL platform #3982

Closed
4 tasks done
mpalomas opened this issue May 15, 2024 · 3 comments · Fixed by #3997
Closed
4 tasks done

[rcore] uncapped framerate not working properly with SDL platform #3982

mpalomas opened this issue May 15, 2024 · 3 comments · Fixed by #3997

Comments

@mpalomas
Copy link

mpalomas commented May 15, 2024

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

(this is on latest master commit)

When compiling with the SDL platform, removing/not using SetTargetFPS does not seem to really work: framerate is actually matching the screen refresh rate.

  • Take any example, just remove SetTargetFPS(60)
  • Then right after BeginDrawing(), add DrawFPS(10, 10);

When doing this with the GLFW platform, you basically get unlocked/uncapped framerate: in my case it can be more than 10000-20000 FPS depending on the example.

When doing this exact same thing, but with SDL platform, I get 115-120 FPS, which is really close to my screen refresh rate (120 HZ).

Environment

  • Ubuntu 23.10 x86_64 under Gnome
  • AMD Ryzen 9 7900 + AMD Radeon 5700XT
  • SDL Platform

Issue Screenshot

With GLFW platform
image

With SDL platform
image
image

Code Example

  • Just take for instance textures_image_loading.c
  • Comment out SetTargetFPS
  • Add DrawFPS
  • Build first with GLFW, then with SDL
  • Observe completely different framerate
@mpalomas mpalomas changed the title [core] uncapped framerate not working properly with SDL platform [rcore] uncapped framerate not working properly with SDL platform May 15, 2024
@raysan5
Copy link
Owner

raysan5 commented May 16, 2024

@mpalomas This is strange, could it be that SDL enables VSync by default?

@mpalomas
Copy link
Author

Strange indeed. No expert but I know that when using OpenGL, SDL controls vsync with https://wiki.libsdl.org/SDL2/SDL_GL_SetSwapInterval
As you can see, 0 means immediate, 1 is vsync. Need to look at the platform implementation, will try spend time this evening.

@JupiterRider
Copy link
Contributor

@raysan5 @mpalomas
I found the issue and created a pull request: #3997

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.

3 participants