summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2006-03-19 00:12:00 +0000
committerSimon Howard2006-03-19 00:12:00 +0000
commite920b33fe51d5f129935ae7d8bfc85bf37263e3d (patch)
tree5dfa6148ab7788cbf893d2bacab3c703a03547c4 /src
parent025459ccb43b0a5a23cbb4453c9a0a1139b0bb2d (diff)
downloadchocolate-doom-e920b33fe51d5f129935ae7d8bfc85bf37263e3d.tar.gz
chocolate-doom-e920b33fe51d5f129935ae7d8bfc85bf37263e3d.tar.bz2
chocolate-doom-e920b33fe51d5f129935ae7d8bfc85bf37263e3d.zip
Smarter fullscreen setting adjustment
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 428
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c100
1 files changed, 64 insertions, 36 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 169efb5b..53e175dd 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 427 2006-03-18 23:42:03Z fraggle $
+// $Id: i_video.c 428 2006-03-19 00:12:00Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -175,7 +175,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_video.c 427 2006-03-18 23:42:03Z fraggle $";
+rcsid[] = "$Id: i_video.c 428 2006-03-19 00:12:00Z fraggle $";
#include <SDL.h>
#include <ctype.h>
@@ -880,14 +880,29 @@ void I_SetWindowIcon(void)
SDL_FreeSurface(surface);
}
-// Check if a screen mode is in the list available
+// Get window dimensions for the current settings
+
+static void GetWindowDimensions(int *windowwidth, int *windowheight)
+{
+ *windowwidth = SCREENWIDTH * screenmultiply;
+
+ if (fullscreen == FULLSCREEN_LETTERBOX)
+ *windowheight = LETTERBOX_SCREENHEIGHT * screenmultiply;
+ else
+ *windowheight = SCREENHEIGHT * screenmultiply;
+}
+
+// Check if the screen mode for the current settings is in the list available
// Not all machines support running in 320x200/640x400 (only support 4:3)
// Some don't even support modes below 640x480.
-static boolean CheckValidFSMode(int w, int h)
+static boolean CheckValidFSMode(void)
{
SDL_Rect **modes;
int i;
+ int w, h;
+
+ GetWindowDimensions(&w, &h);
modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
@@ -902,18 +917,6 @@ static boolean CheckValidFSMode(int w, int h)
return false;
}
-// Get window dimensions for the current settings
-
-static void GetWindowDimensions(int *windowwidth, int *windowheight)
-{
- *windowwidth = SCREENWIDTH * screenmultiply;
-
- if (fullscreen == FULLSCREEN_LETTERBOX)
- *windowheight = LETTERBOX_SCREENHEIGHT * screenmultiply;
- else
- *windowheight = SCREENHEIGHT * screenmultiply;
-}
-
void I_InitGraphics(void)
{
SDL_Event dummy;
@@ -967,45 +970,70 @@ void I_InitGraphics(void)
if (screenmultiply > 2)
screenmultiply = 2;
- GetWindowDimensions(&windowwidth, &windowheight);
-
if (fullscreen)
{
- if (!CheckValidFSMode(windowwidth, windowheight) && screenmultiply == 1)
+ int oldw, oldh;
+ int old_fullscreen, old_screenmultiply;
+
+ GetWindowDimensions(&oldw, &oldh);
+ old_screenmultiply = screenmultiply;
+ old_fullscreen = fullscreen;
+
+ if (!CheckValidFSMode() && screenmultiply == 1
+ && fullscreen == FULLSCREEN_ON)
{
- // This is not a valid video mode. Try doubling up the screen
- // if we are running at 320x200.
+ // 320x200 is not valid.
- printf("I_InitGraphics: Invalid mode %ix%i: turning on "
- "scale x2 mode (screenmultiply=2)\n",
- windowwidth, windowheight);
+ // Try turning on letterbox mode - avoid doubling up
+ // the screen if possible
- screenmultiply = 2;
+ fullscreen = FULLSCREEN_LETTERBOX;
+
+ if (!CheckValidFSMode())
+ {
+ // That doesn't work. Change it back.
- GetWindowDimensions(&windowwidth, &windowheight);
+ fullscreen = FULLSCREEN_ON;
+ }
}
- if (!CheckValidFSMode(windowwidth, windowheight) && fullscreen == 1)
+ if (!CheckValidFSMode() && screenmultiply == 1)
{
- // This is not a valid mode. Try turning on letterbox mode
- // (640x400 -> 640x480)
-
- printf("I_InitGraphics: Invalid mode %ix%i: turning on "
- "letterbox mode (fullscreen=2)\n",
- windowwidth, windowheight);
+ // Try doubling up the screen to 640x400
+
+ screenmultiply = 2;
+ }
- fullscreen = 2;
+ if (!CheckValidFSMode() && fullscreen == FULLSCREEN_ON)
+ {
+ // This is not a valid mode. Try turning on letterbox mode
- GetWindowDimensions(&windowwidth, &windowheight);
+ fullscreen = FULLSCREEN_LETTERBOX;
}
- if (!CheckValidFSMode(windowwidth, windowheight))
+ if (old_fullscreen != fullscreen
+ || old_screenmultiply != screenmultiply)
+ {
+ printf("I_InitGraphics: %ix%i resolution is not supported "
+ "on this machine. \n", oldw, oldh);
+ printf("I_InitGraphics: Video settings adjusted to "
+ "compensate:\n");
+
+ if (fullscreen != old_fullscreen)
+ printf("\tletterbox mode on (fullscreen=2)\n");
+ if (screenmultiply != old_screenmultiply)
+ printf("\tscreenmultiply=%i\n", screenmultiply);
+ }
+
+ if (!CheckValidFSMode())
{
printf("I_InitGraphics: WARNING: Unable to find a valid "
"fullscreen video mode to run in.\n");
}
}
+ GetWindowDimensions(&windowwidth, &windowheight);
+
screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags);
if (screen == NULL)