Skip to content

Commit 454133f

Browse files
committed
[gameui] Enable borderless window support
1 parent c5fa7ae commit 454133f

File tree

11 files changed

+169
-89
lines changed

11 files changed

+169
-89
lines changed

appframework/VguiMatSysApp.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,8 @@ void* CVguiMatSysApp::GetAppWindow()
268268
bool CVguiMatSysApp::SetVideoMode( )
269269
{
270270
MaterialSystem_Config_t config;
271-
if ( CommandLine()->CheckParm( "-fullscreen" ) )
272-
{
273-
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, false );
274-
}
275-
else
276-
{
277-
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, true );
278-
}
271+
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, !CommandLine()->CheckParm( "-fullscreen" ) );
272+
config.SetFlag( MATSYS_VIDCFG_FLAGS_BORDERLESS, !!CommandLine()->CheckParm( "-noborder" ) );
279273

280274
if ( CommandLine()->CheckParm( "-resizing" ) )
281275
{

engine/cl_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ void CDemoPlayer::WriteTimeDemoResults( void )
18041804
g_pFileSystem->FPrintf( fileHandle, "%i,", frames );
18051805
g_pFileSystem->FPrintf( fileHandle, "%i,", width );
18061806
g_pFileSystem->FPrintf( fileHandle, "%i,", height );
1807-
g_pFileSystem->FPrintf( fileHandle, "%s,", config.Windowed() ? "windowed" : "fullscreen");
1807+
g_pFileSystem->FPrintf( fileHandle, "%s,", config.Windowed() ? (config.Borderless() ? "windowed borderless" : "windowed") : "fullscreen");
18081808
g_pFileSystem->FPrintf( fileHandle, "%s,", mat_vsync.GetBool() ? "on" : "off" );
18091809
g_pFileSystem->FPrintf( fileHandle, "%d,", mat_antialias.GetInt() );
18101810
g_pFileSystem->FPrintf( fileHandle, "%d,", mat_forceaniso.GetInt() );

engine/ivideomode.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ abstract_class IVideoMode
3636
virtual void DrawStartupGraphic() = 0;
3737

3838
// Creates the game window, plays the startup movie, starts up the material system
39-
virtual bool CreateGameWindow( int nWidth, int nHeight, bool bWindowed ) = 0;
39+
virtual bool CreateGameWindow( int nWidth, int nHeight, bool bWindowed, bool bBorderless ) = 0;
4040

4141
// Sets the game window in editor mode
4242
virtual void SetGameWindow( void *hWnd ) = 0;
4343

4444
// Sets the video mode, and re-sizes the window
45-
virtual bool SetMode( int nWidth, int nHeight, bool bWindowed ) = 0;
45+
virtual bool SetMode( int nWidth, int nHeight, bool bWindowed, bool bBorderless ) = 0;
4646

4747
// Returns the fullscreen modes for the adapter the game was started on
4848
virtual int GetModeCount( void ) = 0;
@@ -96,6 +96,8 @@ abstract_class IVideoMode
9696
virtual bool TakeSnapshotJPEGToBuffer( CUtlBuffer& buf, int quality ) = 0;
9797

9898
virtual void ReadScreenPixels( int x, int y, int w, int h, void *pBuffer, ImageFormat format ) = 0;
99+
100+
virtual bool IsBorderlessMode() const = 0;
99101
};
100102

101103
//-----------------------------------------------------------------------------

