gl_vidsdl.c: some cleanup

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@816 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2013-02-21 19:35:21 +00:00
parent ca18412bac
commit 8872f4df63

View file

@ -308,32 +308,31 @@ VID_Restart -- johnfitz -- change video modes on the fly
*/ */
static void VID_Restart (void) static void VID_Restart (void)
{ {
int width, height, bpp;
qboolean fullscreen;
if (vid_locked || !vid_changed) if (vid_locked || !vid_changed)
return; return;
width = (int)vid_width.value;
height = (int)vid_height.value;
bpp = (int)vid_bpp.value;
fullscreen = vid_fullscreen.value ? true : false;
// //
// validate new mode // validate new mode
// //
if (!VID_ValidMode ((int)vid_width.value, if (!VID_ValidMode (width, height, bpp, fullscreen))
(int)vid_height.value,
(int)vid_bpp.value,
vid_fullscreen.value ? true : false))
{ {
Con_Printf ("%dx%dx%d %s is not a valid mode\n", Con_Printf ("%dx%dx%d %s is not a valid mode\n",
(int)vid_width.value, width, height, bpp, fullscreen? "fullscreen" : "windowed");
(int)vid_height.value,
(int)vid_bpp.value,
vid_fullscreen.value ? "fullscreen" : "windowed");
return; return;
} }
// //
// set new mode // set new mode
// //
VID_SetMode ((int)vid_width.value, VID_SetMode (width, height, bpp, fullscreen);
(int)vid_height.value,
(int)vid_bpp.value,
vid_fullscreen.value ? true : false);
GL_Init (); GL_Init ();
TexMgr_ReloadImages (); TexMgr_ReloadImages ();
@ -357,7 +356,7 @@ static void VID_Restart (void)
if (modestate == MS_FULLSCREEN) if (modestate == MS_FULLSCREEN)
IN_Activate(); IN_Activate();
else if (key_dest == key_console || key_dest == key_menu) else if (key_dest == key_console || key_dest == key_menu)
IN_Deactivate(modestate == MS_WINDOWED); IN_Deactivate(true);
} }
/* /*
@ -377,7 +376,7 @@ static void VID_Test (void)
old_width = draw_context->w; old_width = draw_context->w;
old_height = draw_context->h; old_height = draw_context->h;
old_bpp = draw_context->format->BitsPerPixel; old_bpp = draw_context->format->BitsPerPixel;
old_fullscreen = draw_context->flags & SDL_FULLSCREEN; old_fullscreen = draw_context->flags & SDL_FULLSCREEN ? true : false;
VID_Restart (); VID_Restart ();
SCR_UpdateScreen (); SCR_UpdateScreen ();
@ -1152,23 +1151,17 @@ void VID_Toggle (void)
goto vrestart; goto vrestart;
if (SDL_WM_ToggleFullScreen(draw_context) == 1) if (SDL_WM_ToggleFullScreen(draw_context) == 1)
{ {
qboolean was_changed;
Sbar_Changed (); // Sbar seems to need refreshing Sbar_Changed (); // Sbar seems to need refreshing
modestate = draw_context->flags & SDL_FULLSCREEN ? MS_FULLSCREEN : MS_WINDOWED; modestate = draw_context->flags & SDL_FULLSCREEN ? MS_FULLSCREEN : MS_WINDOWED;
// since we succeeded, ignore the vid_fullscreen VID_SyncCvars();
// callback function setting vid_changed to true.
was_changed = vid_changed;
Cvar_SetQuick (&vid_fullscreen, draw_context->flags & SDL_FULLSCREEN ? "1" : "0");
vid_changed = was_changed;
// update mouse grab // update mouse grab
if (modestate == MS_FULLSCREEN) if (modestate == MS_FULLSCREEN)
IN_Activate(); IN_Activate();
else if (key_dest == key_console || key_dest == key_menu) else if (key_dest == key_console || key_dest == key_menu)
IN_Deactivate(modestate == MS_WINDOWED); IN_Deactivate(true);
} }
else else
{ {
@ -1199,6 +1192,8 @@ void VID_SyncCvars (void)
if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == 0) if (SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &swap_control) == 0)
Cvar_SetQuick (&vid_vsync, (swap_control > 0)? "1" : "0"); Cvar_SetQuick (&vid_vsync, (swap_control > 0)? "1" : "0");
} }
vid_changed = false;
} }
//========================================================================== //==========================================================================