Version/Branch of Dear ImGui: Tested on tags v1.68, v1.69, & master branch / v1.70 WIP
Back-ends: imgui_impl_sdl.cpp + imgui_impl_opengl.cpp
Compiler: Clang
Operating System: Windows 10 (w/ latest updates)
My Issue:
On my system, the example_sdl_opengl3 suffers from extreme framerate instability. The framerate oscillates between 55fps and 60fps, with occasional dips to much lower rates causing noticeable hitches in on-screen movement.
After 2 days of debugging, I finally discovered the cause:
The example uses the code SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) to initialize SDL.
Adding the flag SDL_INIT_GAMECONTROLLER to the or'd list fixes it.
As to why this happens, I'm not really sure. It doesn't seem as though your code is using anything to do with game controllers, and my system does not have a game controller connected. This is likely an issue with SDL, but for the sake of having a clean and reliable reference code, it might be a good idea to add this flag, a comment explaining the potential issue, or to simply use SDL_INIT_EVERYTHING.
Additional notes:
If you are using this example code as a base for your own work, it might also be useful to know the following:
SDL_INIT_TIMER seems to be unnecessary. (SDL_GL_SetSwapInterval(1) works fine without it)SDL_DisplayMode is unused and can be removed.Do you think you could file an issue on the SDL bug tracker as well? https://bugzilla.libsdl.org/
Do you think you could file an issue on the SDL bug tracker as well? https://bugzilla.libsdl.org/
Thanks for the link, I went ahead and filed an issue here: https://bugzilla.libsdl.org/show_bug.cgi?id=4588
As additional info, is this on 2.0.9?
Might be related to this: https://discourse.libsdl.org/t/unstable-frame-rate-unexpectedly/25783
As additional info, is this on 2.0.9?
Might be related to this: https://discourse.libsdl.org/t/unstable-frame-rate-unexpectedly/25783
Yes this is on 2.0.9, sorry I should have noted that in the initial post.
I checked out this link and indeed it does seem to be the same issue. I replaced SDL_INIT_GAMECONTROLLER with SDL_INIT_JOYSTICK as is suggested there and that also works for me.
I have removed the unnecessary SDL_DisplayMode code, thanks!
May I suggest fixing this issue by actually implementing gamepad support in imgui_impl_sdl.cpp, which has been missing it? Both imgui_impl_glfw.cpp and imgui_impl_win32.cpp already have gamepad support. The byproduct of this improvement would be that passing the SDL_INIT_GAMECONTROLLER flag in the three main.cpp file wouldn't appear as a workaround anymore!
I would appreciate a SDL gamepad support PR modelled after the existing ones, if anyone is interested in helping with that!
I would appreciate a SDL gamepad support PR modelled after the existing ones, if anyone is interested in helping with that!
I'll take a look and give it a try.
Closing this as #2509 added the INIT_GAME_CONTROLLER flag anyway.
It's a weird issue on SDL's end and worth investigating there.
Thanks for the head up!
Bug is fixed in SDL 2.0.10 anyway :-)
Most helpful comment
I'll take a look and give it a try.