Whitespace.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2002-06-27 18:50:26 +00:00
parent e77d730054
commit 4e467ac8df
2 changed files with 112 additions and 120 deletions

View file

@ -75,9 +75,9 @@ void * (* glGetProcAddress) (const char *symbol) = NULL; // FIXME
// the following is to avoid other compiler errors // the following is to avoid other compiler errors
#ifdef _WIN32 #ifdef _WIN32
void *(*getProcAddress) (HINSTANCE, LPCSTR); void * (* getProcAddress) (HINSTANCE, LPCSTR);
#else #else
void *(*getProcAddress) (void *, const char *); void * (* getProcAddress) (void *, const char *);
#endif #endif
void * void *
@ -237,12 +237,12 @@ VID_Init (unsigned char *palette)
vid.initialized = true; vid.initialized = true;
#ifdef WIN32 #ifdef WIN32
// FIXME: EVIL thing - but needed for win32 until // FIXME: EVIL thing - but needed for win32 until
// SDL_sound works better - without this DirectSound fails. // SDL_sound works better - without this DirectSound fails.
// SDL_GetWMInfo(&info); // SDL_GetWMInfo(&info);
// mainwindow=info.window; // mainwindow=info.window;
mainwindow=GetActiveWindow(); mainwindow=GetActiveWindow();
#endif #endif
vid.recalc_refdef = 1; // force a surface cache flush vid.recalc_refdef = 1; // force a surface cache flush
@ -263,7 +263,8 @@ void
VID_Init_Cvars () VID_Init_Cvars ()
{ {
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE, vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
VID_UpdateFullscreen, "Toggles fullscreen mode"); VID_UpdateFullscreen,
"Toggles fullscreen mode");
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL, vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL,
"Use system gamma control if available"); "Use system gamma control if available");
} }
@ -272,7 +273,7 @@ void
VID_SetCaption (const char *text) VID_SetCaption (const char *text)
{ {
if (text && *text) { if (text && *text) {
char *temp = strdup (text); char *temp = strdup (text);
SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL); SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL);
free (temp); free (temp);

View file

@ -78,19 +78,19 @@ BOOL (GLAPIENTRY *qf_wglMakeCurrent) (HDC, HGLRC);
typedef struct { typedef struct {
modestate_t type; modestate_t type;
int width; int width;
int height; int height;
int modenum; int modenum;
int dib; int dib;
int fullscreen; int fullscreen;
int bpp; int bpp;
int halfscreen; int halfscreen;
char modedesc[17]; char modedesc[17];
} vmode_t; } vmode_t;
typedef struct { typedef struct {
int width; int width;
int height; int height;
} lmode_t; } lmode_t;
lmode_t lowresmodes[] = { lmode_t lowresmodes[] = {
@ -100,9 +100,6 @@ lmode_t lowresmodes[] = {
{512, 384}, {512, 384},
}; };
// FIXME: Only used by MGL ..
qboolean DDActive;
// If you ever merge screen/gl_screen, don't forget this one // If you ever merge screen/gl_screen, don't forget this one
qboolean scr_skipupdate; qboolean scr_skipupdate;
@ -116,17 +113,17 @@ static qboolean windowed, leavecurrentmode;
static int windowed_mouse; static int windowed_mouse;
static HICON hIcon; static HICON hIcon;
RECT WindowRect; RECT WindowRect;
DWORD WindowStyle, ExWindowStyle; DWORD WindowStyle, ExWindowStyle;
HWND mainwindow; HWND mainwindow;
int vid_modenum = NO_MODE; int vid_modenum = NO_MODE;
int vid_realmode; int vid_realmode;
int vid_default = MODE_WINDOWED; int vid_default = MODE_WINDOWED;
static int windowed_default; static int windowed_default;
unsigned char vid_curpal[256 * 3]; unsigned char vid_curpal[256 * 3];
static qboolean fullsbardraw = true; static qboolean fullsbardraw = true;
HDC maindc; HDC maindc;
@ -194,12 +191,12 @@ VID_ForceUnlockedAndReturnState (void)
void void
CenterWindow (HWND hWndCenter, int width, int height, BOOL lefttopjustify) CenterWindow (HWND hWndCenter, int width, int height, BOOL lefttopjustify)
{ {
int CenterX, CenterY; int CenterX, CenterY;
CenterX = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; CenterX = (GetSystemMetrics (SM_CXSCREEN) - width) / 2;
CenterY = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; CenterY = (GetSystemMetrics (SM_CYSCREEN) - height) / 2;
if (CenterX > CenterY * 2) if (CenterX > CenterY * 2)
CenterX >>= 1; // dual screens CenterX >>= 1; // dual screens
CenterX = (CenterX < 0) ? 0 : CenterX; CenterX = (CenterX < 0) ? 0 : CenterX;
CenterY = (CenterY < 0) ? 0 : CenterY; CenterY = (CenterY < 0) ? 0 : CenterY;
SetWindowPos (hWndCenter, NULL, CenterX, CenterY, 0, 0, SetWindowPos (hWndCenter, NULL, CenterX, CenterY, 0, 0,
@ -209,9 +206,9 @@ CenterWindow (HWND hWndCenter, int width, int height, BOOL lefttopjustify)
qboolean qboolean
VID_SetWindowedMode (int modenum) VID_SetWindowedMode (int modenum)
{ {
HDC hdc; HDC hdc;
int lastmodestate, width, height; int lastmodestate, width, height;
RECT rect; RECT rect;
lastmodestate = modestate; lastmodestate = modestate;
@ -242,20 +239,20 @@ VID_SetWindowedMode (int modenum)
// Center and show the window // Center and show the window
CenterWindow (mainwindow, WindowRect.right - WindowRect.left, CenterWindow (mainwindow, WindowRect.right - WindowRect.left,
WindowRect.bottom - WindowRect.top, false); WindowRect.bottom - WindowRect.top, false);
ShowWindow (mainwindow, SW_SHOWDEFAULT); ShowWindow (mainwindow, SW_SHOWDEFAULT);
UpdateWindow (mainwindow); UpdateWindow (mainwindow);
modestate = MS_WINDOWED; modestate = MS_WINDOWED;
// because we have set the background brush for the window to NULL // because we have set the background brush for the window to NULL
// (to avoid flickering when re-sizing the window on the desktop), // (to avoid flickering when re-sizing the window on the desktop),
// we clear the window to black when created, otherwise it will be // we clear the window to black when created, otherwise it will be
// empty while Quake starts up. // empty while Quake starts up.
hdc = GetDC (mainwindow); hdc = GetDC (mainwindow);
PatBlt (hdc, 0, 0, WindowRect.right, WindowRect.bottom, BLACKNESS); PatBlt (hdc, 0, 0, WindowRect.right, WindowRect.bottom, BLACKNESS);
ReleaseDC (mainwindow, hdc); ReleaseDC (mainwindow, hdc);
if (vid.conheight > modelist[modenum].height) if (vid.conheight > modelist[modenum].height)
vid.conheight = modelist[modenum].height; vid.conheight = modelist[modenum].height;
@ -277,11 +274,11 @@ VID_SetWindowedMode (int modenum)
qboolean qboolean
VID_SetFullDIBMode (int modenum) VID_SetFullDIBMode (int modenum)
{ {
HDC hdc; HDC hdc;
int lastmodestate, width, height; int lastmodestate, width, height;
RECT rect; RECT rect;
memset(&win_gdevmode,0,sizeof(win_gdevmode)); memset (&win_gdevmode,0,sizeof(win_gdevmode));
if (!leavecurrentmode) { if (!leavecurrentmode) {
win_gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; win_gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
@ -365,9 +362,9 @@ VID_SetFullDIBMode (int modenum)
int int
VID_SetMode (int modenum, unsigned char *palette) VID_SetMode (int modenum, unsigned char *palette)
{ {
int original_mode, temp; int original_mode, temp;
qboolean stat = 0; qboolean stat = 0;
MSG msg; MSG msg;
if ((windowed && (modenum != 0)) || if ((windowed && (modenum != 0)) ||
(!windowed && (modenum < 1)) || (!windowed && (modenum >= nummodes))) { (!windowed && (modenum < 1)) || (!windowed && (modenum >= nummodes))) {
@ -412,12 +409,13 @@ VID_SetMode (int modenum, unsigned char *palette)
if (!stat) { if (!stat) {
Sys_Error ("Couldn't set video mode"); Sys_Error ("Couldn't set video mode");
} }
// now we try to make sure we get the focus on the mode switch, because
// sometimes in some systems we don't. We grab the foreground, then // Now we try to make sure we get the focus on the mode switch, because
// finish setting up, pump all our messages, and sleep for a little while // sometimes in some systems we don't. We grab the foreground, then
// to let messages finish bouncing around the system, then we put // finish setting up, pump all our messages, and sleep for a little while
// ourselves at the top of the z order, then grab the foreground again, // to let messages finish bouncing around the system, then we put
// Who knows if it helps, but it probably doesn't hurt // ourselves at the top of the z order, then grab the foreground again,
// Who knows if it helps, but it probably doesn't hurt
SetForegroundWindow (mainwindow); SetForegroundWindow (mainwindow);
VID_SetPalette (palette); VID_SetPalette (palette);
vid_modenum = modenum; vid_modenum = modenum;
@ -451,7 +449,6 @@ VID_SetMode (int modenum, unsigned char *palette)
void void
VID_UpdateWindowStatus (int w_x, int w_y) VID_UpdateWindowStatus (int w_x, int w_y)
{ {
window_rect.left = window_x = w_x; window_rect.left = window_x = w_x;
window_rect.top = window_y = w_y; window_rect.top = window_y = w_y;
window_rect.right = window_x + window_width; window_rect.right = window_x + window_width;
@ -510,13 +507,13 @@ VID_SetDefaultMode (void)
void void
VID_Shutdown (void) VID_Shutdown (void)
{ {
HGLRC hRC; HGLRC hRC;
HDC hDC; HDC hDC;
int i, temp[8192]; int i, temp[8192];
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
if(hwnd_dialog) if(hwnd_dialog)
DestroyWindow (hwnd_dialog); DestroyWindow (hwnd_dialog);
#endif #endif
if (vid.initialized) { if (vid.initialized) {
@ -528,20 +525,20 @@ VID_Shutdown (void)
// LordHavoc: free textures before closing (may help NVIDIA) // LordHavoc: free textures before closing (may help NVIDIA)
for (i = 0; i < 8192; i++) for (i = 0; i < 8192; i++)
temp[i] = i + 1; temp[i] = i + 1;
qfglDeleteTextures (8192, temp); qfglDeleteTextures (8192, temp);
if (hRC) if (hRC)
qf_wglDeleteContext (hRC); qf_wglDeleteContext (hRC);
if (hDC && mainwindow) if (hDC && mainwindow)
ReleaseDC (mainwindow, hDC); ReleaseDC (mainwindow, hDC);
if (modestate == MS_FULLDIB) if (modestate == MS_FULLDIB)
ChangeDisplaySettings (NULL, 0); ChangeDisplaySettings (NULL, 0);
if (maindc && mainwindow) if (maindc && mainwindow)
ReleaseDC (mainwindow, maindc); ReleaseDC (mainwindow, maindc);
AppActivate (false, false); AppActivate (false, false);
} }
@ -553,17 +550,18 @@ BOOL
bSetupPixelFormat (HDC hDC) bSetupPixelFormat (HDC hDC)
{ {
PIXELFORMATDESCRIPTOR pfd ; PIXELFORMATDESCRIPTOR pfd ;
int pixelformat; int pixelformat;
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); memset (&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1; pfd.nVersion = 1;
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
PFD_DRAW_TO_WINDOW;
pfd.iPixelType = PFD_TYPE_RGBA; pfd.iPixelType = PFD_TYPE_RGBA;
if (!modelist[vid_default].bpp) pfd.cColorBits = 16; if (!modelist[vid_default].bpp)
else pfd.cColorBits = modelist[vid_default].bpp; pfd.cColorBits = 16;
else
pfd.cColorBits = modelist[vid_default].bpp;
pfd.cDepthBits = 32; pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE; pfd.iLayerType = PFD_MAIN_PLANE;
@ -580,14 +578,13 @@ bSetupPixelFormat (HDC hDC)
return TRUE; return TRUE;
} }
int int
VID_NumModes (void) VID_NumModes (void)
{ {
return nummodes; return nummodes;
} }
vmode_t * vmode_t *
VID_GetModePtr (int modenum) VID_GetModePtr (int modenum)
{ {
if ((modenum >= 0) && (modenum < nummodes)) if ((modenum >= 0) && (modenum < nummodes))
@ -596,12 +593,12 @@ VID_GetModePtr (int modenum)
return &badmode; return &badmode;
} }
char * char *
VID_GetModeDescription (int mode) VID_GetModeDescription (int mode)
{ {
char *pinfo; char *pinfo;
vmode_t *pv; vmode_t *pv;
static char temp[100]; static char temp[100];
if ((mode < 0) || (mode >= nummodes)) if ((mode < 0) || (mode >= nummodes))
return NULL; return NULL;
@ -621,11 +618,11 @@ VID_GetModeDescription (int mode)
// KJB: Added this to return the mode driver name in description for console // KJB: Added this to return the mode driver name in description for console
char * char *
VID_GetExtModeDescription (int mode) VID_GetExtModeDescription (int mode)
{ {
static char pinfo[40]; static char pinfo[40];
vmode_t *pv; vmode_t *pv;
if ((mode < 0) || (mode >= nummodes)) if ((mode < 0) || (mode >= nummodes))
return NULL; return NULL;
@ -667,7 +664,7 @@ VID_NumModes_f (void)
void void
VID_DescribeMode_f (void) VID_DescribeMode_f (void)
{ {
int t, modenum; int t, modenum;
modenum = atoi (Cmd_Argv (1)); modenum = atoi (Cmd_Argv (1));
@ -682,9 +679,9 @@ VID_DescribeMode_f (void)
void void
VID_DescribeModes_f (void) VID_DescribeModes_f (void)
{ {
int i, lnummodes, t; int i, lnummodes, t;
char *pinfo; char *pinfo;
vmode_t *pv; vmode_t *pv;
lnummodes = VID_NumModes (); lnummodes = VID_NumModes ();
@ -703,9 +700,9 @@ VID_DescribeModes_f (void)
void void
VID_InitDIB (HINSTANCE hInstance) VID_InitDIB (HINSTANCE hInstance)
{ {
WNDCLASS wc; WNDCLASS wc;
/* Register the frame class */ // Register the frame class
wc.style = 0; wc.style = 0;
wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
@ -753,10 +750,10 @@ VID_InitDIB (HINSTANCE hInstance)
void void
VID_InitFullDIB (HINSTANCE hInstance) VID_InitFullDIB (HINSTANCE hInstance)
{ {
DEVMODE devmode; DEVMODE devmode;
int i, modenum, originalnummodes, existingmode, numlowresmodes; int i, modenum, originalnummodes, existingmode, numlowresmodes;
int j, bpp, done; int j, bpp, done;
BOOL stat; BOOL stat;
// enumerate >8 bpp modes // enumerate >8 bpp modes
originalnummodes = nummodes; originalnummodes = nummodes;
@ -866,11 +863,9 @@ VID_InitFullDIB (HINSTANCE hInstance)
case 16: case 16:
bpp = 32; bpp = 32;
break; break;
case 32: case 32:
bpp = 24; bpp = 24;
break; break;
case 24: case 24:
done = 1; done = 1;
break; break;
@ -884,12 +879,12 @@ VID_InitFullDIB (HINSTANCE hInstance)
void void
VID_Init (unsigned char *palette) VID_Init (unsigned char *palette)
{ {
int i, existingmode; int i, existingmode;
int basenummodes, width, height=480, bpp, findbpp, done; int basenummodes, width, height=480, bpp, findbpp, done;
HDC hdc; HDC hdc;
DEVMODE devmode; DEVMODE devmode;
HGLRC baseRC; HGLRC baseRC;
DWORD lasterror; DWORD lasterror;
GL_Pre_Init (); GL_Pre_Init ();
@ -984,9 +979,8 @@ VID_Init (unsigned char *palette)
modelist[nummodes].bpp = bpp; modelist[nummodes].bpp = bpp;
snprintf (modelist[nummodes].modedesc, snprintf (modelist[nummodes].modedesc,
sizeof (modelist[nummodes].modedesc), sizeof (modelist[nummodes].modedesc),
"%ldx%ldx%ld", "%ldx%ldx%ld", devmode.dmPelsWidth,
devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmPelsHeight, devmode.dmBitsPerPel);
devmode.dmBitsPerPel);
for (i = nummodes, existingmode = 0; i < nummodes; i++) { for (i = nummodes, existingmode = 0; i < nummodes; i++) {
if ((modelist[nummodes].width == modelist[i].width) && if ((modelist[nummodes].width == modelist[i].width) &&
@ -1006,7 +1000,8 @@ VID_Init (unsigned char *palette)
do { do {
if (COM_CheckParm ("-height")) { if (COM_CheckParm ("-height")) {
height = atoi (com_argv[COM_CheckParm ("-height") + 1]); height = atoi
(com_argv[COM_CheckParm ("-height") + 1]);
for (i = 1, vid_default = 0; i < nummodes; i++) { for (i = 1, vid_default = 0; i < nummodes; i++) {
if ((modelist[i].width == width) && if ((modelist[i].width == width) &&
@ -1082,7 +1077,7 @@ VID_Init (unsigned char *palette)
#ifdef SPLASH_SCREEN #ifdef SPLASH_SCREEN
if(hwnd_dialog) if(hwnd_dialog)
DestroyWindow (hwnd_dialog); DestroyWindow (hwnd_dialog);
#endif #endif
VID_SetMode (vid_default, palette); VID_SetMode (vid_default, palette);
@ -1104,8 +1099,8 @@ VID_Init (unsigned char *palette)
lasterror=GetLastError(); lasterror=GetLastError();
if (baseRC) if (baseRC)
qf_wglDeleteContext (baseRC); qf_wglDeleteContext (baseRC);
if (maindc && mainwindow) if (maindc && mainwindow)
ReleaseDC (mainwindow, maindc); ReleaseDC (mainwindow, maindc);
Sys_Error ("wglMakeCurrent failed (%lx)", lasterror); Sys_Error ("wglMakeCurrent failed (%lx)", lasterror);
} }
@ -1134,9 +1129,9 @@ VID_Init_Cvars ()
// Video menu stuff ====================================== // Video menu stuff ======================================
typedef struct { typedef struct {
int modenum; int modenum;
char *desc; char *desc;
int iscur; int iscur;
} modedesc_t; } modedesc_t;
#define MAX_COLUMN_SIZE 9 #define MAX_COLUMN_SIZE 9
@ -1152,7 +1147,7 @@ VID_SetCaption (const char *text)
char *temp = strdup (text); char *temp = strdup (text);
SetWindowText (mainwindow, SetWindowText (mainwindow,
(LPSTR) va ("%s %s: %s", PROGRAM, VERSION, temp)); (LPSTR) va ("%s %s: %s", PROGRAM, VERSION, temp));
free (temp); free (temp);
} else { } else {
SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION)); SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION));
@ -1165,17 +1160,15 @@ static WORD currentgammaramps[3][256];
qboolean qboolean
VID_SetGamma (double gamma) VID_SetGamma (double gamma)
{ {
int i; int i;
HDC hdc = GetDC (NULL); HDC hdc = GetDC (NULL);
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
currentgammaramps[2][i] = currentgammaramps[2][i] = currentgammaramps[1][i] =
currentgammaramps[1][i] =
currentgammaramps[0][i] = gammatable[i] * 256; currentgammaramps[0][i] = gammatable[i] * 256;
} }
i = SetDeviceGammaRamp (hdc, &currentgammaramps[0][0]); i = SetDeviceGammaRamp (hdc, &currentgammaramps[0][0]);
ReleaseDC (NULL, hdc); ReleaseDC (NULL, hdc);
return i; return i;
} }
@ -1183,19 +1176,17 @@ VID_SetGamma (double gamma)
void void
VID_SaveGamma (void) VID_SaveGamma (void)
{ {
HDC hdc = GetDC (NULL); HDC hdc = GetDC (NULL);
GetDeviceGammaRamp (hdc, &systemgammaramps[0][0]); GetDeviceGammaRamp (hdc, &systemgammaramps[0][0]);
ReleaseDC (NULL, hdc); ReleaseDC (NULL, hdc);
} }
void void
VID_RestoreGamma (void) VID_RestoreGamma (void)
{ {
HDC hdc = GetDC (NULL); HDC hdc = GetDC (NULL);
SetDeviceGammaRamp (hdc, &systemgammaramps[0][0]); SetDeviceGammaRamp (hdc, &systemgammaramps[0][0]);
ReleaseDC (NULL, hdc); ReleaseDC (NULL, hdc);
} }