Beispiel #1
0
void M_ChangeScreenMultipleFactor(void)
{
  V_ChangeScreenResolution();
}
Beispiel #2
0
static void ApplyWindowResize(SDL_Event *resize_event)
{
  int i, k;
  char mode[80];

  int w = MAX(320, resize_event->resize.w);
  int h = MAX(200, resize_event->resize.h);

  if (screen_resolution)
  {
    if (!(SDL_GetModState() & KMOD_SHIFT))
    {
      // Find the biggest screen mode that will fall within these
      // dimensions, falling back to the smallest mode possible if
      // none is found.

      Uint32 flags = SDL_FULLSCREEN;

      if (V_GetMode() == VID_MODEGL)
        flags |= SDL_OPENGL;

      I_ClosestResolution(&w, &h, flags);
    }

    w = MAX(320, w);
    h = MAX(200, h);

    sprintf(mode, "%dx%d", w, h);
    screen_resolution = screen_resolutions_list[0];
    for (i = 0; i < MAX_RESOLUTIONS_COUNT; i++)
    {
      if (screen_resolutions_list[i])
      {
        if (!strcmp(mode, screen_resolutions_list[i]))
        {
          screen_resolution = screen_resolutions_list[i];
          break;
        }
      }
    }

    // custom resolution
    if (screen_resolution == screen_resolutions_list[0])
    {
      if (screen_resolution_lowest &&
          !strcmp(screen_resolution_lowest, screen_resolutions_list[0]))
      {
        // there is no "custom resolution" entry in the list
        for(k = MAX_RESOLUTIONS_COUNT - 1; k > 0; k--)
        {
          screen_resolutions_list[k] = screen_resolutions_list[k - 1];
        }
        // add it
        screen_resolutions_list[0] = strdup(mode);
        screen_resolution = screen_resolutions_list[0];
      }
      else
      {
        union { const char *c; char *s; } u; // type punning via unions
        u.c = screen_resolutions_list[0];
        free(u.s);
        screen_resolutions_list[0] = strdup(mode);
        screen_resolution = screen_resolutions_list[0];
      }
    }

    V_ChangeScreenResolution();

    doom_printf("%dx%d", w, h);
  }
}