X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=d34feb4cd2b93af6c4319b210a13520313bf669a;hb=2420800e428feaa01663bb5b9fa334b5efe9221b;hp=ab914a4e17c71778fb10b56c050c58f345b48133;hpb=d2245fbf4b1bf52125ad6324df26a9426b29fc77;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ab914a4e..d34feb4c 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, @@ -868,10 +877,7 @@ void SDLSetScreenRenderingMode(char *screen_rendering_mode) void SDLSetScreenVsyncMode(char *vsync_mode) { - int interval = - (strEqual(vsync_mode, STR_VSYNC_MODE_NORMAL) ? VSYNC_MODE_NORMAL : - strEqual(vsync_mode, STR_VSYNC_MODE_ADAPTIVE) ? VSYNC_MODE_ADAPTIVE : - VSYNC_MODE_OFF); + int interval = VSYNC_MODE_STR_TO_INT(vsync_mode); int result = SDL_GL_SetSwapInterval(interval); // if adaptive vsync requested, but not supported, retry with normal vsync