diff --git a/libs/video/targets/vid_sdl.c b/libs/video/targets/vid_sdl.c index afd43f4e1..1d4d3cf34 100644 --- a/libs/video/targets/vid_sdl.c +++ b/libs/video/targets/vid_sdl.c @@ -159,7 +159,7 @@ VID_UpdateFullscreen (cvar_t *vid_fullscreen) void VID_Init_Cvars () { - vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_NONE, + vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE, VID_UpdateFullscreen, "Toggles fullscreen game mode"); vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL, diff --git a/libs/video/targets/vid_sdl32.c b/libs/video/targets/vid_sdl32.c index ed9571bc7..013f80583 100644 --- a/libs/video/targets/vid_sdl32.c +++ b/libs/video/targets/vid_sdl32.c @@ -200,7 +200,7 @@ VID_UpdateFullscreen (cvar_t *vid_fullscreen) void VID_Init_Cvars () { - vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_NONE, + vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE, VID_UpdateFullscreen, "Toggles fullscreen game mode"); vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets " diff --git a/libs/video/targets/vid_sgl.c b/libs/video/targets/vid_sgl.c index 22b2cad4f..daf9a1156 100644 --- a/libs/video/targets/vid_sgl.c +++ b/libs/video/targets/vid_sgl.c @@ -68,7 +68,7 @@ HWND mainwindow; int VID_options_items = 1; int modestate; - +static SDL_Surface *screen = NULL; void VID_SDL_GammaCheck (void) @@ -189,7 +189,7 @@ VID_Init (unsigned char *palette) SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 1); - if (SDL_SetVideoMode (scr_width, scr_height, 8, flags) == NULL) { + if (!(screen = SDL_SetVideoMode (scr_width, scr_height, 8, flags))) { Sys_Error ("Couldn't set video mode: %s\n", SDL_GetError ()); SDL_Quit (); } @@ -231,11 +231,22 @@ VID_Init (unsigned char *palette) vid.recalc_refdef = 1; // force a surface cache flush } +void +VID_UpdateFullscreen (cvar_t *vid_fullscreen) +{ + if (!vid.initialized) + return; + if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN)) + || (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN)) + if (!SDL_WM_ToggleFullScreen (screen)) + Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n"); +} + void VID_Init_Cvars () { - vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ROM, NULL, - "Toggles fullscreen mode"); + vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE, + VID_UpdateFullscreen, "Toggles fullscreen mode"); vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL, "Use system gamma control if available"); }