summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2006-10-14 14:05:51 +0000
committerSimon Howard2006-10-14 14:05:51 +0000
commit4a81379a448a58feed9668c24be115748d3229db (patch)
treef89f1d64cb1d6daa7f22443f13f0293099df44fc /src
parentbd41935ec4bbd8aa287a870cca8cfd33064665fc (diff)
downloadchocolate-doom-4a81379a448a58feed9668c24be115748d3229db.tar.gz
chocolate-doom-4a81379a448a58feed9668c24be115748d3229db.tar.bz2
chocolate-doom-4a81379a448a58feed9668c24be115748d3229db.zip
Refactor I_InitGraphics.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 701
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c169
1 files changed, 90 insertions, 79 deletions
diff --git a/src/i_video.c b/src/i_video.c
index c67e139e..233ac3ad 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 700 2006-10-14 13:59:28Z fraggle $
+// $Id: i_video.c 701 2006-10-14 14:05:51Z 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 700 2006-10-14 13:59:28Z fraggle $";
+rcsid[] = "$Id: i_video.c 701 2006-10-14 14:05:51Z fraggle $";
#include <SDL.h>
#include <ctype.h>
@@ -265,7 +265,6 @@ int screenmultiply = 1;
// disk image data and background overwritten by the disk to be
// restored by EndRead
-static boolean use_loading_disk;
static byte *disk_image = NULL;
static int disk_image_w, disk_image_h;
static byte *saved_background;
@@ -337,6 +336,18 @@ static void LoadDiskImage(void)
{
patch_t *disk;
int y;
+ char buf[20];
+
+ SDL_VideoDriverName(buf, 15);
+
+ if (!strcmp(buf, "Quartz"))
+ {
+ // MacOS Quartz gives us pageflipped graphics that screw up the
+ // display when we use the loading disk. Disable it.
+ // This is a gross hack.
+
+ return;
+ }
if (M_CheckParm("-cdrom") > 0)
disk = (patch_t *) W_CacheLumpName(DEH_String("STCDROM"), PU_STATIC);
@@ -1051,14 +1062,8 @@ static boolean CheckValidFSMode(void)
return false;
}
-void I_InitGraphics(void)
+static void CheckCommandLine(void)
{
- SDL_Event dummy;
- char buf[20];
- int flags = 0;
-
- SDL_Init(SDL_INIT_VIDEO);
-
// mouse grabbing
if (M_CheckParm("-grabmouse"))
@@ -1107,72 +1112,92 @@ void I_InitGraphics(void)
screenmultiply = 1;
if (screenmultiply > 4)
screenmultiply = 4;
+}
- if (fullscreen && autoadjust_video_settings)
- {
- int oldw, oldh;
- int old_fullscreen, old_screenmultiply;
+static void AutoAdjustSettings(void)
+{
+ int oldw, oldh;
+ int old_fullscreen, old_screenmultiply;
- GetWindowDimensions(&oldw, &oldh);
- old_screenmultiply = screenmultiply;
- old_fullscreen = fullscreen;
+ GetWindowDimensions(&oldw, &oldh);
+ old_screenmultiply = screenmultiply;
+ old_fullscreen = fullscreen;
- if (!CheckValidFSMode() && screenmultiply == 1
- && fullscreen == FULLSCREEN_ON)
- {
- // 320x200 is not valid.
+ if (!CheckValidFSMode() && screenmultiply == 1
+ && fullscreen == FULLSCREEN_ON)
+ {
+ // 320x200 is not valid.
- // Try turning on letterbox mode - avoid doubling up
- // the screen if possible
+ // Try turning on letterbox mode - avoid doubling up
+ // the screen if possible
- fullscreen = FULLSCREEN_LETTERBOX;
+ fullscreen = FULLSCREEN_LETTERBOX;
- if (!CheckValidFSMode())
- {
- // That doesn't work. Change it back.
+ if (!CheckValidFSMode())
+ {
+ // That doesn't work. Change it back.
- fullscreen = FULLSCREEN_ON;
- }
+ fullscreen = FULLSCREEN_ON;
}
+ }
- if (!CheckValidFSMode() && screenmultiply == 1)
- {
- // Try doubling up the screen to 640x400
+ if (!CheckValidFSMode() && screenmultiply == 1)
+ {
+ // Try doubling up the screen to 640x400
- screenmultiply = 2;
- }
+ screenmultiply = 2;
+ }
- if (!CheckValidFSMode() && fullscreen == FULLSCREEN_ON)
- {
- // This is not a valid mode. Try turning on letterbox mode
+ if (!CheckValidFSMode() && fullscreen == FULLSCREEN_ON)
+ {
+ // This is not a valid mode. Try turning on letterbox mode
- fullscreen = FULLSCREEN_LETTERBOX;
- }
+ fullscreen = FULLSCREEN_LETTERBOX;
+ }
- 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);
-
- printf("NOTE: Your video settings have been adjusted. "
- "To disable this behavior,\n"
- "set autoadjust_video_settings to 0 in your "
- "configuration file.\n");
- }
+ 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 (!CheckValidFSMode())
- {
- printf("I_InitGraphics: WARNING: Unable to find a valid "
- "fullscreen video mode to run in.\n");
- }
+ if (fullscreen != old_fullscreen)
+ printf("\tletterbox mode on (fullscreen=2)\n");
+ if (screenmultiply != old_screenmultiply)
+ printf("\tscreenmultiply=%i\n", screenmultiply);
+
+ printf("NOTE: Your video settings have been adjusted. "
+ "To disable this behavior,\n"
+ "set autoadjust_video_settings to 0 in your "
+ "configuration file.\n");
+ }
+
+ if (!CheckValidFSMode())
+ {
+ printf("I_InitGraphics: WARNING: Unable to find a valid "
+ "fullscreen video mode to run in.\n");
+ }
+}
+
+void I_InitGraphics(void)
+{
+ SDL_Event dummy;
+ int flags = 0;
+
+ SDL_Init(SDL_INIT_VIDEO);
+
+ // Check for command-line video-related parameters.
+
+ CheckCommandLine();
+
+ if (fullscreen && autoadjust_video_settings)
+ {
+ // Check that the fullscreen mode we are trying to use is valid;
+ // if not, try to automatically select a more appropriate one.
+
+ AutoAdjustSettings();
}
GetWindowDimensions(&windowwidth, &windowheight);
@@ -1256,25 +1281,11 @@ void I_InitGraphics(void)
screens[0] = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
}
- use_loading_disk = true;
-
- SDL_VideoDriverName(buf, 15);
-
- if (!strcmp(buf, "Quartz"))
- {
- // MacOS Quartz gives us pageflipped graphics that screw up the
- // display when we use the loading disk. Disable it.
- // This is a gross hack.
-
- use_loading_disk = false;
- }
-
// "Loading from disk" icon
- if (use_loading_disk)
- {
- LoadDiskImage();
- }
+ LoadDiskImage();
+
+ // Clear the screen to black.
memset(screens[0], 0, SCREENWIDTH * SCREENHEIGHT);