Fix fullscreen switch on Alt-Enter

Switching to fullscreen through a SDL2 call is nice, but the renderer
needs to be reinitialized. Without it some things will break, for
example the gamma setting.
This commit is contained in:
Yamagi Burmeister 2015-03-30 20:53:08 +02:00
parent 06834d1fb5
commit 02156e03ec
3 changed files with 21 additions and 32 deletions

View file

@ -510,7 +510,13 @@ GLimp_InitGraphics(qboolean fullscreen)
/* If we want fullscreen, but aren't */ /* If we want fullscreen, but aren't */
if (fullscreen != IsFullscreen()) if (fullscreen != IsFullscreen())
{ {
GLimp_ToggleFullscreen(); #if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_SetWindowFullscreen(window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
#else
SDL_WM_ToggleFullScreen(window);
#endif
Cvar_SetValue("vid_fullscreen", fullscreen);
} }
/* Are we now? */ /* Are we now? */
@ -705,31 +711,6 @@ GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen)
return rserr_ok; return rserr_ok;
} }
/*
* Toggle fullscreen.
*/
void GLimp_ToggleFullscreen(void)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
int wantFullscreen = !IsFullscreen();
SDL_SetWindowFullscreen(window, wantFullscreen ? SDL_WINDOW_FULLSCREEN : 0);
Cvar_SetValue("vid_fullscreen", wantFullscreen);
#else
SDL_WM_ToggleFullScreen(window);
if (IsFullscreen())
{
Cvar_SetValue("vid_fullscreen", 1);
}
else
{
Cvar_SetValue("vid_fullscreen", 0);
}
#endif
vid_fullscreen->modified = false;
}
/* /*
* (Un)grab Input * (Un)grab Input
*/ */

View file

@ -909,6 +909,7 @@ Key_Event(int key, qboolean down, qboolean special)
{ {
char cmd[1024]; char cmd[1024];
char *kb; char *kb;
cvar_t *fullscreen;
unsigned int time = Sys_Milliseconds(); unsigned int time = Sys_Milliseconds();
/* Track if key is down */ /* Track if key is down */
@ -938,7 +939,19 @@ Key_Event(int key, qboolean down, qboolean special)
/* Fullscreen switch through Alt + Return */ /* Fullscreen switch through Alt + Return */
if (down && keydown[K_ALT] && key == K_ENTER) if (down && keydown[K_ALT] && key == K_ENTER)
{ {
GLimp_ToggleFullscreen(); fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
if (!fullscreen->value)
{
fullscreen->value = 1;
fullscreen->modified = true;
}
else
{
fullscreen->value = 0;
fullscreen->modified = true;
}
return; return;
} }

View file

@ -429,11 +429,6 @@ int GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen);
*/ */
void *GLimp_GetProcAddress (const char* proc); void *GLimp_GetProcAddress (const char* proc);
/*
* Toggle fullscreen.
*/
void GLimp_ToggleFullscreen(void);
/* /*
* (Un)grab Input * (Un)grab Input
*/ */