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

Problem with example_sdl_opengl3 #2484

Closed
noxabellus opened this issue Apr 10, 2019 · 8 comments
Closed

Problem with example_sdl_opengl3 #2484

noxabellus opened this issue Apr 10, 2019 · 8 comments
Labels

Comments

@noxabellus
Copy link

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:

  • The flag SDL_INIT_TIMER seems to be unnecessary. (SDL_GL_SetSwapInterval(1) works fine without it)
  • The code getting the current SDL_DisplayMode is unused and can be removed.
@nicolasnoble
Copy link
Contributor

Do you think you could file an issue on the SDL bug tracker as well? https://bugzilla.libsdl.org/

@noxabellus
Copy link
Author

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

@DJLink
Copy link
Contributor

DJLink commented Apr 11, 2019

As additional info, is this on 2.0.9?
Might be related to this: https://discourse.libsdl.org/t/unstable-frame-rate-unexpectedly/25783

@noxabellus
Copy link
Author

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.

@ocornut
Copy link
Owner

ocornut commented Apr 22, 2019

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!

@DJLink
Copy link
Contributor

DJLink commented Apr 22, 2019

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.

ocornut added a commit that referenced this issue Apr 23, 2019
…asGamepad not being set. Enable in Emscripten demo. Tweaks. (#2509, #2484).
@ocornut
Copy link
Owner

ocornut commented Apr 23, 2019

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!

@ocornut ocornut closed this as completed Apr 23, 2019
@nicolasnoble
Copy link
Contributor

Bug is fixed in SDL 2.0.10 anyway :-)

https://bugzilla.libsdl.org/show_bug.cgi?id=4391

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

4 participants