Forráskód Böngészése

Simulate NTSC timings for Windows desktop display modes

Sam Lantinga 2 éve
szülő
commit
72f0056961
1 módosított fájl, 14 hozzáadás és 1 törlés
  1. 14 1
      src/video/windows/SDL_windowsmodes.c

+ 14 - 1
src/video/windows/SDL_windowsmodes.c

@@ -159,6 +159,19 @@ static SDL_DisplayOrientation WIN_GetDisplayOrientation(DEVMODE *mode)
     }
 }
 
+static float WIN_GetRefreshRate(DEVMODE *mode)
+{
+    /* We're not currently using DXGI to query display modes, so fake NTSC timings */
+    switch (mode->dmDisplayFrequency) {
+    case 119:
+    case 59:
+    case 29:
+        return ((100 * (mode->dmDisplayFrequency + 1) * 1000) / 1001) / 100.0f;
+    default:
+        return (float)mode->dmDisplayFrequency;
+    }
+}
+
 static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *orientation)
 {
     SDL_DisplayModeData *data;
@@ -181,7 +194,7 @@ static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_D
     mode->format = SDL_PIXELFORMAT_UNKNOWN;
     mode->w = data->DeviceMode.dmPelsWidth;
     mode->h = data->DeviceMode.dmPelsHeight;
-    mode->refresh_rate = (float)data->DeviceMode.dmDisplayFrequency;
+    mode->refresh_rate = WIN_GetRefreshRate(&data->DeviceMode);
 
     /* Fill in the mode information */
     WIN_UpdateDisplayMode(_this, deviceName, index, mode);