Browse Source

ref: gl: move ref_gl cvars to static allocation

pull/2/head
Alibek Omarov 1 year ago
parent
commit
3a57f26351
  1. 2
      ref/gl/gl_cull.c
  2. 5
      ref/gl/gl_dbghulls.c
  3. 12
      ref/gl/gl_decals.c
  4. 4
      ref/gl/gl_frustum.c
  5. 36
      ref/gl/gl_image.c
  6. 63
      ref/gl/gl_local.h
  7. 133
      ref/gl/gl_opengl.c
  8. 6
      ref/gl/gl_rlight.c
  9. 14
      ref/gl/gl_rmain.c
  10. 2
      ref/gl/gl_rmisc.c
  11. 54
      ref/gl/gl_rsurf.c
  12. 2
      ref/gl/gl_sprite.c
  13. 12
      ref/gl/gl_studio.c

2
ref/gl/gl_cull.c

@ -73,7 +73,7 @@ int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags )
if( !surf || !surf->texinfo || !surf->texinfo->texture ) if( !surf || !surf->texinfo || !surf->texinfo->texture )
return CULL_OTHER; return CULL_OTHER;
if( r_nocull->value ) if( r_nocull.value )
return CULL_VISIBLE; return CULL_VISIBLE;
// world surfaces can be culled by vis frame too // world surfaces can be culled by vis frame too

5
ref/gl/gl_dbghulls.c

@ -39,8 +39,9 @@ void R_DrawWorldHull( void )
ClearBits( r_showhull->flags, FCVAR_CHANGED ); ClearBits( r_showhull->flags, FCVAR_CHANGED );
} }
if( !CVAR_TO_BOOL( r_showhull )) if( !r_showhull->flags )
return; return;
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain ) list_for_each_entry( poly, &hull->polys, chain )
@ -61,7 +62,7 @@ void R_DrawModelHull( void )
winding_t *poly; winding_t *poly;
int i; int i;
if( !CVAR_TO_BOOL( r_showhull )) if( !r_showhull->flags )
return; return;
if( !RI.currentmodel || RI.currentmodel->name[0] != '*' ) if( !RI.currentmodel || RI.currentmodel->name[0] != '*' )

12
ref/gl/gl_decals.c

@ -927,10 +927,10 @@ void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse )
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_NONE ); GL_Cull( GL_NONE );
if( gl_polyoffset->value ) if( gl_polyoffset.value )
{ {
pglEnable( GL_POLYGON_OFFSET_FILL ); pglEnable( GL_POLYGON_OFFSET_FILL );
pglPolygonOffset( -1.0f, -gl_polyoffset->value ); pglPolygonOffset( -1.0f, -gl_polyoffset.value );
} }
} }
@ -1020,7 +1020,7 @@ void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse )
pglEnable( GL_ALPHA_TEST ); pglEnable( GL_ALPHA_TEST );
} }
if( gl_polyoffset->value ) if( gl_polyoffset.value )
pglDisable( GL_POLYGON_OFFSET_FILL ); pglDisable( GL_POLYGON_OFFSET_FILL );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
@ -1058,10 +1058,10 @@ void DrawDecalsBatch( void )
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_NONE ); GL_Cull( GL_NONE );
if( gl_polyoffset->value ) if( gl_polyoffset.value )
{ {
pglEnable( GL_POLYGON_OFFSET_FILL ); pglEnable( GL_POLYGON_OFFSET_FILL );
pglPolygonOffset( -1.0f, -gl_polyoffset->value ); pglPolygonOffset( -1.0f, -gl_polyoffset.value );
} }
for( i = 0; i < tr.num_draw_decals; i++ ) for( i = 0; i < tr.num_draw_decals; i++ )
@ -1076,7 +1076,7 @@ void DrawDecalsBatch( void )
pglDisable( GL_ALPHA_TEST ); pglDisable( GL_ALPHA_TEST );
} }
if( gl_polyoffset->value ) if( gl_polyoffset.value )
pglDisable( GL_POLYGON_OFFSET_FILL ); pglDisable( GL_POLYGON_OFFSET_FILL );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )

4
ref/gl/gl_frustum.c

