Browse Source

cvar: don't change cvars without FCVAR_GLCONFIG variable during opengl.cfg reading

pull/2/head
Alibek Omarov 6 years ago
parent
commit
0801922466
  1. 4
      engine/client/vid_common.c
  2. 28
      engine/common/cvar.c

4
engine/client/vid_common.c

@ -473,8 +473,8 @@ void GL_InitCommands( void ) @@ -473,8 +473,8 @@ void GL_InitCommands( void )
gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
gl_test = Cvar_Get( "gl_test", "0", 0, "engine developer cvar for quick testing new features" );
gl_wireframe = Cvar_Get( "gl_wireframe", "0", FCVAR_ARCHIVE|FCVAR_SPONLY, "show wireframe overlay" );
gl_wgl_msaa_samples = Cvar_Get( "gl_wgl_msaa_samples", "4", FCVAR_GLCONFIG, "enable multisample anti-aliasing" );
gl_msaa = Cvar_Get( "gl_msaa", "2", FCVAR_ARCHIVE, "enable multi sample anti-aliasing" );
gl_wgl_msaa_samples = Cvar_Get( "gl_wgl_msaa_samples", "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
gl_msaa = Cvar_Get( "gl_msaa", "1", FCVAR_ARCHIVE, "enable or disable multisample anti-aliasing" );
gl_stencilbits = Cvar_Get( "gl_stencilbits", "8", FCVAR_GLCONFIG, "pixelformat stencil bits (0 - auto)" );
gl_round_down = Cvar_Get( "gl_round_down", "2", FCVAR_RENDERINFO, "round texture sizes to nearest POT value" );
// these cvar not used by engine but some mods requires this

28
engine/common/cvar.c

@ -710,6 +710,26 @@ void Cvar_SetCheatState( void ) @@ -710,6 +710,26 @@ void Cvar_SetCheatState( void )
}
}
/*
============
Cvar_SetGL
As Cvar_Set, but also flags it as glconfig
============
*/
static void Cvar_SetGL( const char *name, const char *value )
{
convar_t *var = Cvar_FindVar( name );
if( var && !FBitSet( var->flags, FCVAR_GLCONFIG ))
{
Con_Reportf( S_ERROR "Can't set non-GL cvar %s to %s\n", name, value );
return;
}
Cvar_FullSet( name, value, FCVAR_GLCONFIG );
}
/*
============
Cvar_Command
@ -722,7 +742,7 @@ qboolean Cvar_Command( convar_t *v ) @@ -722,7 +742,7 @@ qboolean Cvar_Command( convar_t *v )
// special case for setup opengl configuration
if( host.apply_opengl_config )
{
Cvar_FullSet( Cmd_Argv( 0 ), Cmd_Argv( 1 ), FCVAR_GLCONFIG );
Cvar_SetGL( Cmd_Argv( 0 ), Cmd_Argv( 1 ) );
return true;
}
@ -811,13 +831,15 @@ As Cvar_Set, but also flags it as glconfig @@ -811,13 +831,15 @@ As Cvar_Set, but also flags it as glconfig
*/
void Cvar_SetGL_f( void )
{
convar_t *var;
if( Cmd_Argc() != 3 )
{
Con_Printf( S_USAGE "setgl <variable> <value>\n" );
return;
}
Cvar_FullSet( Cmd_Argv( 1 ), Cmd_Argv( 2 ), FCVAR_GLCONFIG );
Cvar_SetGL( Cmd_Argv( 1 ), Cmd_Argv( 2 ) );
}
/*
@ -910,7 +932,7 @@ void Cvar_Init( void ) @@ -910,7 +932,7 @@ void Cvar_Init( void )
cmd_scripting = Cvar_Get( "cmd_scripting", "0", FCVAR_ARCHIVE, "enable simple condition checking and variable operations" );
Cvar_RegisterVariable (&host_developer); // early registering for dev
Cmd_AddCommand( "setgl", Cvar_SetGL_f, "create or change the value of a opengl variable" ); // OBSOLETE
Cmd_AddCommand( "setgl", Cvar_SetGL_f, "change the value of a opengl variable" ); // OBSOLETE
Cmd_AddCommand( "toggle", Cvar_Toggle_f, "toggles a console variable's values (use for more info)" );
Cmd_AddCommand( "reset", Cvar_Reset_f, "reset any type variable to initial value" );
Cmd_AddCommand( "cvarlist", Cvar_List_f, "display all console variables beginning with the specified prefix" );

Loading…
Cancel
Save