Browse Source

engine: always read and set vid_fullscreen value directly with it's object

pull/2/head
Alibek Omarov 1 year ago
parent
commit
05560c7607
  1. 2
      common/defaults.h
  2. 1
      engine/client/input.c
  3. 4
      engine/client/ref_common.c
  4. 10
      engine/platform/sdl/vid_sdl.c

2
common/defaults.h

@ -204,7 +204,7 @@ Default build-depended cvar and constant values @@ -204,7 +204,7 @@ Default build-depended cvar and constant values
#endif // DEFAULT_ALLOWCONSOLE
#ifndef DEFAULT_FULLSCREEN
#define DEFAULT_FULLSCREEN 1
#define DEFAULT_FULLSCREEN "1" // must be a string
#endif // DEFAULT_FULLSCREEN
#endif // DEFAULTS_H

1
engine/client/input.c

@ -36,7 +36,6 @@ static struct inputstate_s @@ -36,7 +36,6 @@ static struct inputstate_s
float lastpitch, lastyaw;
} inputstate;
extern convar_t *vid_fullscreen;
convar_t *m_pitch;
convar_t *m_yaw;

4
engine/client/ref_common.c

@ -557,11 +557,11 @@ static void SetFullscreenModeFromCommandLine( void ) @@ -557,11 +557,11 @@ static void SetFullscreenModeFromCommandLine( void )
#if !XASH_MOBILE_PLATFORM
if( Sys_CheckParm( "-fullscreen" ))
{
Cvar_Set( "fullscreen", "1" );
Cvar_DirectSet( vid_fullscreen, "1" );
}
else if( Sys_CheckParm( "-windowed" ))
{
Cvar_Set( "fullscreen", "0" );
Cvar_DirectSet( vid_fullscreen, "0" );
}
#endif
}

10
engine/platform/sdl/vid_sdl.c

@ -596,7 +596,7 @@ static qboolean VID_SetScreenResolution( int width, int height ) @@ -596,7 +596,7 @@ static qboolean VID_SetScreenResolution( int width, int height )
void VID_RestoreScreenResolution( void )
{
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !Cvar_VariableInteger("fullscreen") )
if( !vid_fullscreen->value )
{
SDL_SetWindowBordered( host.hWnd, SDL_TRUE );
}
@ -1117,7 +1117,6 @@ Set the described video mode @@ -1117,7 +1117,6 @@ Set the described video mode
*/
qboolean VID_SetMode( void )
{
qboolean fullscreen = false;
int iScreenWidth, iScreenHeight;
rserr_t err;
@ -1146,14 +1145,13 @@ qboolean VID_SetMode( void ) @@ -1146,14 +1145,13 @@ qboolean VID_SetMode( void )
}
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN );
Cvar_DirectSet( vid_fullscreen, DEFAULT_FULLSCREEN );
else
ClearBits( vid_fullscreen->flags, FCVAR_CHANGED );
SetBits( gl_vsync->flags, FCVAR_CHANGED );
fullscreen = Cvar_VariableInteger("fullscreen") != 0;
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, fullscreen )) == rserr_ok )
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, vid_fullscreen->value )) == rserr_ok )
{
sdlState.prev_width = iScreenWidth;
sdlState.prev_height = iScreenHeight;
@ -1162,7 +1160,7 @@ qboolean VID_SetMode( void ) @@ -1162,7 +1160,7 @@ qboolean VID_SetMode( void )
{
if( err == rserr_invalid_fullscreen )
{
Cvar_SetValue( "fullscreen", 0 );
Cvar_DirectSet( vid_fullscreen, "0" );
Con_Reportf( S_ERROR "VID_SetMode: fullscreen unavailable in this mode\n" );
Sys_Warn("fullscreen unavailable in this mode!");
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, false )) == rserr_ok )

Loading…
Cancel
Save