@ -102,7 +102,7 @@ qboolean GL_FrustumCullBox( gl_frustum_t *out, const vec3_t mins, const vec3_t m
int iClipFlags; int iClipFlags;
int i, bit; int i, bit;
if( r_nocull->value ) if( r_nocull.value )
return false; return false;
if( userClipFlags != 0 ) if( userClipFlags != 0 )
@ -163,7 +163,7 @@ qboolean GL_FrustumCullSphere( gl_frustum_t *out, const vec3_t center, float rad
int iClipFlags; int iClipFlags;
int i, bit; int i, bit;
if( r_nocull->value ) if( r_nocull.value )
return false; return false;
if( userClipFlags != 0 ) if( userClipFlags != 0 )

36
ref/gl/gl_image.c

@ -167,7 +167,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
} }
else if( FBitSet( tex->flags, TF_NOMIPMAP ) || tex->numMips <= 1 ) else if( FBitSet( tex->flags, TF_NOMIPMAP ) || tex->numMips <= 1 )
{ {
if( FBitSet( tex->flags, TF_NEAREST ) || ( IsLightMap( tex ) && gl_lightmap_nearest->value )) if( FBitSet( tex->flags, TF_NEAREST ) || ( IsLightMap( tex ) && gl_lightmap_nearest.value ))
{ {
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
@ -180,7 +180,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
} }
else else
{ {
if( FBitSet( tex->flags, TF_NEAREST ) || gl_texture_nearest->value ) if( FBitSet( tex->flags, TF_NEAREST ) || gl_texture_nearest.value )
{ {
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
@ -193,11 +193,11 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
// set texture anisotropy if available // set texture anisotropy if available
if( GL_Support( GL_ANISOTROPY_EXT ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_ALPHACONTRAST )) if( GL_Support( GL_ANISOTROPY_EXT ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_ALPHACONTRAST ))
pglTexParameterf( tex->target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_anisotropy->value ); pglTexParameterf( tex->target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_anisotropy.value );
// set texture LOD bias if available // set texture LOD bias if available
if( GL_Support( GL_TEXTURE_LOD_BIAS ) && ( tex->numMips > 1 )) if( GL_Support( GL_TEXTURE_LOD_BIAS ) && ( tex->numMips > 1 ))
pglTexParameterf( tex->target, GL_TEXTURE_LOD_BIAS_EXT, gl_texture_lodbias->value ); pglTexParameterf( tex->target, GL_TEXTURE_LOD_BIAS_EXT, gl_texture_lodbias.value );
} }
// check if border is not supported // check if border is not supported
@ -276,15 +276,15 @@ static void GL_UpdateTextureParams( int iTexture )
// set texture anisotropy if available // set texture anisotropy if available
if( GL_Support( GL_ANISOTROPY_EXT ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_DEPTHMAP|TF_ALPHACONTRAST )) if( GL_Support( GL_ANISOTROPY_EXT ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_DEPTHMAP|TF_ALPHACONTRAST ))
pglTexParameterf( tex->target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_anisotropy->value ); pglTexParameterf( tex->target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_anisotropy.value );
// set texture LOD bias if available // set texture LOD bias if available
if( GL_Support( GL_TEXTURE_LOD_BIAS ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_DEPTHMAP )) if( GL_Support( GL_TEXTURE_LOD_BIAS ) && ( tex->numMips > 1 ) && !FBitSet( tex->flags, TF_DEPTHMAP ))
pglTexParameterf( tex->target, GL_TEXTURE_LOD_BIAS_EXT, gl_texture_lodbias->value ); pglTexParameterf( tex->target, GL_TEXTURE_LOD_BIAS_EXT, gl_texture_lodbias.value );
if( IsLightMap( tex )) if( IsLightMap( tex ))
{ {
if( gl_lightmap_nearest->value ) if( gl_lightmap_nearest.value )
{ {
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
@ -298,7 +298,7 @@ static void GL_UpdateTextureParams( int iTexture )
if( tex->numMips <= 1 ) return; if( tex->numMips <= 1 ) return;
if( FBitSet( tex->flags, TF_NEAREST ) || gl_texture_nearest->value ) if( FBitSet( tex->flags, TF_NEAREST ) || gl_texture_nearest.value )
{ {
pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST );
pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); pglTexParameteri( tex->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
@ -321,24 +321,24 @@ void R_SetTextureParameters( void )
if( GL_Support( GL_ANISOTROPY_EXT )) if( GL_Support( GL_ANISOTROPY_EXT ))
{ {
if( gl_texture_anisotropy->value > glConfig.max_texture_anisotropy ) if( gl_texture_anisotropy.value > glConfig.max_texture_anisotropy )
gEngfuncs.Cvar_SetValue( "gl_anisotropy", glConfig.max_texture_anisotropy ); gEngfuncs.Cvar_SetValue( "gl_anisotropy", glConfig.max_texture_anisotropy );
else if( gl_texture_anisotropy->value < 1.0f ) else if( gl_texture_anisotropy.value < 1.0f )
gEngfuncs.Cvar_SetValue( "gl_anisotropy", 1.0f ); gEngfuncs.Cvar_SetValue( "gl_anisotropy", 1.0f );
} }
if( GL_Support( GL_TEXTURE_LOD_BIAS )) if( GL_Support( GL_TEXTURE_LOD_BIAS ))
{ {
if( gl_texture_lodbias->value < -glConfig.max_texture_lod_bias ) if( gl_texture_lodbias.value < -glConfig.max_texture_lod_bias )
gEngfuncs.Cvar_SetValue( "gl_texture_lodbias", -glConfig.max_texture_lod_bias ); gEngfuncs.Cvar_SetValue( "gl_texture_lodbias", -glConfig.max_texture_lod_bias );
else if( gl_texture_lodbias->value > glConfig.max_texture_lod_bias ) else if( gl_texture_lodbias.value > glConfig.max_texture_lod_bias )
gEngfuncs.Cvar_SetValue( "gl_texture_lodbias", glConfig.max_texture_lod_bias ); gEngfuncs.Cvar_SetValue( "gl_texture_lodbias", glConfig.max_texture_lod_bias );
} }
ClearBits( gl_texture_anisotropy->flags, FCVAR_CHANGED ); ClearBits( gl_texture_anisotropy.flags, FCVAR_CHANGED );
ClearBits( gl_texture_lodbias->flags, FCVAR_CHANGED ); ClearBits( gl_texture_lodbias.flags, FCVAR_CHANGED );
ClearBits( gl_texture_nearest->flags, FCVAR_CHANGED ); ClearBits( gl_texture_nearest.flags, FCVAR_CHANGED );
ClearBits( gl_lightmap_nearest->flags, FCVAR_CHANGED ); ClearBits( gl_lightmap_nearest.flags, FCVAR_CHANGED );
// change all the existing mipmapped texture objects // change all the existing mipmapped texture objects
for( i = 0; i < gl_numTextures; i++ ) for( i = 0; i < gl_numTextures; i++ )
@ -577,7 +577,7 @@ static void GL_SetTextureDimensions( gl_texture_t *tex, int width, int height, i
if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT )) if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
{ {
int step = (int)gl_round_down->value; int step = (int)gl_round_down.value;
int scaled_width, scaled_height; int scaled_width, scaled_height;
for( scaled_width = 1; scaled_width < width; scaled_width <<= 1 ); for( scaled_width = 1; scaled_width < width; scaled_width <<= 1 );
@ -1140,7 +1140,7 @@ static void GL_CheckTexImageError( gl_texture_t *tex )
Assert( tex != NULL ); Assert( tex != NULL );
// catch possible errors // catch possible errors
if( CVAR_TO_BOOL( gl_check_errors ) && ( err = pglGetError()) != GL_NO_ERROR ) if( gl_check_errors.value && ( err = pglGetError()) != GL_NO_ERROR )
gEngfuncs.Con_Printf( S_OPENGL_ERROR "%s while uploading %s [%s]\n", GL_ErrorString( err ), tex->name, GL_TargetToString( tex->target )); gEngfuncs.Con_Printf( S_OPENGL_ERROR "%s while uploading %s [%s]\n", GL_ErrorString( err ), tex->name, GL_TargetToString( tex->target ));
} }

63
ref/gl/gl_local.h

@ -31,7 +31,7 @@ GNU General Public License for more details.
#include "enginefeatures.h" #include "enginefeatures.h"
#include "com_strings.h" #include "com_strings.h"
#include "pm_movevars.h" #include "pm_movevars.h"
//#include "cvar.h" #include "common/cvar.h"
#include "gl_export.h" #include "gl_export.h"
#include "wadfile.h" #include "wadfile.h"
@ -54,10 +54,6 @@ void VGL_ShimEndFrame( void );
#include <stdio.h> #include <stdio.h>
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) cvar_t cv = { cvname, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) cvar_t cv = { #cv, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
#define CVAR_TO_BOOL( x ) ((x) && ((x)->value != 0.0f) ? true : false )
#define WORLD (gEngfuncs.GetWorld()) #define WORLD (gEngfuncs.GetWorld())
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 )) #define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars()) #define MOVEVARS (gEngfuncs.pfnGetMoveVars())
@ -713,36 +709,33 @@ extern ref_globals_t *gpGlobals;
// //
// renderer cvars // renderer cvars
// //
extern cvar_t *gl_texture_anisotropy; extern convar_t gl_texture_anisotropy;
extern cvar_t *gl_extensions; extern convar_t gl_extensions;
extern cvar_t *gl_check_errors; extern convar_t gl_check_errors;
extern cvar_t *gl_texture_lodbias; extern convar_t gl_texture_lodbias;
extern cvar_t *gl_texture_nearest; extern convar_t gl_texture_nearest;
extern cvar_t *gl_lightmap_nearest; extern convar_t gl_lightmap_nearest;
extern cvar_t *gl_keeptjunctions; extern convar_t gl_keeptjunctions;
extern cvar_t *gl_round_down; extern convar_t gl_round_down;
extern cvar_t *gl_wireframe; extern convar_t gl_wireframe;
extern cvar_t *gl_polyoffset; extern convar_t gl_polyoffset;
extern cvar_t *gl_finish; extern convar_t gl_finish;
extern cvar_t *gl_nosort; extern convar_t gl_nosort;
extern cvar_t *gl_clear; extern convar_t gl_test; // cvar to testify new effects
extern cvar_t *gl_test; // cvar to testify new effects extern convar_t gl_msaa;
extern cvar_t *gl_msaa; extern convar_t gl_stencilbits;
extern cvar_t *gl_stencilbits;
extern convar_t r_lighting_extended;
extern cvar_t *r_lighting_extended; extern convar_t r_lighting_ambient;
extern cvar_t *r_lighting_modulate; extern convar_t r_studio_lambert;
extern cvar_t *r_lighting_ambient; extern convar_t r_detailtextures;
extern cvar_t *r_studio_lambert; extern convar_t r_novis;
extern cvar_t *r_detailtextures; extern convar_t r_nocull;
extern cvar_t *r_drawentities; extern convar_t r_lockpvs;
extern cvar_t *r_novis; extern convar_t r_lockfrustum;
extern cvar_t *r_nocull; extern convar_t r_traceglow;
extern cvar_t *r_lockpvs; extern convar_t r_vbo;
extern cvar_t *r_lockfrustum; extern convar_t r_vbo_dlightmode;
extern cvar_t *r_traceglow;
extern cvar_t *r_vbo;
extern cvar_t *r_vbo_dlightmode;
// //

133
ref/gl/gl_opengl.c

@ -5,40 +5,31 @@
#include "gl4es/include/gl4eshint.h" #include "gl4es/include/gl4eshint.h"
#endif // XASH_GL4ES #endif // XASH_GL4ES
cvar_t *gl_extensions; CVAR_DEFINE( gl_extensions, "gl_allow_extensions", "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "allow gl_extensions" );
cvar_t *gl_texture_anisotropy; CVAR_DEFINE( gl_texture_anisotropy, "gl_anisotropy", "8", FCVAR_GLCONFIG, "textures anisotropic filter" );
cvar_t *gl_texture_lodbias; CVAR_DEFINE_AUTO( gl_texture_lodbias, "0.0", FCVAR_GLCONFIG, "LOD bias for mipmapped textures (perfomance|quality)" );
cvar_t *gl_texture_nearest; CVAR_DEFINE_AUTO( gl_texture_nearest, "0", FCVAR_GLCONFIG, "disable texture filter" );
cvar_t *gl_lightmap_nearest; CVAR_DEFINE_AUTO( gl_lightmap_nearest, "0", FCVAR_GLCONFIG, "disable lightmap filter" );
cvar_t *gl_keeptjunctions; CVAR_DEFINE_AUTO( gl_keeptjunctions, "1", FCVAR_GLCONFIG, "removing tjuncs causes blinking pixels" );
cvar_t *gl_check_errors; CVAR_DEFINE_AUTO( gl_check_errors, "1", FCVAR_GLCONFIG, "ignore video engine errors" );
cvar_t *gl_polyoffset; CVAR_DEFINE_AUTO( gl_polyoffset, "2.0", FCVAR_GLCONFIG, "polygon offset for decals" );
cvar_t *gl_wireframe; CVAR_DEFINE_AUTO( gl_wireframe, "0", FCVAR_GLCONFIG|FCVAR_SPONLY, "show wireframe overlay" );
cvar_t *gl_finish; CVAR_DEFINE_AUTO( gl_finish, "0", FCVAR_GLCONFIG, "use glFinish instead of glFlush" );
cvar_t *gl_nosort; CVAR_DEFINE_AUTO( gl_nosort, "0", FCVAR_GLCONFIG, "disable sorting of translucent surfaces" );
cvar_t *gl_vsync; CVAR_DEFINE_AUTO( gl_test, "0", 0, "engine developer cvar for quick testing new features" );
cvar_t *gl_clear; CVAR_DEFINE_AUTO( gl_msaa, "1", FCVAR_GLCONFIG, "enable or disable multisample anti-aliasing" );
cvar_t *gl_test; CVAR_DEFINE_AUTO( gl_stencilbits, "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" );
cvar_t *gl_msaa; CVAR_DEFINE_AUTO( r_lighting_extended, "1", FCVAR_GLCONFIG, "allow to get lighting from world and bmodels" );
cvar_t *gl_stencilbits; CVAR_DEFINE_AUTO( r_lighting_ambient, "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" );
cvar_t *r_lighting_extended; CVAR_DEFINE_AUTO( r_detailtextures, "1", FCVAR_ARCHIVE, "enable detail textures support" );
cvar_t *r_lighting_modulate; CVAR_DEFINE_AUTO( r_novis, "0", 0, "ignore vis information (perfomance test)" );
cvar_t *r_lighting_ambient; CVAR_DEFINE_AUTO( r_nocull, "0", 0, "ignore frustrum culling (perfomance test)" );
cvar_t *r_detailtextures; CVAR_DEFINE_AUTO( r_lockpvs, "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" );
cvar_t *r_novis; CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" );
cvar_t *r_nocull; CVAR_DEFINE_AUTO( r_traceglow, "1", FCVAR_GLCONFIG, "cull flares behind models" );
cvar_t *r_lockpvs; CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
cvar_t *r_lockfrustum; CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
cvar_t *r_traceglow; CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
cvar_t *r_dynamic;
cvar_t *gl_round_down;
cvar_t *r_vbo;
cvar_t *r_vbo_dlightmode;
cvar_t *tracerred;
cvar_t *tracergreen;
cvar_t *tracerblue;
cvar_t *traceralpha;
DEFINE_ENGINE_SHARED_CVAR_LIST() DEFINE_ENGINE_SHARED_CVAR_LIST()
@ -345,7 +336,7 @@ qboolean GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char
parm = gEngfuncs.Cvar_Get( cvarname, "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, desc ); parm = gEngfuncs.Cvar_Get( cvarname, "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, desc );
} }
if(( parm && !CVAR_TO_BOOL( parm )) || ( !CVAR_TO_BOOL( gl_extensions ) && r_ext != GL_OPENGL_110 )) if(( parm && !parm->value ) || ( !gl_extensions.value && r_ext != GL_OPENGL_110 ))
{ {
gEngfuncs.Con_Reportf( "- disabled\n" ); gEngfuncs.Con_Reportf( "- disabled\n" );
GL_SetExtension( r_ext, false ); GL_SetExtension( r_ext, false );
@ -807,7 +798,7 @@ void GL_InitExtensions( void )
Q_snprintf( value, sizeof( value ), "%i", glConfig.max_2d_texture_size ); Q_snprintf( value, sizeof( value ), "%i", glConfig.max_2d_texture_size );
gEngfuncs.Cvar_Get( "gl_max_size", value, 0, "opengl texture max dims" ); gEngfuncs.Cvar_Get( "gl_max_size", value, 0, "opengl texture max dims" );
gEngfuncs.Cvar_SetValue( "gl_anisotropy", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )); gEngfuncs.Cvar_SetValue( "gl_anisotropy", bound( 0, gl_texture_anisotropy.value, glConfig.max_texture_anisotropy ));
if( GL_Support( GL_TEXTURE_COMPRESSION_EXT )) if( GL_Support( GL_TEXTURE_COMPRESSION_EXT ))
gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE ); gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE );
@ -846,33 +837,32 @@ void GL_InitCommands( void )
{ {
RETRIEVE_ENGINE_SHARED_CVAR_LIST(); RETRIEVE_ENGINE_SHARED_CVAR_LIST();
r_lighting_extended = gEngfuncs.Cvar_Get( "r_lighting_extended", "1", FCVAR_GLCONFIG, "allow to get lighting from world and bmodels" ); gEngfuncs.Cvar_RegisterVariable( &r_lighting_extended );
r_lighting_modulate = gEngfuncs.Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_GLCONFIG, "lightstyles modulate scale" ); gEngfuncs.Cvar_RegisterVariable( &r_lighting_ambient );
r_lighting_ambient = gEngfuncs.Cvar_Get( "r_lighting_ambient", "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" ); gEngfuncs.Cvar_RegisterVariable( &r_novis );
r_novis = gEngfuncs.Cvar_Get( "r_novis", "0", 0, "ignore vis information (perfomance test)" ); gEngfuncs.Cvar_RegisterVariable( &r_nocull );
r_nocull = gEngfuncs.Cvar_Get( "r_nocull", "0", 0, "ignore frustrum culling (perfomance test)" ); gEngfuncs.Cvar_RegisterVariable( &r_detailtextures );
r_detailtextures = gEngfuncs.Cvar_Get( "r_detailtextures", "1", FCVAR_ARCHIVE, "enable detail textures support" ); gEngfuncs.Cvar_RegisterVariable( &r_lockpvs );
r_lockpvs = gEngfuncs.Cvar_Get( "r_lockpvs", "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" ); gEngfuncs.Cvar_RegisterVariable( &r_lockfrustum );
r_lockfrustum = gEngfuncs.Cvar_Get( "r_lockfrustum", "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" ); gEngfuncs.Cvar_RegisterVariable( &r_traceglow );
r_traceglow = gEngfuncs.Cvar_Get( "r_traceglow", "1", FCVAR_GLCONFIG, "cull flares behind models" );
gEngfuncs.Cvar_RegisterVariable( &gl_extensions );
gl_extensions = gEngfuncs.Cvar_Get( "gl_allow_extensions", "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "allow gl_extensions" ); gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest );
gl_texture_nearest = gEngfuncs.Cvar_Get( "gl_texture_nearest", "0", FCVAR_GLCONFIG, "disable texture filter" ); gEngfuncs.Cvar_RegisterVariable( &gl_lightmap_nearest );
gl_lightmap_nearest = gEngfuncs.Cvar_Get( "gl_lightmap_nearest", "0", FCVAR_GLCONFIG, "disable lightmap filter" ); gEngfuncs.Cvar_RegisterVariable( &gl_check_errors );
gl_check_errors = gEngfuncs.Cvar_Get( "gl_check_errors", "1", FCVAR_GLCONFIG, "ignore video engine errors" ); gEngfuncs.Cvar_RegisterVariable( &gl_texture_anisotropy );
gl_texture_anisotropy = gEngfuncs.Cvar_Get( "gl_anisotropy", "8", FCVAR_GLCONFIG, "textures anisotropic filter" ); gEngfuncs.Cvar_RegisterVariable( &gl_texture_lodbias );
gl_texture_lodbias = gEngfuncs.Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_GLCONFIG, "LOD bias for mipmapped textures (perfomance|quality)" ); gEngfuncs.Cvar_RegisterVariable( &gl_keeptjunctions );
gl_keeptjunctions = gEngfuncs.Cvar_Get( "gl_keeptjunctions", "1", FCVAR_GLCONFIG, "removing tjuncs causes blinking pixels" ); gEngfuncs.Cvar_RegisterVariable( &gl_finish );
gl_finish = gEngfuncs.Cvar_Get( "gl_finish", "0", FCVAR_GLCONFIG, "use glFinish instead of glFlush" ); gEngfuncs.Cvar_RegisterVariable( &gl_nosort );
gl_nosort = gEngfuncs.Cvar_Get( "gl_nosort", "0", FCVAR_GLCONFIG, "disable sorting of translucent surfaces" ); gEngfuncs.Cvar_RegisterVariable( &gl_test );
gl_test = gEngfuncs.Cvar_Get( "gl_test", "0", 0, "engine developer cvar for quick testing new features" ); gEngfuncs.Cvar_RegisterVariable( &gl_wireframe );
gl_wireframe = gEngfuncs.Cvar_Get( "gl_wireframe", "0", FCVAR_GLCONFIG|FCVAR_SPONLY, "show wireframe overlay" ); gEngfuncs.Cvar_RegisterVariable( &gl_msaa );
gl_msaa = gEngfuncs.Cvar_Get( "gl_msaa", "1", FCVAR_GLCONFIG, "enable or disable multisample anti-aliasing" ); gEngfuncs.Cvar_RegisterVariable( &gl_stencilbits );
gl_stencilbits = gEngfuncs.Cvar_Get( "gl_stencilbits", "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" ); gEngfuncs.Cvar_RegisterVariable( &gl_round_down );
gl_round_down = gEngfuncs.Cvar_Get( "gl_round_down", "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
// these cvar not used by engine but some mods requires this // these cvar not used by engine but some mods requires this
gl_polyoffset = gEngfuncs.Cvar_Get( "gl_polyoffset", "2.0", FCVAR_GLCONFIG, "polygon offset for decals" ); gEngfuncs.Cvar_RegisterVariable( &gl_polyoffset );
// make sure gl_vsync is checked after vid_restart // make sure gl_vsync is checked after vid_restart
SetBits( gl_vsync->flags, FCVAR_CHANGED ); SetBits( gl_vsync->flags, FCVAR_CHANGED );
@ -890,9 +880,6 @@ register VBO cvars and get default value
*/ */
static void R_CheckVBO( void ) static void R_CheckVBO( void )
{ {
const char *def = "0";
const char *dlightmode = "1";
int flags = FCVAR_ARCHIVE;
qboolean disable = false; qboolean disable = false;
// some bad GLES1 implementations breaks dlights completely // some bad GLES1 implementations breaks dlights completely
@ -904,21 +891,17 @@ static void R_CheckVBO( void )
// Disable it, as there is no suitable workaround here // Disable it, as there is no suitable workaround here
if( Q_stristr( glConfig.renderer_string, "VideoCore IV" ) || Q_stristr( glConfig.renderer_string, "vc4" ) ) if( Q_stristr( glConfig.renderer_string, "VideoCore IV" ) || Q_stristr( glConfig.renderer_string, "vc4" ) )
disable = true; disable = true;
// dlightmode 1 is not too much tested on android
// so better to left it off
dlightmode = "0";
#endif #endif
if( disable ) if( disable )
{ {
// do not keep in config unless dev > 3 and enabled r_vbo.flags = r_vbo_dlightmode.flags = 0;
flags = 0; r_vbo.string = "0";
def = "0"; r_vbo_dlightmode.string = "0";
} }
r_vbo = gEngfuncs.Cvar_Get( "gl_vbo", def, flags, "draw world using VBO (known to be glitchy)" ); gEngfuncs.Cvar_RegisterVariable( &r_vbo );
r_vbo_dlightmode = gEngfuncs.Cvar_Get( "gl_vbo_dlightmode", dlightmode, FCVAR_ARCHIVE, "vbo dlight rendering mode(0-1)" ); gEngfuncs.Cvar_RegisterVariable( &r_vbo_dlightmode );
} }
/* /*
@ -1030,7 +1013,7 @@ void GL_CheckForErrors_( const char *filename, const int fileline )
{ {
int err; int err;
if( !CVAR_TO_BOOL( gl_check_errors )) if( !gl_check_errors.value )
return; return;
if(( err = pglGetError( )) == GL_NO_ERROR ) if(( err = pglGetError( )) == GL_NO_ERROR )
@ -1099,7 +1082,7 @@ void GL_SetupAttributes( int safegl )
gEngfuncs.Con_Printf( "bpp %d\n", gpGlobals->desktopBitsPixel ); gEngfuncs.Con_Printf( "bpp %d\n", gpGlobals->desktopBitsPixel );
if( safegl < SAFE_NOSTENCIL ) if( safegl < SAFE_NOSTENCIL )
gEngfuncs.GL_SetAttribute( REF_GL_STENCIL_SIZE, gl_stencilbits->value ); gEngfuncs.GL_SetAttribute( REF_GL_STENCIL_SIZE, gl_stencilbits.value );
if( safegl < SAFE_NOALPHA ) if( safegl < SAFE_NOALPHA )
gEngfuncs.GL_SetAttribute( REF_GL_ALPHA_SIZE, 8 ); gEngfuncs.GL_SetAttribute( REF_GL_ALPHA_SIZE, 8 );

6
ref/gl/gl_rlight.c

@ -74,7 +74,7 @@ void CL_RunLightStyles( void )
tr.lightstylevalue[i] = ls->map[0] * 22 * scale; tr.lightstylevalue[i] = ls->map[0] * 22 * scale;
continue; continue;
} }
else if( !ls->interp || !CVAR_TO_BOOL( cl_lightstyle_lerping )) else if( !ls->interp || !cl_lightstyle_lerping->flags )
{ {
tr.lightstylevalue[i] = ls->map[flight%ls->length] * 22 * scale; tr.lightstylevalue[i] = ls->map[flight%ls->length] * 22 * scale;
continue; continue;
@ -376,7 +376,7 @@ colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t lspot,
last_fraction = 1.0f; last_fraction = 1.0f;
// get light from bmodels too // get light from bmodels too
if( CVAR_TO_BOOL( r_lighting_extended )) if( r_lighting_extended.value )
maxEnts = MAX_PHYSENTS; maxEnts = MAX_PHYSENTS;
// check all the bsp-models // check all the bsp-models
@ -448,7 +448,7 @@ colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t
{ {
colorVec light = R_LightVecInternal( start, end, lspot, lvec ); colorVec light = R_LightVecInternal( start, end, lspot, lvec );
if( CVAR_TO_BOOL( r_lighting_extended ) && lspot != NULL && lvec != NULL ) if( r_lighting_extended.value && lspot != NULL && lvec != NULL )
{ {
// trying to get light from ceiling (but ignore gradient analyze) // trying to get light from ceiling (but ignore gradient analyze)
if(( light.r + light.g + light.b ) == 0 ) if(( light.r + light.g + light.b ) == 0 )

14
ref/gl/gl_rmain.c

@ -345,7 +345,7 @@ void R_SetupFrustum( void )
// build the transformation matrix for the given view angles // build the transformation matrix for the given view angles
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup ); AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
if( !r_lockfrustum->value ) if( !r_lockfrustum.value )
{ {
VectorCopy( RI.vieworg, RI.cullorigin ); VectorCopy( RI.vieworg, RI.cullorigin );
VectorCopy( RI.vforward, RI.cull_vforward ); VectorCopy( RI.vforward, RI.cull_vforward );
@ -495,7 +495,7 @@ static void R_SetupFrame( void )
// NOTE: this request is the fps-killer on some NVidia drivers // NOTE: this request is the fps-killer on some NVidia drivers
glState.isFogEnabled = pglIsEnabled( GL_FOG ); glState.isFogEnabled = pglIsEnabled( GL_FOG );
if( !gl_nosort->value ) if( !gl_nosort.value )
{ {
// sort translucents entities by rendermode and distance // sort translucents entities by rendermode and distance
qsort( tr.draw_list->trans_entities, tr.draw_list->num_trans_entities, sizeof( cl_entity_t* ), R_TransEntityCompare ); qsort( tr.draw_list->trans_entities, tr.draw_list->num_trans_entities, sizeof( cl_entity_t* ), R_TransEntityCompare );
@ -1030,7 +1030,7 @@ void R_BeginFrame( qboolean clearScene )
pglDrawBuffer( GL_BACK ); pglDrawBuffer( GL_BACK );
// update texture parameters // update texture parameters
if( FBitSet( gl_texture_nearest->flags|gl_lightmap_nearest->flags|gl_texture_anisotropy->flags|gl_texture_lodbias->flags, FCVAR_CHANGED )) if( FBitSet( gl_texture_nearest.flags|gl_lightmap_nearest.flags|gl_texture_anisotropy.flags|gl_texture_lodbias.flags, FCVAR_CHANGED ))
R_SetTextureParameters(); R_SetTextureParameters();
gEngfuncs.CL_ExtraUpdate (); gEngfuncs.CL_ExtraUpdate ();
@ -1082,15 +1082,15 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
// setup the initial render params // setup the initial render params
R_SetupRefParams( rvp ); R_SetupRefParams( rvp );
if( gl_finish->value && RI.drawWorld ) if( gl_finish.value && RI.drawWorld )
pglFinish(); pglFinish();
if( glConfig.max_multisamples > 1 && FBitSet( gl_msaa->flags, FCVAR_CHANGED )) if( glConfig.max_multisamples > 1 && FBitSet( gl_msaa.flags, FCVAR_CHANGED ))
{ {
if( CVAR_TO_BOOL( gl_msaa )) if( gl_msaa.value )
pglEnable( GL_MULTISAMPLE_ARB ); pglEnable( GL_MULTISAMPLE_ARB );
else pglDisable( GL_MULTISAMPLE_ARB ); else pglDisable( GL_MULTISAMPLE_ARB );
ClearBits( gl_msaa->flags, FCVAR_CHANGED ); ClearBits( gl_msaa.flags, FCVAR_CHANGED );
} }
// completely override rendering // completely override rendering

2
ref/gl/gl_rmisc.c

@ -113,7 +113,7 @@ void R_NewMap( void )
R_StudioResetPlayerModels(); R_StudioResetPlayerModels();
// upload detailtextures // upload detailtextures
if( CVAR_TO_BOOL( r_detailtextures )) if( r_detailtextures.value )
{ {
string mapname, filepath; string mapname, filepath;

54
ref/gl/gl_rsurf.c

@ -214,8 +214,8 @@ void GL_SetupFogColorForSurfaces( void )
return; return;
} }
div = (r_detailtextures->value) ? 2.0f : 1.0f; div = (r_detailtextures.value) ? 2.0f : 1.0f;
factor = (r_detailtextures->value) ? 3.0f : 2.0f; factor = (r_detailtextures.value) ? 3.0f : 2.0f;
fogColor[0] = pow( RI.fogColor[0] / div, ( 1.0f / factor )); fogColor[0] = pow( RI.fogColor[0] / div, ( 1.0f / factor ));
fogColor[1] = pow( RI.fogColor[1] / div, ( 1.0f / factor )); fogColor[1] = pow( RI.fogColor[1] / div, ( 1.0f / factor ));
fogColor[2] = pow( RI.fogColor[2] / div, ( 1.0f / factor )); fogColor[2] = pow( RI.fogColor[2] / div, ( 1.0f / factor ));
@ -355,7 +355,7 @@ void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa )
} }
// remove co-linear points - Ed // remove co-linear points - Ed
if( !CVAR_TO_BOOL( gl_keeptjunctions ) && !FBitSet( fa->flags, SURF_UNDERWATER )) if( !gl_keeptjunctions.value && !FBitSet( fa->flags, SURF_UNDERWATER ))
{ {
for( i = 0; i < lnumverts; i++ ) for( i = 0; i < lnumverts; i++ )
{ {
@ -879,7 +879,7 @@ void DrawGLPolyChain( glpoly_t *p, float soffset, float toffset )
_inline qboolean R_HasLightmap( void ) _inline qboolean R_HasLightmap( void )
{ {
if( CVAR_TO_BOOL( r_fullbright ) || !WORLDMODEL->lightdata ) if( r_fullbright->value || !WORLDMODEL->lightdata )
return false; return false;
if( RI.currententity ) if( RI.currententity )
@ -916,7 +916,7 @@ void R_BlendLightmaps( void )
GL_SetupFogColorForSurfaces (); GL_SetupFogColorForSurfaces ();
if( !CVAR_TO_BOOL( r_lightmap )) if( !r_lightmap->value )
pglEnable( GL_BLEND ); pglEnable( GL_BLEND );
else pglDisable( GL_BLEND ); else pglDisable( GL_BLEND );
@ -943,7 +943,7 @@ void R_BlendLightmaps( void )
} }
// render dynamic lightmaps // render dynamic lightmaps
if( CVAR_TO_BOOL( r_dynamic )) if( r_dynamic->value )
{ {
LM_InitBlock(); LM_InitBlock();
@ -1153,7 +1153,7 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type )
draw_fullbrights = true; draw_fullbrights = true;
} }
if( CVAR_TO_BOOL( r_detailtextures )) if( r_detailtextures.value )
{ {
if( glState.isFogEnabled ) if( glState.isFogEnabled )
{ {
@ -1522,7 +1522,7 @@ void R_DrawBrushModel( cl_entity_t *e )
model_t *clmodel; model_t *clmodel;
qboolean rotated; qboolean rotated;
dlight_t *l; dlight_t *l;
qboolean allow_vbo = CVAR_TO_BOOL( r_vbo ); qboolean allow_vbo = r_vbo.value;
if( !RI.drawWorld ) return; if( !RI.drawWorld ) return;
@ -1627,7 +1627,7 @@ void R_DrawBrushModel( cl_entity_t *e )
} }
// sort faces if needs // sort faces if needs
if( !FBitSet( clmodel->flags, MODEL_LIQUID ) && e->curstate.rendermode == kRenderTransTexture && !CVAR_TO_BOOL( gl_nosort )) if( !FBitSet( clmodel->flags, MODEL_LIQUID ) && e->curstate.rendermode == kRenderTransTexture && !gl_nosort.value )
qsort( gpGlobals->draw_surfaces, num_sorted, sizeof( sortedface_t ), R_SurfaceCompare ); qsort( gpGlobals->draw_surfaces, num_sorted, sizeof( sortedface_t ), R_SurfaceCompare );
// draw sorted translucent surfaces // draw sorted translucent surfaces
@ -1803,8 +1803,8 @@ void R_GenerateVBO( void )
} }
// save in config if enabled manually // save in config if enabled manually
if( CVAR_TO_BOOL( r_vbo ) ) if( r_vbo.value )
r_vbo->flags |= FCVAR_ARCHIVE; r_vbo.flags |= FCVAR_ARCHIVE;
vbos.mempool = Mem_AllocPool("Render VBO Zone"); vbos.mempool = Mem_AllocPool("Render VBO Zone");
@ -1979,7 +1979,7 @@ void R_GenerateVBO( void )
// select maximum possible length for dlight // select maximum possible length for dlight
vbos.dlight_tc = Mem_Calloc( vbos.mempool, sizeof( vec2_t ) * (int)(vbos.arraylist->next?USHRT_MAX + 1:vbos.arraylist->array_len + 1) ); vbos.dlight_tc = Mem_Calloc( vbos.mempool, sizeof( vec2_t ) * (int)(vbos.arraylist->next?USHRT_MAX + 1:vbos.arraylist->array_len + 1) );
if( CVAR_TO_BOOL(r_vbo_dlightmode) ) if( r_vbo_dlightmode.value )
{ {
pglGenBuffersARB( 1, &vbos.dlight_vbo ); pglGenBuffersARB( 1, &vbos.dlight_vbo );
pglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbos.dlight_vbo ); pglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbos.dlight_vbo );
@ -2176,7 +2176,7 @@ static texture_t *R_SetupVBOTexture( texture_t *tex, int number )
if( !tex ) if( !tex )
tex = R_TextureAnim( WORLDMODEL->textures[number] ); tex = R_TextureAnim( WORLDMODEL->textures[number] );
if( CVAR_TO_BOOL( r_detailtextures ) && tex->dt_texturenum && mtst.tmu_dt != -1 ) if( r_detailtextures.value && tex->dt_texturenum && mtst.tmu_dt != -1 )
{ {
mtst.details_enabled = true; mtst.details_enabled = true;
GL_Bind( mtst.tmu_dt, tex->dt_texturenum ); GL_Bind( mtst.tmu_dt, tex->dt_texturenum );
@ -2185,7 +2185,7 @@ static texture_t *R_SetupVBOTexture( texture_t *tex, int number )
} }
else R_DisableDetail(); else R_DisableDetail();
GL_Bind( mtst.tmu_gl, CVAR_TO_BOOL( r_lightmap )?tr.whiteTexture:tex->gl_texturenum ); GL_Bind( mtst.tmu_gl, r_lightmap->value ?tr.whiteTexture:tex->gl_texturenum );
return tex; return tex;
} }
@ -2200,7 +2200,7 @@ draw details when not enough tmus
static void R_AdditionalPasses( vboarray_t *vbo, int indexlen, void *indexarray, texture_t *tex, qboolean resetvbo ) static void R_AdditionalPasses( vboarray_t *vbo, int indexlen, void *indexarray, texture_t *tex, qboolean resetvbo )
{ {
// draw details in additional pass // draw details in additional pass
if( r_detailtextures->value && mtst.tmu_dt == -1 && tex->dt_texturenum ) if( r_detailtextures.value && mtst.tmu_dt == -1 && tex->dt_texturenum )
{ {
gl_texture_t *glt = R_GetTexture( tex->gl_texturenum ); gl_texture_t *glt = R_GetTexture( tex->gl_texturenum );
@ -2266,7 +2266,7 @@ static void R_DrawLightmappedVBO( vboarray_t *vbo, vbotexture_t *vbotex, texture
R_AdditionalPasses( vbo, vbotex->curindex, vbotex->indexarray, texture, false ); R_AdditionalPasses( vbo, vbotex->curindex, vbotex->indexarray, texture, false );
// draw debug lines // draw debug lines
if( CVAR_TO_BOOL(gl_wireframe) && !skiplighting ) if( gl_wireframe.value && !skiplighting )
{ {
R_SetDecalMode( true ); R_SetDecalMode( true );
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
@ -2640,7 +2640,7 @@ void R_DrawVBO( qboolean drawlightmap, qboolean drawtextures )
int k; int k;
vboarray_t *vbo = vbos.arraylist; vboarray_t *vbo = vbos.arraylist;
if( !CVAR_TO_BOOL( r_vbo ) ) if( !r_vbo.value )
return; return;
// bind array // bind array
@ -2969,7 +2969,7 @@ static qboolean R_CheckLightMap( msurface_t *fa )
qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap ) qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap )
{ {
if( CVAR_TO_BOOL(r_vbo) && vbos.surfdata[surf - WORLDMODEL->surfaces].vbotexture ) if( r_vbo.value && vbos.surfdata[surf - WORLDMODEL->surfaces].vbotexture )
{ {
// find vbotexture_t assotiated with this surface // find vbotexture_t assotiated with this surface
int idx = surf - WORLDMODEL->surfaces; int idx = surf - WORLDMODEL->surfaces;
@ -2988,7 +2988,7 @@ qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap )
if( vbos.mintexture > texturenum ) if( vbos.mintexture > texturenum )
vbos.mintexture = texturenum; vbos.mintexture = texturenum;
buildlightmap &= !CVAR_TO_BOOL( r_fullbright ) && !!WORLDMODEL->lightdata; buildlightmap &= !r_fullbright->value && !!WORLDMODEL->lightdata;
if( buildlightmap && R_CheckLightMap( surf ) ) if( buildlightmap && R_CheckLightMap( surf ) )
{ {
@ -3047,7 +3047,7 @@ loc0:
if( node->visframe != tr.visframecount ) if( node->visframe != tr.visframecount )
return; return;
if( clipflags && !CVAR_TO_BOOL( r_nocull )) if( clipflags && !r_nocull.value )
{ {
for( i = 0; i < 6; i++ ) for( i = 0; i < 6; i++ )
{ {
@ -3198,7 +3198,7 @@ void R_DrawWorldTopView( mnode_t *node, uint clipflags )
if( node->visframe != tr.visframecount ) if( node->visframe != tr.visframecount )
return; return;
if( clipflags && !r_nocull->value ) if( clipflags && !r_nocull.value )
{ {
for( i = 0; i < 6; i++ ) for( i = 0; i < 6; i++ )
{ {
@ -3262,7 +3262,7 @@ void R_DrawTriangleOutlines( void )
glpoly_t *p; glpoly_t *p;
float *v; float *v;
if( !gl_wireframe->value ) if( !gl_wireframe.value )
return; return;
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
@ -3347,7 +3347,7 @@ void R_DrawWorld( void )
r_stats.t_world_node = end - start; r_stats.t_world_node = end - start;
start = gEngfuncs.pfnTime(); start = gEngfuncs.pfnTime();
R_DrawVBO( !CVAR_TO_BOOL(r_fullbright) && !!WORLDMODEL->lightdata, true ); R_DrawVBO( !r_fullbright->value && !!WORLDMODEL->lightdata, true );
R_DrawTextureChains(); R_DrawTextureChains();
@ -3392,10 +3392,10 @@ void R_MarkLeaves( void )
if( !RI.drawWorld ) return; if( !RI.drawWorld ) return;
if( FBitSet( r_novis->flags, FCVAR_CHANGED ) || tr.fResetVis ) if( FBitSet( r_novis.flags, FCVAR_CHANGED ) || tr.fResetVis )
{ {
// force recalc viewleaf // force recalc viewleaf
ClearBits( r_novis->flags, FCVAR_CHANGED ); ClearBits( r_novis.flags, FCVAR_CHANGED );
tr.fResetVis = false; tr.fResetVis = false;
RI.viewleaf = NULL; RI.viewleaf = NULL;
} }
@ -3425,12 +3425,12 @@ void R_MarkLeaves( void )
// development aid to let you run around // development aid to let you run around
// and see exactly where the pvs ends // and see exactly where the pvs ends
if( r_lockpvs->value ) return; if( r_lockpvs.value ) return;
RI.oldviewleaf = RI.viewleaf; RI.oldviewleaf = RI.viewleaf;
tr.visframecount++; tr.visframecount++;
if( r_novis->value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata ) if( r_novis.value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true; novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis ); gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );

2
ref/gl/gl_sprite.c

@ -666,7 +666,7 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
if( RP_NORMALPASS( )) if( RP_NORMALPASS( ))
{ {
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow->value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE)); tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
if(( 1.0f - tr->fraction ) * dist > 8.0f ) if(( 1.0f - tr->fraction ) * dist > 8.0f )
return 0.0f; return 0.0f;

12
ref/gl/gl_studio.c

@ -121,9 +121,9 @@ typedef struct
} studio_draw_state_t; } studio_draw_state_t;
// studio-related cvars // studio-related cvars
static cvar_t *r_studio_sort_textures; static CVAR_DEFINE_AUTO( r_studio_sort_textures, "0", FCVAR_GLCONFIG, "change draw order for additive meshes" );
static cvar_t *cl_righthand = NULL; static cvar_t *cl_righthand = NULL;
static cvar_t *r_studio_drawelements; static CVAR_DEFINE_AUTO( r_studio_drawelements, "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
static r_studio_interface_t *pStudioDraw; static r_studio_interface_t *pStudioDraw;
static studio_draw_state_t g_studio; // global studio state static studio_draw_state_t g_studio; // global studio state
@ -146,8 +146,8 @@ R_StudioInit
*/ */
void R_StudioInit( void ) void R_StudioInit( void )
{ {
r_studio_sort_textures = gEngfuncs.Cvar_Get( "r_studio_sort_textures", "0", FCVAR_GLCONFIG, "change draw order for additive meshes" ); gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
r_studio_drawelements = gEngfuncs.Cvar_Get( "r_studio_drawelements", "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" ); gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
#if XASH_PSVITA #if XASH_PSVITA
// don't do the same array-building work twice since that's what our FFP shim does anyway // don't do the same array-building work twice since that's what our FFP shim does anyway
@ -2331,7 +2331,7 @@ static void R_StudioDrawPoints( void )
} }
} }
if( r_studio_sort_textures->value && need_sort ) if( r_studio_sort_textures.value && need_sort )
{ {
// resort opaque and translucent meshes draw order // resort opaque and translucent meshes draw order
qsort( g_studio.meshes, m_pSubModel->nummesh, sizeof( sortedmesh_t ), R_StudioMeshCompare ); qsort( g_studio.meshes, m_pSubModel->nummesh, sizeof( sortedmesh_t ), R_StudioMeshCompare );
@ -2378,7 +2378,7 @@ static void R_StudioDrawPoints( void )
R_StudioSetupSkin( m_pStudioHeader, pskinref[pmesh->skinref] ); R_StudioSetupSkin( m_pStudioHeader, pskinref[pmesh->skinref] );
if( CVAR_TO_BOOL(r_studio_drawelements) ) if( r_studio_drawelements.value )
{ {
if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME )) if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME ))
R_StudioBuildArrayChromeMesh( ptricmds, pstudionorms, s, t, shellscale ); R_StudioBuildArrayChromeMesh( ptricmds, pstudionorms, s, t, shellscale );

Loading…
Cancel
Save