src/SDL_compat.c
changeset 1967 01e29c3e9a29
parent 1965 a788656ca29a
child 1969 5d3724f64f2b
     1.1 --- a/src/SDL_compat.c	Sat Aug 05 17:12:22 2006 +0000
     1.2 +++ b/src/SDL_compat.c	Sat Aug 05 22:34:23 2006 +0000
     1.3 @@ -65,14 +65,15 @@
     1.4  SDL_GetVideoInfo(void)
     1.5  {
     1.6      static SDL_VideoInfo info;
     1.7 +    SDL_DisplayMode mode;
     1.8  
     1.9      /* Memory leak, compatibility code, who cares? */
    1.10 -    if (!info.vfmt && SDL_GetDesktopDisplayMode()) {
    1.11 +    if (!info.vfmt && SDL_GetDesktopDisplayMode(&mode) == 0) {
    1.12          int bpp;
    1.13          Uint32 Rmask, Gmask, Bmask, Amask;
    1.14  
    1.15 -        SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
    1.16 -                                   &Rmask, &Gmask, &Bmask, &Amask);
    1.17 +        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask,
    1.18 +                                   &Amask);
    1.19          info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
    1.20      }
    1.21      return &info;
    1.22 @@ -88,17 +89,20 @@
    1.23      }
    1.24  
    1.25      if (!(flags & SDL_FULLSCREEN)) {
    1.26 -        return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()->format);
    1.27 +        SDL_DisplayMode mode;
    1.28 +        SDL_GetDesktopDisplayMode(&mode);
    1.29 +        return SDL_BITSPERPIXEL(mode.format);
    1.30      }
    1.31  
    1.32      for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
    1.33 -        const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
    1.34 -        if (!mode->w || !mode->h || (width == mode->w && height == mode->h)) {
    1.35 -            if (!mode->format) {
    1.36 +        SDL_DisplayMode mode;
    1.37 +        SDL_GetDisplayMode(i, &mode);
    1.38 +        if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
    1.39 +            if (!mode.format) {
    1.40                  return bpp;
    1.41              }
    1.42 -            if (SDL_BITSPERPIXEL(mode->format) >= (Uint32) bpp) {
    1.43 -                actual_bpp = SDL_BITSPERPIXEL(mode->format);
    1.44 +            if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
    1.45 +                actual_bpp = SDL_BITSPERPIXEL(mode.format);
    1.46              }
    1.47          }
    1.48      }
    1.49 @@ -123,15 +127,16 @@
    1.50      nmodes = 0;
    1.51      modes = NULL;
    1.52      for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
    1.53 -        const SDL_DisplayMode *mode = SDL_GetDisplayMode(i);
    1.54 -        if (!mode->w || !mode->h) {
    1.55 +        SDL_DisplayMode mode;
    1.56 +        SDL_GetDisplayMode(i, &mode);
    1.57 +        if (!mode.w || !mode.h) {
    1.58              return (SDL_Rect **) (-1);
    1.59          }
    1.60 -        if (SDL_BITSPERPIXEL(mode->format) != format->BitsPerPixel) {
    1.61 +        if (SDL_BITSPERPIXEL(mode.format) != format->BitsPerPixel) {
    1.62              continue;
    1.63          }
    1.64 -        if (nmodes > 0 && modes[nmodes - 1]->w == mode->w
    1.65 -            && modes[nmodes - 1]->h == mode->h) {
    1.66 +        if (nmodes > 0 && modes[nmodes - 1]->w == mode.w
    1.67 +            && modes[nmodes - 1]->h == mode.h) {
    1.68              continue;
    1.69          }
    1.70  
    1.71 @@ -145,8 +150,8 @@
    1.72          }
    1.73          modes[nmodes]->x = 0;
    1.74          modes[nmodes]->y = 0;
    1.75 -        modes[nmodes]->w = mode->w;
    1.76 -        modes[nmodes]->h = mode->h;
    1.77 +        modes[nmodes]->w = mode.w;
    1.78 +        modes[nmodes]->h = mode.h;
    1.79          ++nmodes;
    1.80      }
    1.81      if (modes) {
    1.82 @@ -300,16 +305,17 @@
    1.83          }
    1.84      }
    1.85      if (center) {
    1.86 -        const SDL_DisplayMode *current = SDL_GetDesktopDisplayMode();
    1.87 -        *x = (current->w - w) / 2;
    1.88 -        *y = (current->h - h) / 2;
    1.89 +        SDL_DisplayMode mode;
    1.90 +        SDL_GetDesktopDisplayMode(&mode);
    1.91 +        *x = (mode.w - w) / 2;
    1.92 +        *y = (mode.h - h) / 2;
    1.93      }
    1.94  }
    1.95  
    1.96  SDL_Surface *
    1.97  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
    1.98  {
    1.99 -    const SDL_DisplayMode *desktop_mode;
   1.100 +    SDL_DisplayMode desktop_mode;
   1.101      SDL_DisplayMode mode;
   1.102      int window_x = SDL_WINDOWPOS_UNDEFINED;
   1.103      int window_y = SDL_WINDOWPOS_UNDEFINED;
   1.104 @@ -390,8 +396,8 @@
   1.105      }
   1.106  
   1.107      /* Set up the desired display mode */
   1.108 -    desktop_mode = SDL_GetDesktopDisplayMode();
   1.109 -    desktop_format = desktop_mode->format;
   1.110 +    SDL_GetDesktopDisplayMode(&desktop_mode);
   1.111 +    desktop_format = desktop_mode.format;
   1.112      if (desktop_format && ((flags & SDL_ANYFORMAT)
   1.113                             || (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
   1.114          desired_format = desktop_format;