Added r_mode_desktop cvar to force desktop resolution in borderless window mode.

This commit is contained in:
Knightmare66 2021-08-25 02:28:15 -04:00
parent e872299cbd
commit b80d34a3e3
3 changed files with 47 additions and 8 deletions

View file

@ -305,6 +305,9 @@ extern cvar_t *r_screenshot_gamma_correct; // gamma correction for screenshots
//extern cvar_t *r_nosubimage; // unused
extern cvar_t *r_bitdepth;
extern cvar_t *r_mode;
#ifdef _WIN32
extern cvar_t *r_mode_desktop; // desktop-resolution display mode
#endif
extern cvar_t *r_log;
extern cvar_t *r_lightmap;
extern cvar_t *r_shadows;

View file

@ -169,6 +169,9 @@ cvar_t *r_particledistance;
cvar_t *r_particle_overdraw;
cvar_t *r_mode;
#ifdef _WIN32
cvar_t *r_mode_desktop; // desktop-resolution display mode
#endif
cvar_t *r_dynamic;
cvar_t *r_monolightmap;
@ -1040,6 +1043,10 @@ void R_Register (void)
Cvar_SetDescription ("r_bitdepth", "Sets color bit depth. 0 = desktop setting.");
r_mode = Cvar_Get( "r_mode", "4", CVAR_ARCHIVE );
Cvar_SetDescription ("r_mode", "Sets enumerated video mode for renderer. -1 = custom mode.");
#ifdef _WIN32 // desktop-resolution display mode
r_mode_desktop = Cvar_Get( "r_mode_desktop", "0", CVAR_ARCHIVE );
Cvar_SetDescription ("r_mode_desktop", "Enables setting borderless window mode to current desktop size (including multiple monitors). Experimental.");
#endif
r_lightmap = Cvar_Get ("r_lightmap", "0", 0);
Cvar_SetDescription ("r_lightmap", "Enables lightmap-only world rendering.");
r_shadows = Cvar_Get ("r_shadows", "0", CVAR_ARCHIVE );
@ -1277,6 +1284,9 @@ qboolean R_SetMode (void)
vid_fullscreen->modified = false;
r_mode->modified = false;
#ifdef _WIN32
r_mode_desktop->modified = false; // desktop-resolution display mode
#endif
if ( ( err = GLimp_SetMode( &vid.width, &vid.height, r_mode->integer, fullscreen ) ) == rserr_ok )
{
@ -2203,7 +2213,13 @@ void R_BeginFrame( float camera_separation )
//
// change modes if necessary
//
if ( r_mode->modified || vid_fullscreen->modified )
// if ( r_mode->modified || vid_fullscreen->modified )
if ( r_mode->modified || vid_fullscreen->modified
#ifdef _WIN32
|| (r_mode_desktop->modified && (vid_fullscreen->integer >= 2)) ) // desktop-resolution display mode
#else
)
#endif // _WIN32
{ // FIXME: only restart if CDS is required
cvar_t *ref;

View file

@ -70,6 +70,7 @@ cvar_t *vid_ypos; // Y coordinate of window position
cvar_t *vid_fullscreen;
cvar_t *r_customwidth;
cvar_t *r_customheight;
cvar_t *r_mode_desktop; // desktop-resolution display mode
// Global variables used internally by this module
viddef_t viddef; // global video state; used by other modules
@ -526,15 +527,18 @@ void VID_Restart_f (void)
vid_ref->modified = true;
}
/*
==============
VID_Front_f
==============
*/
void VID_Front_f( void )
{
SetWindowLongPtr( cl_hwnd, GWL_EXSTYLE, WS_EX_TOPMOST );
SetForegroundWindow( cl_hwnd );
}
/*
** VID_GetModeInfo
*/
typedef struct vidmode_s
{
const char *description;
@ -548,8 +552,23 @@ vidmode_t vid_modes[] =
#include "../qcommon/vid_modes.h"
};
/*
==============
VID_GetModeInfo
==============
*/
qboolean VID_GetModeInfo (int *width, int *height, int mode)
{
// desktop-resolution display mode
if ( r_mode_desktop->integer && (vid_fullscreen->integer >= 2) )
{
*width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
*height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
if ( (width == 0) || (height == 0) )
return false;
return true;
}
if (mode == -1) // custom mode
{
// *width = r_customwidth->value;
@ -562,7 +581,6 @@ qboolean VID_GetModeInfo (int *width, int *height, int mode)
if ( mode < 0 || mode >= VID_NUM_MODES )
return false;
*width = vid_modes[mode].width;
*height = vid_modes[mode].height;
@ -756,12 +774,14 @@ void VID_Init (void)
Cvar_SetDescription ("win_noalttab", "Disables alt-tab out of game when set to 1.");
win_alttab_restore_desktop = Cvar_Get( "win_alttab_restore_desktop", "1", CVAR_ARCHIVE ); // Knightmare- whether to restore desktop resolution on alt-tab
Cvar_SetDescription ("win_alttab_restore_desktop", "Enables restoration of desktop resolution when alt-tabbing.");
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE );
r_customwidth = Cvar_Get ("r_customwidth", "1600", CVAR_ARCHIVE);
Cvar_SetDescription ("r_customwidth", "Sets resolution width when using custom video mode (-1).");
r_customheight = Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE );
r_customheight = Cvar_Get ("r_customheight", "1024", CVAR_ARCHIVE);
Cvar_SetDescription ("r_customheight", "Sets resolution height when using custom video mode (-1).");
r_mode_desktop = Cvar_Get ("r_mode_desktop", "0", CVAR_ARCHIVE); // desktop-resolution display mode
// Knightmare- just here to enable command line option without error
scanforcd = Cvar_Get( "scanforcd", "0", 0 );
scanforcd = Cvar_Get ("scanforcd", "0", 0);
// force vid_ref to gl
// older versions of Lazarus code check only vid_ref=gl for fadein effects