Fixed running on Windows under VMware
authorSam Lantinga <slouken@libsdl.org>
Thu, 14 Jun 2007 06:32:36 +0000
changeset 21199341a884a4d9
parent 2118 238db749017a
child 2120 2c835d58faad
Fixed running on Windows under VMware
src/video/SDL_video.c
src/video/win32/SDL_win32modes.c
     1.1 --- a/src/video/SDL_video.c	Wed Jun 13 08:02:43 2007 +0000
     1.2 +++ b/src/video/SDL_video.c	Thu Jun 14 06:32:36 2007 +0000
     1.3 @@ -1353,9 +1353,14 @@
     1.4  void
     1.5  SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
     1.6  {
     1.7 -    SDL_VideoDisplay *display = &_this->displays[displayIndex];
     1.8 +    SDL_VideoDisplay *display;
     1.9      SDL_RenderDriver *render_drivers;
    1.10  
    1.11 +    if (displayIndex >= _this->num_displays) {
    1.12 +        return;
    1.13 +    }
    1.14 +    display = &_this->displays[displayIndex];
    1.15 +
    1.16      render_drivers =
    1.17          SDL_realloc(display->render_drivers,
    1.18                      (display->num_render_drivers +
     2.1 --- a/src/video/win32/SDL_win32modes.c	Wed Jun 13 08:02:43 2007 +0000
     2.2 +++ b/src/video/win32/SDL_win32modes.c	Thu Jun 14 06:32:36 2007 +0000
     2.3 @@ -110,6 +110,34 @@
     2.4      return SDL_TRUE;
     2.5  }
     2.6  
     2.7 +static void
     2.8 +WIN_AddDisplay(LPTSTR DeviceName)
     2.9 +{
    2.10 +    SDL_VideoDisplay display;
    2.11 +    SDL_DisplayData *displaydata;
    2.12 +    SDL_DisplayMode mode;
    2.13 +
    2.14 +#ifdef DEBUG_MODES
    2.15 +    printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
    2.16 +#endif
    2.17 +    if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
    2.18 +        return;
    2.19 +    }
    2.20 +
    2.21 +    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    2.22 +    if (!displaydata) {
    2.23 +        return;
    2.24 +    }
    2.25 +    SDL_memcpy(displaydata->DeviceName, DeviceName,
    2.26 +               sizeof(displaydata->DeviceName));
    2.27 +
    2.28 +    SDL_zero(display);
    2.29 +    display.desktop_mode = mode;
    2.30 +    display.current_mode = mode;
    2.31 +    display.driverdata = displaydata;
    2.32 +    SDL_AddVideoDisplay(&display);
    2.33 +}
    2.34 +
    2.35  void
    2.36  WIN_InitModes(_THIS)
    2.37  {
    2.38 @@ -132,36 +160,16 @@
    2.39          printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
    2.40  #endif
    2.41          for (j = 0;; ++j) {
    2.42 -            SDL_VideoDisplay display;
    2.43 -            SDL_DisplayData *displaydata;
    2.44 -            SDL_DisplayMode mode;
    2.45 -
    2.46              if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
    2.47                  break;
    2.48              }
    2.49              if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
    2.50                  continue;
    2.51              }
    2.52 -#ifdef DEBUG_MODES
    2.53 -            printf("Monitor: %s\n", WIN_StringToUTF8(device.DeviceName));
    2.54 -#endif
    2.55 -            if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
    2.56 -                break;
    2.57 -            }
    2.58 -
    2.59 -            displaydata =
    2.60 -                (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    2.61 -            if (!displaydata) {
    2.62 -                continue;
    2.63 -            }
    2.64 -            SDL_memcpy(displaydata->DeviceName, DeviceName,
    2.65 -                       sizeof(DeviceName));
    2.66 -
    2.67 -            SDL_zero(display);
    2.68 -            display.desktop_mode = mode;
    2.69 -            display.current_mode = mode;
    2.70 -            display.driverdata = displaydata;
    2.71 -            SDL_AddVideoDisplay(&display);
    2.72 +            WIN_AddDisplay(device.DeviceName);
    2.73 +        }
    2.74 +        if (j == 0) {
    2.75 +            WIN_AddDisplay(DeviceName);
    2.76          }
    2.77      }
    2.78  }