From 9244bdc7dbf9e754be48e3351e6fbbc642904f11 Mon Sep 17 00:00:00 2001 From: SNMetamorph Date: Thu, 21 Nov 2024 23:17:30 +0400 Subject: [PATCH] ref: gl: added gl_fog cvar for better GoldSrc compatibility --- ref/gl/gl_local.h | 1 + ref/gl/gl_opengl.c | 2 ++ ref/gl/gl_rmain.c | 5 +++-- ref/gl/gl_triapi.c | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index 6ca3a7e9a..c999c20e8 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -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; diff --git a/ref/gl/gl_opengl.c b/ref/gl/gl_opengl.c index a632364ba..fa9a1a807 100644 --- a/ref/gl/gl_opengl.c +++ b/ref/gl/gl_opengl.c @@ -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" ); @@ -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 ); diff --git a/ref/gl/gl_rmain.c b/ref/gl/gl_rmain.c index 69a63dfa1..1a307233a 100644 --- a/ref/gl/gl_rmain.c +++ b/ref/gl/gl_rmain.c @@ -44,7 +44,7 @@ void R_AllowFog( qboolean allowed ) { if( allowed ) { - if( glState.isFogEnabled ) + if( glState.isFogEnabled && gl_fog.value ) pglEnable( GL_FOG ); } else @@ -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 )) diff --git a/ref/gl/gl_triapi.c b/ref/gl/gl_triapi.c index 2c23c2f6b..db05e5184 100644 --- a/ref/gl/gl_triapi.c +++ b/ref/gl/gl_triapi.c @@ -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