SDL: Make sure SDL_GL_SetSwapInterval() is only called on the GL path

This commit is contained in:
Henrik Rydgård 2024-09-16 12:01:51 +02:00
parent 62656b6e6f
commit 41b1165dcd
3 changed files with 10 additions and 3 deletions

View File

@ -299,6 +299,13 @@ void EGL_Close() {
#endif // USING_EGL
bool SDLGLGraphicsContext::InitFromRenderThread() {
bool retval = GraphicsContext::InitFromRenderThread();
// HACK: Ensure that the swap interval is set after context creation (needed for kmsdrm)
SDL_GL_SetSwapInterval(1);
return retval;
}
// Returns 0 on success.
int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, int h, int mode, std::string *error_message) {
struct GLVersionPair {
@ -435,6 +442,7 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int w, int h,
INFO_LOG(Log::G3D, "SDL SwapInterval: %d", interval);
SDL_GL_SetSwapInterval(interval);
});
window_ = window;
return 0;
}

View File

@ -16,6 +16,8 @@ public:
// Returns 0 on success.
int Init(SDL_Window *&window, int x, int y, int w, int h, int mode, std::string *error_message);
bool InitFromRenderThread() override;
void Shutdown() override {}
void ShutdownFromRenderThread() override;

View File

@ -1402,9 +1402,6 @@ int main(int argc, char *argv[]) {
SDL_ShowCursor(SDL_DISABLE);
#endif
// Ensure that the swap interval is set after context creation (needed for kmsdrm)
SDL_GL_SetSwapInterval(1);
// Avoid the IME popup when holding keys. This doesn't affect all versions of SDL.
// TODO: Enable it in text input fields
SDL_StopTextInput();