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

The SDL_GL_SetSwapInterval function in the example_sdl2_opengl3 project sometimes does not work #8396

Open
capp-adocia opened this issue Feb 13, 2025 · 2 comments
Labels

Comments

@capp-adocia
Copy link

Version/Branch of Dear ImGui:

Version v1.91.8, Branch: master

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows10 + MSVC 2019

Full config/build information:

No response

Details:

When I run the example_sdl2_opengl3 project on Windows, I found that when I enabled the vertical synchronization function, that is, set SDL_GL_SetSwapInterval to 1, the frame rate should be limited to the screen refresh rate. Before this, I also tested it on a laptop. This function worked on my laptop and it was limited to 60 frames. But when I changed the device, this SDL_GL_SetSwapInterval function did not work. What is the reason?

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

SDL_GL_SetSwapInterval(1); // Enable vsync
@ocornut
Copy link
Owner

ocornut commented Feb 13, 2025

I believe it may be overridden (globally or per executable) in some drivers settings.
Either way, take note that this is a SDL question, not a Dear ImGui question. I agree that in principle it would be nice if our example apps were more battle-tested for all situations, but it would make them much more complicated too.

@capp-adocia
Copy link
Author

我相信它可能在某些驱动程序设置中被覆盖(全局或每个可执行文件)。 无论如何,请注意这是一个 SDL 问题,而不是 Dear ImGui 问题。我同意,原则上如果我们的示例应用程序在所有情况下都经过更严格的测试,那就太好了,但这也会使它们变得更加复杂。

Thanks for your answer. You mentioned the driver, which is a good direction. I paid special attention to the vertical synchronization option of the local NVIDIA graphics card. When I saw this option, it was turned off. When it was enabled, the frame rate was limited to 60 regardless of whether I used SDL_GL_SetSwapInterval. At this point, I feel that things are somewhat clear. I guess that the priority of the driver configuration item is higher than what I set here. The problem I mentioned before also makes sense, because I disabled vertical synchronization in the driver at the beginning, which made it meaningless whether I turned on SDL_GL_SetSwapInterval or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants