gl_vidsdl.c fixes/changes from Sander van Dijk: if (hypothetically) no

fullscreen modes are reported at all fixes bad behaviour of several
options in the video menu, and allows the user to use "-force" to force
a fullscreen mode even if none was reported; this was previously only
possible if there was at least one fullscreen mode reported), makes the
treatment of "-current" more similar to "-width/-height/-bpp" (only
forcing it if the user provides "-force"), gets rid of leavecurrentmode
hack (which didn't do much useful, besides making the code less clear).

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@534 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2011-12-22 21:55:48 +00:00
parent b7ee9177d0
commit 1089ae52a2

View file

@ -77,7 +77,7 @@ static int nummodes;
static vmode_t badmode;
static qboolean vid_initialized = false;
static qboolean windowed, leavecurrentmode;
static qboolean windowed;
static qboolean vid_canalttab = false;
static qboolean vid_toggle_works = true;
extern qboolean mouseactive; // from in_win.c
@ -901,24 +901,12 @@ const char *VID_GetModeDescription (int mode)
{
const char *pinfo;
vmode_t *pv;
static char temp[100];
if ((mode < 0) || (mode >= nummodes))
return NULL;
if (!leavecurrentmode)
{
pv = VID_GetModePtr (mode);
pinfo = pv->modedesc;
}
else
{
sprintf (temp, "Desktop resolution (%ix%ix%i)", //johnfitz -- added bpp
modelist[MODE_FULLSCREEN_DEFAULT].width,
modelist[MODE_FULLSCREEN_DEFAULT].height,
modelist[MODE_FULLSCREEN_DEFAULT].bpp); //johnfitz -- added bpp
pinfo = temp;
}
return pinfo;
}
@ -939,20 +927,10 @@ const char *VID_GetExtModeDescription (int mode)
pv = VID_GetModePtr (mode);
if (modelist[mode].type == MODE_FULLSCREEN_DEFAULT)
{
if (!leavecurrentmode)
{
sprintf(pinfo,"%s fullscreen", pv->modedesc);
}
else
{
sprintf (pinfo, "Desktop resolution (%ix%ix%i)", //johnfitz -- added bpp
modelist[MODE_FULLSCREEN_DEFAULT].width,
modelist[MODE_FULLSCREEN_DEFAULT].height,
modelist[MODE_FULLSCREEN_DEFAULT].bpp); //johnfitz -- added bpp
}
}
else
{
if (modestate == MODE_WINDOWED)
sprintf(pinfo, "%s windowed", pv->modedesc);
@ -980,14 +958,12 @@ VID_DescribeModes_f -- johnfitz -- changed formatting, and added refresh rates a
*/
void VID_DescribeModes_f (void)
{
int i, lnummodes, t;
int i, lnummodes;
vmode_t *pv;
int lastwidth, lastheight, lastbpp, count;
lnummodes = VID_NumModes ();
t = leavecurrentmode;
leavecurrentmode = 0;
lastwidth = lastheight = lastbpp = count = 0;
for (i = 1; i < lnummodes; i++)
@ -1005,8 +981,6 @@ void VID_DescribeModes_f (void)
}
}
Con_Printf ("\n%i modes\n", count);
leavecurrentmode = t;
}
//==========================================================================
@ -1201,7 +1175,6 @@ void VID_Init (void)
CFG_ReadCvarOverrides(read_vars, num_readvars);
VID_InitDIB();
nummodes = 1;
VID_InitFullDIB();
if (COM_CheckParm("-window") || COM_CheckParm("-w"))
@ -1220,32 +1193,22 @@ void VID_Init (void)
}
else
{
if (nummodes == 1)
Sys_Error ("No RGB fullscreen modes available");
windowed = false;
vid_default = NO_MODE;
width = vid_width.value;
height = vid_height.value;
bpp = vid_bpp.value;
p = COM_CheckParm("-mode");
if (p && p < com_argc-1)
{
vid_default = Q_atoi(com_argv[p+1]);
}
else
{
if (COM_CheckParm("-current"))
{
info = SDL_GetVideoInfo();
modelist[MODE_FULLSCREEN_DEFAULT].width = info->current_w;
modelist[MODE_FULLSCREEN_DEFAULT].height = info->current_h;
modelist[MODE_FULLSCREEN_DEFAULT].bpp = info->vfmt->BitsPerPixel;
vid_default = MODE_FULLSCREEN_DEFAULT;
leavecurrentmode = 1;
width = info->current_w;
height = info->current_h;
bpp = info->vfmt->BitsPerPixel;
}
else
{
width = vid_width.value;
height = vid_height.value;
p = COM_CheckParm("-width");
if (p && p < com_argc-1)
{
@ -1267,8 +1230,7 @@ void VID_Init (void)
p = COM_CheckParm("-bpp");
if (p && p < com_argc-1)
bpp = Q_atoi(com_argv[p+1]);
else
bpp = vid_bpp.value;
}
// if they want to force it, add the specified mode to the list
if (COM_CheckParm("-force") && (nummodes < MAX_MODE_LIST))
@ -1303,9 +1265,17 @@ void VID_Init (void)
}
}
vid_default = 0;
p = COM_CheckParm("-mode");
if (p && p < com_argc-1)
{
i = Q_atoi(com_argv[p+1]);
if (i > 0 && i < nummodes)
vid_default = i;
}
// Try to find a mode with matching width, height and bpp
if (vid_default == NO_MODE)
{
for (i = 1; i < nummodes; i++)
{
if ((modelist[i].width == width) &&
@ -1316,9 +1286,10 @@ void VID_Init (void)
break;
}
}
}
// Try to find a mode with matching width and height
if (!vid_default)
if (vid_default == NO_MODE)
{
for (i = 1; i < nummodes; i++)
{
@ -1332,7 +1303,7 @@ void VID_Init (void)
}
// Try to find a mode with matching width
if (!vid_default)
if (vid_default == NO_MODE)
{
for (i = 1; i < nummodes; i++)
{
@ -1345,15 +1316,13 @@ void VID_Init (void)
}
// Still no luck? Default to windowed mode
if (!vid_default)
if (vid_default == NO_MODE)
{
Cvar_Set ("vid_fullscreen", "0");
windowed = true;
vid_default = MODE_WINDOWED;
}
}
}
}
vid_initialized = true;
@ -1553,6 +1522,8 @@ void VID_Menu_ChooseNextMode (int dir)
{
int i;
if (vid_menu_nummodes)
{
for (i = 0; i < vid_menu_nummodes; i++)
{
if (vid_menu_modes[i].width == vid_width.value &&
@ -1577,6 +1548,7 @@ void VID_Menu_ChooseNextMode (int dir)
Cvar_SetValue ("vid_height",(float)vid_menu_modes[i].height);
VID_Menu_RebuildBppList ();
}
}
/*
================
@ -1589,6 +1561,8 @@ void VID_Menu_ChooseNextBpp (int dir)
{
int i;
if (vid_menu_numbpps)
{
for (i = 0; i < vid_menu_numbpps; i++)
{
if (vid_menu_bpps[i] == vid_bpp.value)
@ -1610,6 +1584,7 @@ void VID_Menu_ChooseNextBpp (int dir)
Cvar_SetValue ("vid_bpp",(float)vid_menu_bpps[i]);
}
}
/*
================
@ -1623,6 +1598,8 @@ void VID_Menu_ChooseNextRate (int dir)
#if 0 /* not implemented for SDL */
int i;
if (vid_menu_numrates)
{
for (i = 0; i < vid_menu_numrates; i++)
{
if (vid_menu_rates[i] == vid_refreshrate.value)
@ -1643,6 +1620,7 @@ void VID_Menu_ChooseNextRate (int dir)
}
Cvar_SetValue ("vid_refreshrate",(float)vid_menu_rates[i]);
}
#endif
}