From 067b4c260fbfe3a6742e3ca877e6309a679713c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Mar 2024 14:44:02 +0100 Subject: [PATCH] handle async vsync fail better a --- src/sdl/ogl_sdl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index a5a1ddb41..71e7fcdab 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -163,7 +163,15 @@ boolean OglSdlSurface(INT32 w, INT32 h) granisotropicmode_cons_t[1].value = maximumAnisotropy; - SDL_GL_SetSwapInterval(cv_vidwait.value ? -1 : 0); + if (cv_vidwait.value) + { + if (SDL_GL_SetSwapInterval(-1) != 0) // try async vsync + SDL_GL_SetSwapInterval(1); // normal vsync + } + else + SDL_GL_SetSwapInterval(0); + + //SDL_GL_SetSwapInterval(cv_vidwait.value ? -1 : 0); // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) @@ -203,7 +211,14 @@ void OglSdlFinishUpdate(boolean waitvbl) int sdlw, sdlh; if (oldwaitvbl != waitvbl) { - SDL_GL_SetSwapInterval(waitvbl ? -1 : 0); + if (waitvbl) + { + if (SDL_GL_SetSwapInterval(-1) != 0) // try async vsync + SDL_GL_SetSwapInterval(1); // normal vsync + } + else + SDL_GL_SetSwapInterval(0); + //SDL_GL_SetSwapInterval(waitvbl ? -1 : 0); } oldwaitvbl = waitvbl;