From: Holger Schemel Date: Thu, 3 Sep 2020 23:54:03 +0000 (+0200) Subject: added setting video vsync mode when creating renderer X-Git-Tag: 4.2.0.2~10 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=47593c038f8d8155cbd1722d641c652a486f76bf;p=rocksndiamonds.git added setting video vsync mode when creating renderer Changing the vsync mode after creating the renderer only works for the OpenGL renderer. For all other renderers, it must be set when creating the renderer. This means that changes to the vsync mode settings in the setup menu currently only take effect after restarting the program. --- diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ab914a4e..c7a87297 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -515,6 +515,14 @@ static boolean SDLCreateScreen(boolean fullscreen) #if 1 int renderer_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; + + video.vsync_mode = VSYNC_MODE_OFF; + + if (!strEqual(setup.vsync_mode, STR_VSYNC_MODE_OFF)) + { + renderer_flags |= SDL_RENDERER_PRESENTVSYNC; + video.vsync_mode = VSYNC_MODE_NORMAL; + } #else /* If SDL_CreateRenderer() is called from within a VirtualBox Windows VM _without_ enabling 2D/3D acceleration and/or guest additions installed, @@ -587,6 +595,7 @@ static boolean SDLCreateScreen(boolean fullscreen) // SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setup.window_scaling_quality); + // required for setting adaptive vsync when using OpenGL renderer SDLSetScreenVsyncMode(setup.vsync_mode); sdl_texture_stream = SDL_CreateTexture(sdl_renderer,