engine/matsys_interface.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ static void ReadMaterialSystemConfigFromRegistry( MaterialSystem_Config_t &confi
409409
ReadVideoConfigInt( "ScreenWidth", &config.m_VideoMode.m_Width );
410410
ReadVideoConfigInt( "ScreenHeight", &config.m_VideoMode.m_Height );
411411
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, ReadVideoConfigInt( "ScreenWindowed", 0 ) != 0 );
412+
config.SetFlag( MATSYS_VIDCFG_FLAGS_BORDERLESS, ReadVideoConfigInt( "ScreenNoBorder", 0 ) != 0 );
412413
#if defined( USE_SDL ) && !defined( SWDS )
413414
// Read the ScreenDisplayIndex and set sdl_displayindex if it's there.
414415
static ConVarRef conVar( "sdl_displayindex" );
@@ -540,6 +541,7 @@ static void WriteMaterialSystemConfigToRegistry( const MaterialSystem_Config_t &
540541
WriteVideoConfigInt( "ScreenWidth", config.m_VideoMode.m_Width );
541542
WriteVideoConfigInt( "ScreenHeight", config.m_VideoMode.m_Height );
542543
WriteVideoConfigInt( "ScreenWindowed", config.Windowed() );
544+
WriteVideoConfigInt( "ScreenNoBorder", config.Borderless() );
543545
WriteVideoConfigInt( "ScreenMSAA", config.m_nAASamples );
544546
WriteVideoConfigInt( "ScreenMSAAQuality", config.m_nAAQuality );
545547
WriteVideoConfigInt( "MotionBlur", config.m_bMotionBlur ? 1 : 0 );
@@ -600,6 +602,12 @@ static void OverrideMaterialSystemConfigFromCommandLine( MaterialSystem_Config_t
600602
config.SetFlag( MATSYS_VIDCFG_FLAGS_WINDOWED, false );
601603
}
602604

605+
// Check window is borderless
606+
if ( CommandLine()->FindParm( "-noborder" ) )
607+
{
608+
config.SetFlag( MATSYS_VIDCFG_FLAGS_BORDERLESS, true );
609+
}
610+
603611
// Get width and height
604612
if ( CommandLine()->FindParm( "-width" ) || CommandLine()->FindParm( "-w" ) )
605613
{
@@ -859,6 +867,7 @@ void GetMaterialSystemConfigForBenchmarkUpload(KeyValues *dataToUpload)
859867
dataToUpload->SetInt( "ShadowDepthTexture", g_pMaterialSystemConfig->ShadowDepthTexture() );
860868
dataToUpload->SetInt( "MotionBlur", g_pMaterialSystemConfig->MotionBlur() );
861869
dataToUpload->SetInt( "Windowed", (g_pMaterialSystemConfig->m_Flags & MATSYS_VIDCFG_FLAGS_WINDOWED) ? 1 : 0 );
870+
dataToUpload->SetInt( "Borderless", (g_pMaterialSystemConfig->m_Flags & MATSYS_VIDCFG_FLAGS_BORDERLESS) ? 1 : 0 );
862871
dataToUpload->SetInt( "Trilinear", (g_pMaterialSystemConfig->m_Flags & MATSYS_VIDCFG_FLAGS_FORCE_TRILINEAR) ? 1 : 0 );
863872
dataToUpload->SetInt( "ForceHWSync", (g_pMaterialSystemConfig->m_Flags & MATSYS_VIDCFG_FLAGS_FORCE_HWSYNC) ? 1 : 0 );
864873
dataToUpload->SetInt( "NoWaitForVSync", (g_pMaterialSystemConfig->m_Flags & MATSYS_VIDCFG_FLAGS_NO_WAIT_FOR_VSYNC) ? 1 : 0 );
@@ -891,6 +900,7 @@ void PrintMaterialSystemConfig( const MaterialSystem_Config_t &config )
891900
Warning( "dxSupportLevel: %d\n", config.dxSupportLevel );
892901
Warning( "monitorGamma: %f\n", config.m_fMonitorGamma );
893902
Warning( "MATSYS_VIDCFG_FLAGS_WINDOWED: %s\n", ( config.m_Flags & MATSYS_VIDCFG_FLAGS_WINDOWED ) ? "true" : "false" );
903+
Warning( "MATSYS_VIDCFG_FLAGS_BORDERLESS: %s\n", ( config.m_Flags & MATSYS_VIDCFG_FLAGS_BORDERLESS ) ? "true" : "false" );
894904
Warning( "MATSYS_VIDCFG_FLAGS_FORCE_TRILINEAR: %s\n", ( config.m_Flags & MATSYS_VIDCFG_FLAGS_FORCE_TRILINEAR ) ? "true" : "false" );
895905
Warning( "MATSYS_VIDCFG_FLAGS_FORCE_HWSYNC: %s\n", ( config.m_Flags & MATSYS_VIDCFG_FLAGS_FORCE_HWSYNC ) ? "true" : "false" );
896906
Warning( "MATSYS_VIDCFG_FLAGS_DISABLE_SPECULAR: %s\n", ( config.m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_SPECULAR ) ? "true" : "false" );
@@ -913,16 +923,22 @@ CON_COMMAND( mat_configcurrent, "show the current video control panel config for
913923
}
914924

915925
#if !defined(SWDS) && !defined( _X360 )
916-
CON_COMMAND( mat_setvideomode, "sets the width, height, windowed state of the material system" )
926+
CON_COMMAND( mat_setvideomode, "sets the width, height, windowed state and optional borderless state of the material system" )
917927
{
918-
if ( args.ArgC() != 4 )
928+
if ( args.ArgC() < 4 || args.ArgC() > 5 )
919929
return;
920930

921931
int nWidth = Q_atoi( args[1] );
922932
int nHeight = Q_atoi( args[2] );
923-
bool bWindowed = Q_atoi( args[3] ) > 0 ? true : false;
933+
bool bWindowed = Q_atoi( args[3] ) > 0;
934+
bool bBorderless = args.ArgC() == 5 && Q_atoi( args[4] ) > 0;
935+
936+
if ( !bWindowed && bBorderless )
937+
{
938+
Warning( "Can't set borderless state when not windowed.\n" );
939+
}
924940

925-
videomode->SetMode( nWidth, nHeight, bWindowed );
941+
videomode->SetMode( nWidth, nHeight, bWindowed, bBorderless );
926942
}
927943
#endif
928944

engine/sys_dll2.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,9 +1670,12 @@ bool CEngineAPI::ModInit( const char *pModName, const char *pGameDir )
16701670
bool bWindowed = g_pMaterialSystemConfig->Windowed() ||
16711671
// at init time we never want to start up full screen
16721672
g_pMaterialSystemConfig->m_nVRModeAdapter != UINT_MAX;
1673+
bool bBorderless = g_pMaterialSystemConfig->Borderless() ||
1674+
// at init time we never want to start up full screen
1675+
g_pMaterialSystemConfig->m_nVRModeAdapter != UINT_MAX;
16731676

16741677
return videomode &&
1675-
videomode->CreateGameWindow( width, height, bWindowed );
1678+
videomode->CreateGameWindow( width, height, bWindowed, bBorderless );
16761679
}
16771680

16781681
void CEngineAPI::ModShutdown()

0 commit comments

Comments
 (0)