From 8e4f0f38371cb6f03c26b364ea148d49a86ed21c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 26 Nov 2023 14:18:54 +0900 Subject: [PATCH] [win] Implement borderless fullscreen mode And rip out all the crufty DIB mode junk. Fixes #60 --- include/context_win.h | 1 + libs/video/targets/context_win.c | 758 ++----------------------------- libs/video/targets/vid_win.c | 2 +- 3 files changed, 32 insertions(+), 729 deletions(-) diff --git a/include/context_win.h b/include/context_win.h index 6e9d39ad5..3cea5d8a2 100644 --- a/include/context_win.h +++ b/include/context_win.h @@ -51,6 +51,7 @@ void Win_Activate (BOOL fActive, BOOL minimize); bool Win_AddEvent (UINT event, LONG (*event_handler)(HWND, UINT, WPARAM, LPARAM)); bool Win_RemoveEvent (UINT event); +void Win_UpdateFullscreen (int fullscreen); void Win_UnloadAllDrivers (void); void Win_OpenDisplay (void); diff --git a/libs/video/targets/context_win.c b/libs/video/targets/context_win.c index 41e44b517..4fb53ddb5 100644 --- a/libs/video/targets/context_win.c +++ b/libs/video/targets/context_win.c @@ -226,20 +226,11 @@ int win_len_x, win_len_y; RECT win_rect; DEVMODE win_gdevmode; -static bool startwindowed = 0; -//static bool windowed_mode_set; -//static int vid_fulldib_on_focus_mode; -static bool force_minimized; -static bool force_mode_set; -static bool vid_mode_set; -//static HICON hIcon; - int vid_modenum = NO_MODE; int vid_testingmode, vid_realmode; double vid_testendtime; int vid_default = MODE_WINDOWED; -static int windowed_default; modestate_t modestate = MS_UNINIT; @@ -247,51 +238,10 @@ byte vid_curpal[256 * 3]; int mode; -typedef struct { - modestate_t type; - int width; - int height; - int modenum; - int fullscreen; - char modedesc[13]; -} vmode_t; - -static vmode_t modelist[MAX_MODE_LIST] = { - { - .type = MS_WINDOWED, - .width = 320, - .height = 240, - .modedesc = "320x240", - .modenum = MODE_WINDOWED, - .fullscreen = 0, - }, - { - .type = MS_WINDOWED, - .width = 640, - .height = 480, - .modedesc = "640x480", - .modenum = MODE_WINDOWED + 1, - .fullscreen = 0, - }, - { - .type = MS_WINDOWED, - .width = 800, - .height = 600, - .modedesc = "800x600", - .modenum = MODE_WINDOWED + 2, - .fullscreen = 0, - } -}; -static int nummodes; - int aPage; // Current active display page int vPage; // Current visible display page int waitVRT = true; // True to wait for retrace on flip -static vmode_t badmode = { - .modedesc = "Bad mode", -}; - static LONG (*event_handlers[WM_USER])(HWND, UINT, WPARAM, LPARAM); bool @@ -330,36 +280,6 @@ Win_EventHandler (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DefWindowProc (hWnd, uMsg, wParam, lParam); } -static int VID_SetMode (int modenum, const byte *palette); - -static void __attribute__ ((used)) -VID_RememberWindowPos (void) -{ - RECT rect; - - if (GetWindowRect (win_mainwindow, &rect)) { - if ((rect.left < GetSystemMetrics (SM_CXSCREEN)) && - (rect.top < GetSystemMetrics (SM_CYSCREEN)) && - (rect.right > 0) && (rect.bottom > 0)) { - vid_window_x = rect.left; - vid_window_y = rect.top; - } - } -} - -#if 0 -static void -VID_CheckWindowXY (void) -{ - if ((vid_window_x > (GetSystemMetrics (SM_CXSCREEN) - 160)) || - (vid_window_y > (GetSystemMetrics (SM_CYSCREEN) - 120)) || - (vid_window_x < 0) || (vid_window_y < 0)) { - vid_window_x = 0.0; - vid_window_y = 0.0; - } -} -#endif - static void Win_UpdateWindowStatus () { @@ -373,15 +293,6 @@ Win_UpdateWindowStatus () IN_UpdateClipCursor (); } - -static bool -VID_CheckAdequateMem (int width, int height) -{ - // there will always be enough ;) - return true; -} - - static void VID_InitModes (HINSTANCE hInstance) { @@ -391,7 +302,6 @@ VID_InitModes (HINSTANCE hInstance) .hInstance = hInstance, .lpszClassName = WINDOW_CLASS, }; - HDC hdc; win_arrow = LoadCursor (NULL, IDC_ARROW); @@ -401,119 +311,19 @@ VID_InitModes (HINSTANCE hInstance) if (!RegisterClass (&wc)) Sys_Error ("Couldn't register window class"); - - // automatically stretch the default mode up if > 640x480 desktop - // resolution - hdc = GetDC (NULL); - - if ((GetDeviceCaps (hdc, HORZRES) > 800) - && !COM_CheckParm ("-noautostretch")) { - vid_default = MODE_WINDOWED + 2; - } else if ((GetDeviceCaps (hdc, HORZRES) > 640) - && !COM_CheckParm ("-noautostretch")) { - vid_default = MODE_WINDOWED + 1; - } else { - vid_default = MODE_WINDOWED; - } - - // always start at the lowest mode then switch to the higher one if - // selected - vid_default = MODE_WINDOWED; - - windowed_default = vid_default; - ReleaseDC (NULL, hdc); - nummodes = 3; // reserve space for windowed mode -} - - -static void -VID_GetDisplayModes (void) -{ - DEVMODE devmode; - int i, modenum, existingmode, originalnummodes, lowestres; - BOOL stat; - - // enumerate > 8 bpp modes - originalnummodes = nummodes; - modenum = 0; - lowestres = 99999; - - do { - stat = EnumDisplaySettings (NULL, modenum, &devmode); - - if ((devmode.dmPelsWidth <= MAXWIDTH) - && (devmode.dmPelsHeight <= MAXHEIGHT) - && (devmode.dmPelsWidth >= 320) - && (devmode.dmPelsHeight >= 240) - && (nummodes < MAX_MODE_LIST)) { - devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == - DISP_CHANGE_SUCCESSFUL) { - modelist[nummodes].type = MS_FULLDIB; - modelist[nummodes].width = devmode.dmPelsWidth; - modelist[nummodes].height = devmode.dmPelsHeight; - modelist[nummodes].modenum = 0; - modelist[nummodes].fullscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", - (int) devmode.dmPelsWidth, - (int) devmode.dmPelsHeight); - - // see is the mode already there - // (same dimensions but different refresh rate) - for (i = originalnummodes, existingmode = 0; - i < nummodes; i++) { - if ((modelist[nummodes].width == modelist[i].width) - && (modelist[nummodes].height == modelist[i].height)) { - existingmode = 1; - break; - } - } - - // if it's not add it to the list - if (!existingmode) { - if (modelist[nummodes].width < lowestres) - lowestres = modelist[nummodes].width; - - nummodes++; - } - } - } - - modenum++; - } while (stat); - - if (nummodes != originalnummodes) - vid_default = MODE_FULLSCREEN_DEFAULT; - else - Sys_Printf ("No fullscreen DIB modes found\n"); } void Win_OpenDisplay (void) { global_hInstance = GetModuleHandle (0); - VID_InitModes (global_hInstance); - VID_GetDisplayModes (); - - vid_testingmode = 0; - - // if (COM_CheckParm("-startwindowed")) - { - startwindowed = 1; - vid_default = windowed_default; - } } void Win_CloseDisplay (void) { if (viddef.initialized) { - if (modestate == MS_FULLDIB) { - ChangeDisplaySettings (NULL, CDS_FULLSCREEN); - } - PostMessage (HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM) win_mainwindow, (LPARAM) 0); PostMessage (HWND_BROADCAST, WM_SYSCOLORCHANGE, (WPARAM) 0, (LPARAM) 0); @@ -523,321 +333,35 @@ Win_CloseDisplay (void) } } +static RECT window_rect; void -Win_SetVidMode (int width, int height) +Win_UpdateFullscreen (int fullscreen) { -//FIXME SCR_StretchInit(); - - force_mode_set = true; - //VID_SetMode (vid_default, palette); - force_mode_set = false; - vid_realmode = vid_modenum; -} - -static void -VID_CheckModedescFixup (int mode) -{ -} - -static bool -VID_SetWindowedMode (int modenum) -{ -#if 0 - if (!windowed_mode_set) { - if (COM_CheckParm ("-resetwinpos")) { - vid_window_x = 0.0; - vid_window_y = 0.0; - } - - windowed_mode_set = true; - } - - VID_CheckModedescFixup (modenum); - VID_DestroyWindow (); - - DIBWidth = modelist[modenum].width; - DIBHeight = modelist[modenum].height; - - WindowStyle = WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | - WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | - WS_CLIPCHILDREN | WS_THICKFRAME; - - // WindowStyle = WS_OVERLAPPEDWINDOW|WS_VISIBLE; - ExWindowStyle = 0; - - // the first time we're called to set the mode, create the window we'll use - // for the rest of the session - if (!vid_mode_set) { + if (fullscreen) { + GetWindowRect (win_mainwindow, &window_rect); + SetWindowLongW (win_mainwindow, GWL_STYLE, 0); + HMONITOR monitor = MonitorFromWindow (win_mainwindow, MONITOR_DEFAULTTONEAREST); + MONITORINFO info = { + .cbSize = sizeof (info), + }; + GetMonitorInfoW (monitor, &info); + SetWindowPos (win_mainwindow, HWND_TOP, + info.rcMonitor.left, + info.rcMonitor.top, + info.rcMonitor.right - info.rcMonitor.left, + info.rcMonitor.bottom - info.rcMonitor.top, + SWP_FRAMECHANGED | SWP_NOACTIVATE); + ShowWindow (win_mainwindow, SW_MAXIMIZE); } else { - SetWindowLong (win_mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); - SetWindowLong (win_mainwindow, GWL_EXSTYLE, ExWindowStyle); + SetWindowLongW (win_mainwindow, GWL_STYLE, WindowStyle); + SetWindowPos (win_mainwindow, HWND_NOTOPMOST, + window_rect.left, + window_rect.top, + window_rect.right - window_rect.left, + window_rect.bottom - window_rect.top, + SWP_FRAMECHANGED | SWP_NOACTIVATE); + ShowWindow (win_mainwindow, SW_NORMAL); } - - if (!SetWindowPos (win_mainwindow, - NULL, - 0, 0, - WindowRect.right - WindowRect.left, - WindowRect.bottom - WindowRect.top, - SWP_NOCOPYBITS | SWP_NOZORDER | SWP_HIDEWINDOW)) { - Sys_Error ("Couldn't resize DIB window"); - } - - // position and show the DIB window - VID_CheckWindowXY (); - SetWindowPos (win_mainwindow, NULL, vid_window_x, - vid_window_y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_DRAWFRAME); - - if (force_minimized) - ShowWindow (win_mainwindow, SW_MINIMIZE); - else - ShowWindow (win_mainwindow, SW_SHOWDEFAULT); - - UpdateWindow (win_mainwindow); - modestate = MS_WINDOWED; - vid_fulldib_on_focus_mode = 0; - - viddef.numpages = 1; - -// viddef.height = viddef.conheight = DIBHeight; -// viddef.width = viddef.conwidth = DIBWidth; - - viddef.height = viddef.conheight = DIBHeight; - viddef.width = viddef.conwidth = DIBWidth; -//FIXME? if (!yeahimconsoled){ -//FIXME? viddef.vconheight = DIBHeight; -//FIXME? viddef.vconwidth = DIBWidth; -//FIXME? } - SendMessage (win_mainwindow, WM_SETICON, (WPARAM) TRUE, (LPARAM) hIcon); - SendMessage (win_mainwindow, WM_SETICON, (WPARAM) FALSE, (LPARAM) hIcon); -#endif - return true; -} - - -static bool -VID_SetFullDIBMode (int modenum) -{ -#if 0 - VID_DestroyWindow (); - - win_gdevmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; - win_gdevmode.dmPelsWidth = modelist[modenum].width; - win_gdevmode.dmPelsHeight = modelist[modenum].height; - win_gdevmode.dmSize = sizeof (win_gdevmode); - - if (ChangeDisplaySettings (&win_gdevmode, CDS_FULLSCREEN) != - DISP_CHANGE_SUCCESSFUL) - Sys_Error ("Couldn't set fullscreen DIB mode"); - - modestate = MS_FULLDIB; - vid_fulldib_on_focus_mode = modenum; - - WindowRect.top = WindowRect.left = 0; - WindowRect.right = modelist[modenum].width; - WindowRect.bottom = modelist[modenum].height; - - DIBWidth = modelist[modenum].width; - DIBHeight = modelist[modenum].height; - - WindowStyle = WS_POPUP | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - ExWindowStyle = 0; - - AdjustWindowRectEx (&WindowRect, WindowStyle, FALSE, 0); - - SetWindowLong (win_mainwindow, GWL_STYLE, WindowStyle | WS_VISIBLE); - SetWindowLong (win_mainwindow, GWL_EXSTYLE, ExWindowStyle); - - if (!SetWindowPos (win_mainwindow, - NULL, - 0, 0, - WindowRect.right - WindowRect.left, - WindowRect.bottom - WindowRect.top, - SWP_NOCOPYBITS | SWP_NOZORDER)) { - Sys_Error ("Couldn't resize DIB window"); - } - // position and show the DIB window - SetWindowPos (win_mainwindow, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_SHOWWINDOW | SWP_DRAWFRAME); - ShowWindow (win_mainwindow, SW_SHOWDEFAULT); - UpdateWindow (win_mainwindow); - - viddef.numpages = 1; - -#ifdef SCALED2D - viddef.height = viddef.conheight = DIBHeight; - viddef.width = viddef.conwidth = DIBWidth; - // viddef.vconwidth = 320; - // viddef.vconheight = 200; -//FIXME? if (!yeahimconsoled){ -//FIXME? viddef.vconheight = DIBHeight; -//FIXME? viddef.vconwidth = DIBWidth; -//FIXME? } -#else - viddef.height = viddef.conheight = DIBHeight; - viddef.width = viddef.conwidth = DIBWidth; -#endif -#endif - return true; -} - -static void -VID_RestoreOldMode (int original_mode) -{ - static bool inerror = false; - - if (inerror) - return; - - inerror = true; - // make sure mode set happens (video mode changes) - vid_modenum = original_mode - 1; - - if (!VID_SetMode (original_mode, vid_curpal)) { - vid_modenum = MODE_WINDOWED - 1; - - if (!VID_SetMode (windowed_default, vid_curpal)) - Sys_Error ("Can't set any video mode"); - } - - inerror = false; -} - - -static void __attribute__ ((used)) -VID_SetDefaultMode (void) -{ - if (viddef.initialized) - VID_SetMode (0, vid_curpal); - - IN_DeactivateMouse (); -} - -static vmode_t * -VID_GetModePtr (int modenum) -{ - if ((modenum >= 0) && (modenum < nummodes)) - return &modelist[modenum]; - else - return &badmode; -} - -static char * -VID_GetModeDescription (int mode) -{ - char *pinfo; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - pv = VID_GetModePtr (mode); - pinfo = pv->modedesc; - return pinfo; -} - -static int -VID_SetMode (int modenum, const byte *palette) -{ - int original_mode; // FIXME, temp; - bool stat; - MSG msg; - HDC hdc; - - while ((modenum >= nummodes) || (modenum < 0)) { - if (vid_modenum == NO_MODE) { - if (modenum == vid_default) { - modenum = windowed_default; - } else { - modenum = vid_default; - } - - vid_mode = modenum; - } else { - vid_mode = vid_modenum; - return 0; - } - } - - if (!force_mode_set && (modenum == vid_modenum)) - return true; - -//FIXME CDAudio_Pause (); -//FIXME S_ClearBuffer (); - - if (vid_modenum == NO_MODE) - original_mode = windowed_default; - else - original_mode = vid_modenum; - - // Set either the fullscreen or windowed mode - if (modelist[modenum].type == MS_WINDOWED) { - if (_windowed_mouse) { - stat = VID_SetWindowedMode (modenum); - IN_ActivateMouse (); - } else { - IN_DeactivateMouse (); - stat = VID_SetWindowedMode (modenum); - } - } else { - stat = VID_SetFullDIBMode (modenum); - IN_ActivateMouse (); - } - - Win_UpdateWindowStatus (); -//FIXME CDAudio_Resume (); - - if (!stat) { - VID_RestoreOldMode (original_mode); - return false; - } - - // now we try to make sure we get the focus on the mode switch, because - // sometimes in some systems we don't. We grab the foreground, then - // finish setting up, pump all our messages, and sleep for a little while - // to let messages finish bouncing around the system, then we put - // ourselves at the top of the z order, then grab the foreground again, - // Who knows if it helps, but it probably doesn't hurt - if (!force_minimized) - SetForegroundWindow (win_mainwindow); - - hdc = GetDC (NULL); - if (GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) { - win_palettized = true; - } else { - win_palettized = false; - } - ReleaseDC (NULL, hdc); - - vid_modenum = modenum; - vid_mode = vid_modenum; - - while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage (&msg); - DispatchMessage (&msg); - } - - Sleep (100); - - if (!force_minimized) { - SetWindowPos (win_mainwindow, HWND_TOP, 0, 0, 0, 0, - SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | - SWP_NOCOPYBITS); - - SetForegroundWindow (win_mainwindow); - } - // fix the leftover Alt from any Alt-Tab or the like that switched us away - IN_ClearStates (); - - Sys_Printf ("%s\n", VID_GetModeDescription (vid_modenum)); - - viddef.recalc_refdef = 1; - -//FIXME SCR_StretchInit(); -//FIXME SCR_StretchRefresh(); -//FIXME SCR_CvarCheck(); - return true; } static long @@ -912,11 +436,9 @@ Win_CreateWindow (int width, int height) NULL, NULL, global_hInstance, NULL); if (!win_mainwindow) - Sys_Error ("Couldn't create DIB window"); + Sys_Error ("Couldn't create window"); // done - vid_mode_set = true; -//FIXME if (firsttime) S_Init (); Win_UpdateWindowStatus (); HDC hdc = GetDC (NULL); @@ -927,9 +449,6 @@ Win_CreateWindow (int width, int height) } ReleaseDC (NULL, hdc); - //vid_modenum = modenum; - //Cvar_SetValue (vid_mode, (float) vid_modenum); - MSG msg; while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage (&msg); @@ -938,221 +457,14 @@ Win_CreateWindow (int width, int height) Sleep (100); - if (!force_minimized) { - SetWindowPos (win_mainwindow, HWND_TOP, 0, 0, 0, 0, - SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | - SWP_NOCOPYBITS); - - SetForegroundWindow (win_mainwindow); - } - // fix the leftover Alt from any Alt-Tab or the like that switched us away - - Sys_Printf ("%s\n", VID_GetModeDescription (vid_modenum)); + SetWindowPos (win_mainwindow, HWND_TOP, 0, 0, 0, 0, + SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | + SWP_NOCOPYBITS); + SetForegroundWindow (win_mainwindow); viddef.recalc_refdef = 1; } - -/* -=================================================================== - -MAIN WINDOW - -=================================================================== -*/ - -typedef struct { - int modenum; - char *desc; - int iscur; - int width; -} modedesc_t; - -#define MAX_COLUMN_SIZE 5 -#define MODE_AREA_HEIGHT (MAX_COLUMN_SIZE + 6) -#define MAX_MODEDESCS (MAX_COLUMN_SIZE*3) - -//static modedesc_t modedescs[MAX_MODEDESCS]; - -static int -VID_NumModes (void) -{ - return nummodes; -} - -static char * __attribute__((used)) -VID_GetModeDescriptionMemCheck (int mode) -{ - char *pinfo; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - pv = VID_GetModePtr (mode); - pinfo = pv->modedesc; - - if (VID_CheckAdequateMem (pv->width, pv->height)) { - return pinfo; - } else { - return NULL; - } -} - - -// Tacks on "windowed" or "fullscreen" -static const char * __attribute__((used)) -VID_GetModeDescription2 (int mode) -{ - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - pv = VID_GetModePtr (mode); - - if (modelist[mode].type == MS_FULLSCREEN) { - return va (0, "%s fullscreen", pv->modedesc); - } else if (modelist[mode].type == MS_FULLDIB) { - return va (0, "%s fullscreen", pv->modedesc); - } else { - return va (0, "%s windowed", pv->modedesc); - } -} - - -// KJB: Added this to return the mode driver name in description for console -static char * -VID_GetExtModeDescription (int mode) -{ - static char pinfo[40]; - vmode_t *pv; - - if ((mode < 0) || (mode >= nummodes)) - return NULL; - - VID_CheckModedescFixup (mode); - pv = VID_GetModePtr (mode); - - if (modelist[mode].type == MS_FULLDIB) { - sprintf (pinfo, "%s fullscreen", pv->modedesc); - } else { - sprintf (pinfo, "%s windowed", pv->modedesc); - } - - return pinfo; -} -static void -VID_DescribeCurrentMode_f (void) -{ - Sys_Printf ("%s\n", VID_GetExtModeDescription (vid_modenum)); -} - -static void -VID_NumModes_f (void) -{ - if (nummodes == 1) - Sys_Printf ("%d video mode is available\n", nummodes); - else - Sys_Printf ("%d video modes are available\n", nummodes); -} - - -static void -VID_DescribeMode_f (void) -{ - int modenum; - - modenum = atoi (Cmd_Argv (1)); - Sys_Printf ("%s\n", VID_GetExtModeDescription (modenum)); -} - - -static void -VID_DescribeModes_f (void) -{ - int i, lnummodes; - char *pinfo; - bool na; - vmode_t *pv; - - na = false; - lnummodes = VID_NumModes (); - - for (i = 0; i < lnummodes; i++) { - pv = VID_GetModePtr (i); - pinfo = VID_GetExtModeDescription (i); - - if (VID_CheckAdequateMem (pv->width, pv->height)) { - Sys_Printf ("%2d: %s\n", i, pinfo); - } else { - Sys_Printf ("**: %s\n", pinfo); - na = true; - } - } - - if (na) { - Sys_Printf ("\n[**: not enough system RAM for mode]\n"); - } -} - -static void -VID_TestMode_f (void) -{ - int modenum; - double testduration; - - if (!vid_testingmode) { - modenum = atoi (Cmd_Argv (1)); - - if (VID_SetMode (modenum, vid_curpal)) { - vid_testingmode = 1; - testduration = atof (Cmd_Argv (2)); - - if (testduration == 0) - testduration = 5.0; - - vid_testendtime = Sys_DoubleTime () + testduration; - } - } -} - -static void -VID_Windowed_f (void) -{ - VID_SetMode (vid_windowed_mode, vid_curpal); -} - -static void -VID_Fullscreen_f (void) -{ - VID_SetMode (vid_fullscreen_mode, vid_curpal); -} - -static void -VID_Minimize_f (void) -{ - // we only support minimizing windows; if you're fullscreen, - // switch to windowed first - if (modestate == MS_WINDOWED) - ShowWindow (win_mainwindow, SW_MINIMIZE); -} - -static void -VID_ForceMode_f (void) -{ - int modenum; - - if (!vid_testingmode) { - modenum = atoi (Cmd_Argv (1)); - force_mode_set = 1; - VID_SetMode (modenum, vid_curpal); - force_mode_set = 0; - } -} - void Win_SetCaption (const char *text) { @@ -1199,16 +511,6 @@ Win_Init_Cvars (void) Cvar_Register (&block_switch_cvar, 0, 0); Cvar_Register (&vid_window_x_cvar, 0, 0); Cvar_Register (&vid_window_y_cvar, 0, 0); - - Cmd_AddCommand ("vid_testmode", VID_TestMode_f, ""); - Cmd_AddCommand ("vid_nummodes", VID_NumModes_f, ""); - Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f, ""); - Cmd_AddCommand ("vid_describemode", VID_DescribeMode_f, ""); - Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f, ""); - Cmd_AddCommand ("vid_forcemode", VID_ForceMode_f, ""); - Cmd_AddCommand ("vid_windowed", VID_Windowed_f, ""); - Cmd_AddCommand ("vid_fullscreen", VID_Fullscreen_f, ""); - Cmd_AddCommand ("vid_minimize", VID_Minimize_f, ""); } extern int win_force_link; diff --git a/libs/video/targets/vid_win.c b/libs/video/targets/vid_win.c index ba3345385..e51a07795 100644 --- a/libs/video/targets/vid_win.c +++ b/libs/video/targets/vid_win.c @@ -84,7 +84,6 @@ Win_VID_Init (byte *palette, byte *colormap) VID_GetWindowSize (640, 480); Win_OpenDisplay (); vid_internal.choose_visual (win_sw_context); - Win_SetVidMode (viddef.width, viddef.height); Win_CreateWindow (viddef.width, viddef.height); vid_internal.create_context (win_sw_context); @@ -111,6 +110,7 @@ vid_system_t vid_system = { .init = Win_VID_Init, .set_palette = Win_VID_SetPalette, .init_cvars = Win_VID_Init_Cvars, + .update_fullscreen = Win_UpdateFullscreen, .set_cursor = Win_VID_SetCursor, };