changeset 2119:9341a884a4d9

Fixed running on Windows under VMware
author Sam Lantinga <slouken@libsdl.org>
date Thu, 14 Jun 2007 06:32:36 +0000
parents 238db749017a
children 2c835d58faad
files src/video/SDL_video.c src/video/win32/SDL_win32modes.c
diffstat 2 files changed, 38 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_video.c	Wed Jun 13 08:02:43 2007 +0000
+++ b/src/video/SDL_video.c	Thu Jun 14 06:32:36 2007 +0000
@@ -1353,9 +1353,14 @@
 void
 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
 {
-    SDL_VideoDisplay *display = &_this->displays[displayIndex];
+    SDL_VideoDisplay *display;
     SDL_RenderDriver *render_drivers;
 
+    if (displayIndex >= _this->num_displays) {
+        return;
+    }
+    display = &_this->displays[displayIndex];
+
     render_drivers =
         SDL_realloc(display->render_drivers,
                     (display->num_render_drivers +
--- a/src/video/win32/SDL_win32modes.c	Wed Jun 13 08:02:43 2007 +0000
+++ b/src/video/win32/SDL_win32modes.c	Thu Jun 14 06:32:36 2007 +0000
@@ -110,6 +110,34 @@
     return SDL_TRUE;
 }
 
+static void
+WIN_AddDisplay(LPTSTR DeviceName)
+{
+    SDL_VideoDisplay display;
+    SDL_DisplayData *displaydata;
+    SDL_DisplayMode mode;
+
+#ifdef DEBUG_MODES
+    printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
+#endif
+    if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
+        return;
+    }
+
+    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
+    if (!displaydata) {
+        return;
+    }
+    SDL_memcpy(displaydata->DeviceName, DeviceName,
+               sizeof(displaydata->DeviceName));
+
+    SDL_zero(display);
+    display.desktop_mode = mode;
+    display.current_mode = mode;
+    display.driverdata = displaydata;
+    SDL_AddVideoDisplay(&display);
+}
+
 void
 WIN_InitModes(_THIS)
 {
@@ -132,36 +160,16 @@
         printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
 #endif
         for (j = 0;; ++j) {
-            SDL_VideoDisplay display;
-            SDL_DisplayData *displaydata;
-            SDL_DisplayMode mode;
-
             if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
                 break;
             }
             if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
                 continue;
             }
-#ifdef DEBUG_MODES
-            printf("Monitor: %s\n", WIN_StringToUTF8(device.DeviceName));
-#endif
-            if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
-                break;
-            }
-
-            displaydata =
-                (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
-            if (!displaydata) {
-                continue;
-            }
-            SDL_memcpy(displaydata->DeviceName, DeviceName,
-                       sizeof(DeviceName));
-
-            SDL_zero(display);
-            display.desktop_mode = mode;
-            display.current_mode = mode;
-            display.driverdata = displaydata;
-            SDL_AddVideoDisplay(&display);
+            WIN_AddDisplay(device.DeviceName);
+        }
+        if (j == 0) {
+            WIN_AddDisplay(DeviceName);
         }
     }
 }