Browse Source

render: Default to primary display in SDL_CalculateSimulatedVSyncInterval if window is not set

- Fixes previous change to SDL_CreateRendererWithProperties which skipped SDL_CalculateSimulatedVSyncInterval if window was not set.
Sam Lantinga 6 days ago
parent
commit
1cda789a37
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/render/SDL_render.c

+ 2 - 4
src/render/SDL_render.c

@@ -1015,7 +1015,7 @@ static SDL_RenderLineMethod SDL_GetRenderLineMethod(void)
 
 static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Window *window)
 {
-    SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
+    SDL_DisplayID displayID = window ? SDL_GetDisplayForWindow(window) : 0;
     const SDL_DisplayMode *mode;
     int refresh_num, refresh_den;
 
@@ -1232,9 +1232,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
     SDL_SetRenderVSync(renderer, vsync);
 #endif
 
-    if (window) {
-        SDL_CalculateSimulatedVSyncInterval(renderer, window);
-    }
+    SDL_CalculateSimulatedVSyncInterval(renderer, window);
 
     SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
                 "Created renderer: %s", renderer->name);