Skip to content

Commit

Permalink
ref: gl: added gl_fog cvar for better GoldSrc compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SNMetamorph authored and a1batross committed Nov 21, 2024
1 parent 0db2597 commit 9244bdc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions ref/gl/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ extern convar_t gl_test; // cvar to testify new effects
extern convar_t gl_msaa;
extern convar_t gl_stencilbits;
extern convar_t gl_overbright;
extern convar_t gl_fog;

extern convar_t r_lighting_extended;
extern convar_t r_lighting_ambient;
Expand Down
2 changes: 2 additions & 0 deletions ref/gl/gl_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CVAR_DEFINE_AUTO( gl_test, "0", 0, "engine developer cvar for quick testing new
CVAR_DEFINE_AUTO( gl_msaa, "1", FCVAR_GLCONFIG, "enable or disable multisample anti-aliasing" );
CVAR_DEFINE_AUTO( gl_stencilbits, "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" );
CVAR_DEFINE_AUTO( gl_overbright, "1", FCVAR_GLCONFIG, "overbrights" );
CVAR_DEFINE_AUTO( gl_fog, "1", FCVAR_GLCONFIG, "allow for rendering fog using built-in OpenGL fog implementation" );
CVAR_DEFINE_AUTO( r_lighting_extended, "1", FCVAR_GLCONFIG, "allow to get lighting from world and bmodels" );
CVAR_DEFINE_AUTO( r_lighting_ambient, "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" );
CVAR_DEFINE_AUTO( r_detailtextures, "1", FCVAR_GLCONFIG, "enable detail textures support" );
Expand Down Expand Up @@ -1208,6 +1209,7 @@ static void GL_InitCommands( void )
gEngfuncs.Cvar_RegisterVariable( &gl_stencilbits );
gEngfuncs.Cvar_RegisterVariable( &gl_round_down );
gEngfuncs.Cvar_RegisterVariable( &gl_overbright );
gEngfuncs.Cvar_RegisterVariable( &gl_fog );

// these cvar not used by engine but some mods requires this
gEngfuncs.Cvar_RegisterVariable( &gl_polyoffset );
Expand Down
5 changes: 3 additions & 2 deletions ref/gl/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void R_AllowFog( qboolean allowed )
{
if( allowed )
{
if( glState.isFogEnabled )
if( glState.isFogEnabled && gl_fog.value )
pglEnable( GL_FOG );
}
else
Expand Down Expand Up @@ -800,7 +800,8 @@ R_DrawFog
*/
void R_DrawFog( void )
{
if( !RI.fogEnabled ) return;
if( !RI.fogEnabled || !gl_fog.value )
return;

pglEnable( GL_FOG );
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
Expand Down
2 changes: 1 addition & 1 deletion ref/gl/gl_triapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ enables global fog on the level
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
{
// overrided by internal fog
if( RI.fogEnabled ) return;
if( RI.fogEnabled || !gl_fog.value ) return;
RI.fogCustom = bOn;

// check for invalid parms
Expand Down

0 comments on commit 9244bdc

Please sign in to comment.