gl_vidsdl.c: make VID_Restart independent from modelist

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@812 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2013-02-19 19:20:17 +00:00
parent 88b0694432
commit 00a3f7659b

View file

@ -194,6 +194,24 @@ static void VID_Gamma_Init (void)
Cvar_SetCallback (&vid_gamma, VID_Gamma_f); Cvar_SetCallback (&vid_gamma, VID_Gamma_f);
} }
/*
================
VID_ValidMode
================
*/
static qboolean VID_ValidMode (int width, int height, int bpp, qboolean fullscreen)
{
Uint32 flags = SDL_DEFAULT_FLAGS;
if (fullscreen)
flags |= SDL_FULLSCREEN;
if (width < 320 || height < 200 || !SDL_VideoModeOK(width, height, bpp, flags))
return false;
return true;
}
/* /*
================ ================
VID_SetMode VID_SetMode
@ -208,9 +226,6 @@ static int VID_SetMode (int width, int height, int bpp, qboolean fullscreen)
if (fullscreen) if (fullscreen)
flags |= SDL_FULLSCREEN; flags |= SDL_FULLSCREEN;
if (!SDL_VideoModeOK(width, height, bpp, flags))
Sys_Error ("Bad video mode\n");
// so Con_Printfs don't mess us up by forcing vid and snd updates // so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading; temp = scr_disabled_for_loading;
scr_disabled_for_loading = true; scr_disabled_for_loading = true;
@ -277,63 +292,32 @@ VID_Restart -- johnfitz -- change video modes on the fly
*/ */
static void VID_Restart (void) static void VID_Restart (void)
{ {
int i;
if (vid_locked || !vid_changed) if (vid_locked || !vid_changed)
return; return;
// //
// decide which mode to set // validate new mode
// //
if (vid_fullscreen.value) if (!VID_ValidMode ((int)vid_width.value,
(int)vid_height.value,
(int)vid_bpp.value,
vid_fullscreen.value ? true : false))
{ {
for (i = 1; i < nummodes; i++) Con_Printf ("%dx%dx%d %s is not a valid mode\n",
{ (int)vid_width.value,
if (modelist[i].width == (int)vid_width.value && (int)vid_height.value,
modelist[i].height == (int)vid_height.value && (int)vid_bpp.value,
modelist[i].bpp == (int)vid_bpp.value) vid_fullscreen.value ? "fullscreen" : "windowed");
{ return;
break;
}
}
if (i == nummodes)
{
Con_Printf ("%dx%dx%d is not a valid fullscreen mode\n",
(int)vid_width.value,
(int)vid_height.value,
(int)vid_bpp.value);
return;
}
vid_default = i;
} }
else //not fullscreen
{
if (vid_width.value < 320)
{
Con_Printf ("Window width can't be less than 320\n");
return;
}
if (vid_height.value < 200)
{
Con_Printf ("Window height can't be less than 200\n");
return;
}
modelist[0].width = (int)vid_width.value;
modelist[0].height = (int)vid_height.value;
vid_default = 0;
}
// //
// set new mode // set new mode
// //
VID_SetMode (modelist[vid_default].width, VID_SetMode ((int)vid_width.value,
modelist[vid_default].height, (int)vid_height.value,
modelist[vid_default].bpp, (int)vid_bpp.value,
modelist[vid_default].type == MS_FULLSCREEN); vid_fullscreen.value ? true : false);
GL_Init (); GL_Init ();
TexMgr_ReloadImages (); TexMgr_ReloadImages ();