removed 'inline' keyword (compilers are better at this today)
[rocksndiamonds.git] / src / libgame / sdl.c
index a794a153ec85f4adba6e3d73a1abac4224269af8..9a7717532e47970827dc679dc546f27873babcc1 100644 (file)
@@ -525,7 +525,7 @@ void SDLInitVideoDisplay(void)
 #endif
 }
 
-inline static void SDLInitVideoBuffer_VideoBuffer(boolean fullscreen)
+static void SDLInitVideoBuffer_VideoBuffer(boolean fullscreen)
 {
   if (program.headless)
     return;
@@ -555,7 +555,7 @@ inline static void SDLInitVideoBuffer_VideoBuffer(boolean fullscreen)
   SDLSetWindowTitle();
 }
 
-inline static void SDLInitVideoBuffer_DrawBuffer(void)
+static void SDLInitVideoBuffer_DrawBuffer(void)
 {
   /* SDL cannot directly draw to the visible video framebuffer like X11,
      but always uses a backbuffer, which is then blitted to the visible
@@ -677,6 +677,8 @@ static boolean SDLCreateScreen(boolean fullscreen)
       // SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
       SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, setup.window_scaling_quality);
 
+      SDLSetScreenVsyncMode(setup.vsync_mode);
+
       sdl_texture_stream = SDL_CreateTexture(sdl_renderer,
                                             SDL_PIXELFORMAT_ARGB8888,
                                             SDL_TEXTUREACCESS_STREAMING,
@@ -1013,6 +1015,21 @@ void SDLSetScreenRenderingMode(char *screen_rendering_mode)
 #endif
 }
 
+void SDLSetScreenVsyncMode(char *vsync_mode)
+{
+#if defined(TARGET_SDL2)
+  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 result = SDL_GL_SetSwapInterval(interval);
+
+  // if adaptive vsync requested, but not supported, retry with normal vsync
+  if (result == -1 && interval == VSYNC_MODE_ADAPTIVE)
+    SDL_GL_SetSwapInterval(VSYNC_MODE_NORMAL);
+#endif
+}
+
 void SDLRedrawWindow(void)
 {
   UpdateScreen_WithoutFrameDelay(NULL);