2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 09:56:22 +01:00

ref: gl: move ref_gl cvars to static allocation

This commit is contained in:
Alibek Omarov 2023-05-20 20:27:15 +03:00
parent 7fd1534753
commit 3a57f26351
13 changed files with 159 additions and 182 deletions

View File

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

View File

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

View File

@ -927,10 +927,10 @@ void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse )
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_NONE );
if( gl_polyoffset->value )
if( gl_polyoffset.value )
{
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 );
}
if( gl_polyoffset->value )
if( gl_polyoffset.value )
pglDisable( GL_POLYGON_OFFSET_FILL );
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 )
GL_Cull( GL_NONE );
if( gl_polyoffset->value )
if( gl_polyoffset.value )
{
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++ )
@ -1076,7 +1076,7 @@ void DrawDecalsBatch( void )
pglDisable( GL_ALPHA_TEST );
}
if( gl_polyoffset->value )
if( gl_polyoffset.value )
pglDisable( GL_POLYGON_OFFSET_FILL );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )

View File

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

View File

@ -167,7 +167,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
}
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_MAG_FILTER, GL_NEAREST );
@ -180,7 +180,7 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
}
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_MAG_FILTER, GL_NEAREST );
@ -193,11 +193,11 @@ void GL_ApplyTextureParams( gl_texture_t *tex )
// set texture anisotropy if available
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
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
@ -276,15 +276,15 @@ static void GL_UpdateTextureParams( int iTexture )
// set texture anisotropy if available
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
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( gl_lightmap_nearest->value )
if( gl_lightmap_nearest.value )
{
pglTexParameteri( tex->target, GL_TEXTURE_MIN_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( 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_MAG_FILTER, GL_NEAREST );
@ -321,24 +321,24 @@ void R_SetTextureParameters( void )
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 );
else if( gl_texture_anisotropy->value < 1.0f )
else if( gl_texture_anisotropy.value < 1.0f )
gEngfuncs.Cvar_SetValue( "gl_anisotropy", 1.0f );
}
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 );
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 );
}
ClearBits( gl_texture_anisotropy->flags, FCVAR_CHANGED );
ClearBits( gl_texture_lodbias->flags, FCVAR_CHANGED );
ClearBits( gl_texture_nearest->flags, FCVAR_CHANGED );
ClearBits( gl_lightmap_nearest->flags, FCVAR_CHANGED );
ClearBits( gl_texture_anisotropy.flags, FCVAR_CHANGED );
ClearBits( gl_texture_lodbias.flags, FCVAR_CHANGED );
ClearBits( gl_texture_nearest.flags, FCVAR_CHANGED );
ClearBits( gl_lightmap_nearest.flags, FCVAR_CHANGED );
// change all the existing mipmapped texture objects
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 ))
{
int step = (int)gl_round_down->value;
int step = (int)gl_round_down.value;
int scaled_width, scaled_height;
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 );
// 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 ));
}

View File

@ -31,7 +31,7 @@ GNU General Public License for more details.
#include "enginefeatures.h"
#include "com_strings.h"
#include "pm_movevars.h"
//#include "cvar.h"
#include "common/cvar.h"
#include "gl_export.h"
#include "wadfile.h"
@ -54,10 +54,6 @@ void VGL_ShimEndFrame( void );
#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 WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
@ -713,36 +709,33 @@ extern ref_globals_t *gpGlobals;
//
// renderer cvars
//
extern cvar_t *gl_texture_anisotropy;
extern cvar_t *gl_extensions;
extern cvar_t *gl_check_errors;
extern cvar_t *gl_texture_lodbias;
extern cvar_t *gl_texture_nearest;
extern cvar_t *gl_lightmap_nearest;
extern cvar_t *gl_keeptjunctions;
extern cvar_t *gl_round_down;
extern cvar_t *gl_wireframe;
extern cvar_t *gl_polyoffset;
extern cvar_t *gl_finish;
extern cvar_t *gl_nosort;
extern cvar_t *gl_clear;
extern cvar_t *gl_test; // cvar to testify new effects
extern cvar_t *gl_msaa;
extern cvar_t *gl_stencilbits;
extern convar_t gl_texture_anisotropy;
extern convar_t gl_extensions;
extern convar_t gl_check_errors;
extern convar_t gl_texture_lodbias;
extern convar_t gl_texture_nearest;
extern convar_t gl_lightmap_nearest;
extern convar_t gl_keeptjunctions;
extern convar_t gl_round_down;
extern convar_t gl_wireframe;
extern convar_t gl_polyoffset;
extern convar_t gl_finish;
extern convar_t gl_nosort;
extern convar_t gl_test; // cvar to testify new effects
extern convar_t gl_msaa;
extern convar_t gl_stencilbits;
extern cvar_t *r_lighting_extended;
extern cvar_t *r_lighting_modulate;
extern cvar_t *r_lighting_ambient;
extern cvar_t *r_studio_lambert;
extern cvar_t *r_detailtextures;
extern cvar_t *r_drawentities;
extern cvar_t *r_novis;
extern cvar_t *r_nocull;
extern cvar_t *r_lockpvs;
extern cvar_t *r_lockfrustum;
extern cvar_t *r_traceglow;
extern cvar_t *r_vbo;
extern cvar_t *r_vbo_dlightmode;
extern convar_t r_lighting_extended;
extern convar_t r_lighting_ambient;
extern convar_t r_studio_lambert;
extern convar_t r_detailtextures;
extern convar_t r_novis;
extern convar_t r_nocull;
extern convar_t r_lockpvs;
extern convar_t r_lockfrustum;
extern convar_t r_traceglow;
extern convar_t r_vbo;
extern convar_t r_vbo_dlightmode;
//

View File

@ -5,40 +5,31 @@
#include "gl4es/include/gl4eshint.h"
#endif // XASH_GL4ES
cvar_t *gl_extensions;
cvar_t *gl_texture_anisotropy;
cvar_t *gl_texture_lodbias;
cvar_t *gl_texture_nearest;
cvar_t *gl_lightmap_nearest;
cvar_t *gl_keeptjunctions;
cvar_t *gl_check_errors;
cvar_t *gl_polyoffset;
cvar_t *gl_wireframe;
cvar_t *gl_finish;
cvar_t *gl_nosort;
cvar_t *gl_vsync;
cvar_t *gl_clear;
cvar_t *gl_test;
cvar_t *gl_msaa;
cvar_t *gl_stencilbits;
cvar_t *r_lighting_extended;
cvar_t *r_lighting_modulate;
cvar_t *r_lighting_ambient;
cvar_t *r_detailtextures;
cvar_t *r_novis;
cvar_t *r_nocull;
cvar_t *r_lockpvs;
cvar_t *r_lockfrustum;
cvar_t *r_traceglow;
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;
CVAR_DEFINE( gl_extensions, "gl_allow_extensions", "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "allow gl_extensions" );
CVAR_DEFINE( gl_texture_anisotropy, "gl_anisotropy", "8", FCVAR_GLCONFIG, "textures anisotropic filter" );
CVAR_DEFINE_AUTO( gl_texture_lodbias, "0.0", FCVAR_GLCONFIG, "LOD bias for mipmapped textures (perfomance|quality)" );
CVAR_DEFINE_AUTO( gl_texture_nearest, "0", FCVAR_GLCONFIG, "disable texture filter" );
CVAR_DEFINE_AUTO( gl_lightmap_nearest, "0", FCVAR_GLCONFIG, "disable lightmap filter" );
CVAR_DEFINE_AUTO( gl_keeptjunctions, "1", FCVAR_GLCONFIG, "removing tjuncs causes blinking pixels" );
CVAR_DEFINE_AUTO( gl_check_errors, "1", FCVAR_GLCONFIG, "ignore video engine errors" );
CVAR_DEFINE_AUTO( gl_polyoffset, "2.0", FCVAR_GLCONFIG, "polygon offset for decals" );
CVAR_DEFINE_AUTO( gl_wireframe, "0", FCVAR_GLCONFIG|FCVAR_SPONLY, "show wireframe overlay" );
CVAR_DEFINE_AUTO( gl_finish, "0", FCVAR_GLCONFIG, "use glFinish instead of glFlush" );
CVAR_DEFINE_AUTO( gl_nosort, "0", FCVAR_GLCONFIG, "disable sorting of translucent surfaces" );
CVAR_DEFINE_AUTO( gl_test, "0", 0, "engine developer cvar for quick testing new features" );
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( 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_ARCHIVE, "enable detail textures support" );
CVAR_DEFINE_AUTO( r_novis, "0", 0, "ignore vis information (perfomance test)" );
CVAR_DEFINE_AUTO( r_nocull, "0", 0, "ignore frustrum culling (perfomance test)" );
CVAR_DEFINE_AUTO( r_lockpvs, "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" );
CVAR_DEFINE_AUTO( r_lockfrustum, "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" );
CVAR_DEFINE_AUTO( r_traceglow, "1", FCVAR_GLCONFIG, "cull flares behind models" );
CVAR_DEFINE_AUTO( gl_round_down, "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
CVAR_DEFINE( r_vbo, "gl_vbo", "0", FCVAR_ARCHIVE, "draw world using VBO (known to be glitchy)" );
CVAR_DEFINE( r_vbo_dlightmode, "gl_vbo_dlightmode", "1", FCVAR_ARCHIVE, "vbo dlight rendering mode (0-1)" );
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 );
}
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" );
GL_SetExtension( r_ext, false );
@ -807,7 +798,7 @@ void GL_InitExtensions( void )
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_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 ))
gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE );
@ -846,33 +837,32 @@ void GL_InitCommands( void )
{
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" );
r_lighting_modulate = gEngfuncs.Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_GLCONFIG, "lightstyles modulate scale" );
r_lighting_ambient = gEngfuncs.Cvar_Get( "r_lighting_ambient", "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" );
r_novis = gEngfuncs.Cvar_Get( "r_novis", "0", 0, "ignore vis information (perfomance test)" );
r_nocull = gEngfuncs.Cvar_Get( "r_nocull", "0", 0, "ignore frustrum culling (perfomance test)" );
r_detailtextures = gEngfuncs.Cvar_Get( "r_detailtextures", "1", FCVAR_ARCHIVE, "enable detail textures support" );
r_lockpvs = gEngfuncs.Cvar_Get( "r_lockpvs", "0", FCVAR_CHEAT, "lockpvs area at current point (pvs test)" );
r_lockfrustum = gEngfuncs.Cvar_Get( "r_lockfrustum", "0", FCVAR_CHEAT, "lock frustrum area at current point (cull test)" );
r_traceglow = gEngfuncs.Cvar_Get( "r_traceglow", "1", FCVAR_GLCONFIG, "cull flares behind models" );
gEngfuncs.Cvar_RegisterVariable( &r_lighting_extended );
gEngfuncs.Cvar_RegisterVariable( &r_lighting_ambient );
gEngfuncs.Cvar_RegisterVariable( &r_novis );
gEngfuncs.Cvar_RegisterVariable( &r_nocull );
gEngfuncs.Cvar_RegisterVariable( &r_detailtextures );
gEngfuncs.Cvar_RegisterVariable( &r_lockpvs );
gEngfuncs.Cvar_RegisterVariable( &r_lockfrustum );
gEngfuncs.Cvar_RegisterVariable( &r_traceglow );
gl_extensions = gEngfuncs.Cvar_Get( "gl_allow_extensions", "1", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "allow gl_extensions" );
gl_texture_nearest = gEngfuncs.Cvar_Get( "gl_texture_nearest", "0", FCVAR_GLCONFIG, "disable texture filter" );
gl_lightmap_nearest = gEngfuncs.Cvar_Get( "gl_lightmap_nearest", "0", FCVAR_GLCONFIG, "disable lightmap filter" );
gl_check_errors = gEngfuncs.Cvar_Get( "gl_check_errors", "1", FCVAR_GLCONFIG, "ignore video engine errors" );
gl_texture_anisotropy = gEngfuncs.Cvar_Get( "gl_anisotropy", "8", FCVAR_GLCONFIG, "textures anisotropic filter" );
gl_texture_lodbias = gEngfuncs.Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_GLCONFIG, "LOD bias for mipmapped textures (perfomance|quality)" );
gl_keeptjunctions = gEngfuncs.Cvar_Get( "gl_keeptjunctions", "1", FCVAR_GLCONFIG, "removing tjuncs causes blinking pixels" );
gl_finish = gEngfuncs.Cvar_Get( "gl_finish", "0", FCVAR_GLCONFIG, "use glFinish instead of glFlush" );
gl_nosort = gEngfuncs.Cvar_Get( "gl_nosort", "0", FCVAR_GLCONFIG, "disable sorting of translucent surfaces" );
gl_test = gEngfuncs.Cvar_Get( "gl_test", "0", 0, "engine developer cvar for quick testing new features" );
gl_wireframe = gEngfuncs.Cvar_Get( "gl_wireframe", "0", FCVAR_GLCONFIG|FCVAR_SPONLY, "show wireframe overlay" );
gl_msaa = gEngfuncs.Cvar_Get( "gl_msaa", "1", FCVAR_GLCONFIG, "enable or disable multisample anti-aliasing" );
gl_stencilbits = gEngfuncs.Cvar_Get( "gl_stencilbits", "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" );
gl_round_down = gEngfuncs.Cvar_Get( "gl_round_down", "2", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "round texture sizes to nearest POT value" );
gEngfuncs.Cvar_RegisterVariable( &gl_extensions );
gEngfuncs.Cvar_RegisterVariable( &gl_texture_nearest );
gEngfuncs.Cvar_RegisterVariable( &gl_lightmap_nearest );
gEngfuncs.Cvar_RegisterVariable( &gl_check_errors );
gEngfuncs.Cvar_RegisterVariable( &gl_texture_anisotropy );
gEngfuncs.Cvar_RegisterVariable( &gl_texture_lodbias );
gEngfuncs.Cvar_RegisterVariable( &gl_keeptjunctions );
gEngfuncs.Cvar_RegisterVariable( &gl_finish );
gEngfuncs.Cvar_RegisterVariable( &gl_nosort );
gEngfuncs.Cvar_RegisterVariable( &gl_test );
gEngfuncs.Cvar_RegisterVariable( &gl_wireframe );
gEngfuncs.Cvar_RegisterVariable( &gl_msaa );
gEngfuncs.Cvar_RegisterVariable( &gl_stencilbits );
gEngfuncs.Cvar_RegisterVariable( &gl_round_down );
// 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
SetBits( gl_vsync->flags, FCVAR_CHANGED );
@ -890,9 +880,6 @@ register VBO cvars and get default value
*/
static void R_CheckVBO( void )
{
const char *def = "0";
const char *dlightmode = "1";
int flags = FCVAR_ARCHIVE;
qboolean disable = false;
// 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
if( Q_stristr( glConfig.renderer_string, "VideoCore IV" ) || Q_stristr( glConfig.renderer_string, "vc4" ) )
disable = true;
// dlightmode 1 is not too much tested on android
// so better to left it off
dlightmode = "0";
#endif
if( disable )
{
// do not keep in config unless dev > 3 and enabled
flags = 0;
def = "0";
r_vbo.flags = r_vbo_dlightmode.flags = 0;
r_vbo.string = "0";
r_vbo_dlightmode.string = "0";
}
r_vbo = gEngfuncs.Cvar_Get( "gl_vbo", def, flags, "draw world using VBO (known to be glitchy)" );
r_vbo_dlightmode = gEngfuncs.Cvar_Get( "gl_vbo_dlightmode", dlightmode, FCVAR_ARCHIVE, "vbo dlight rendering mode(0-1)" );
gEngfuncs.Cvar_RegisterVariable( &r_vbo );
gEngfuncs.Cvar_RegisterVariable( &r_vbo_dlightmode );
}
/*
@ -1030,7 +1013,7 @@ void GL_CheckForErrors_( const char *filename, const int fileline )
{
int err;
if( !CVAR_TO_BOOL( gl_check_errors ))
if( !gl_check_errors.value )
return;
if(( err = pglGetError( )) == GL_NO_ERROR )
@ -1099,7 +1082,7 @@ void GL_SetupAttributes( int safegl )
gEngfuncs.Con_Printf( "bpp %d\n", gpGlobals->desktopBitsPixel );
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 )
gEngfuncs.GL_SetAttribute( REF_GL_ALPHA_SIZE, 8 );

View File

@ -74,7 +74,7 @@ void CL_RunLightStyles( void )
tr.lightstylevalue[i] = ls->map[0] * 22 * scale;
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;
continue;
@ -376,7 +376,7 @@ colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t lspot,
last_fraction = 1.0f;
// get light from bmodels too
if( CVAR_TO_BOOL( r_lighting_extended ))
if( r_lighting_extended.value )
maxEnts = MAX_PHYSENTS;
// 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 );
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)
if(( light.r + light.g + light.b ) == 0 )

View File

@ -345,7 +345,7 @@ void R_SetupFrustum( void )
// build the transformation matrix for the given view angles
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
if( !r_lockfrustum->value )
if( !r_lockfrustum.value )
{
VectorCopy( RI.vieworg, RI.cullorigin );
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
glState.isFogEnabled = pglIsEnabled( GL_FOG );
if( !gl_nosort->value )
if( !gl_nosort.value )
{
// 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 );
@ -1030,7 +1030,7 @@ void R_BeginFrame( qboolean clearScene )
pglDrawBuffer( GL_BACK );
// 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();
gEngfuncs.CL_ExtraUpdate ();
@ -1082,15 +1082,15 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
// setup the initial render params
R_SetupRefParams( rvp );
if( gl_finish->value && RI.drawWorld )
if( gl_finish.value && RI.drawWorld )
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 );
else pglDisable( GL_MULTISAMPLE_ARB );
ClearBits( gl_msaa->flags, FCVAR_CHANGED );
ClearBits( gl_msaa.flags, FCVAR_CHANGED );
}
// completely override rendering

View File

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

View File

@ -214,8 +214,8 @@ void GL_SetupFogColorForSurfaces( void )
return;
}
div = (r_detailtextures->value) ? 2.0f : 1.0f;
factor = (r_detailtextures->value) ? 3.0f : 2.0f;
div = (r_detailtextures.value) ? 2.0f : 1.0f;
factor = (r_detailtextures.value) ? 3.0f : 2.0f;
fogColor[0] = pow( RI.fogColor[0] / div, ( 1.0f / factor ));
fogColor[1] = pow( RI.fogColor[1] / 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
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++ )
{
@ -879,7 +879,7 @@ void DrawGLPolyChain( glpoly_t *p, float soffset, float toffset )
_inline qboolean R_HasLightmap( void )
{
if( CVAR_TO_BOOL( r_fullbright ) || !WORLDMODEL->lightdata )
if( r_fullbright->value || !WORLDMODEL->lightdata )
return false;
if( RI.currententity )
@ -916,7 +916,7 @@ void R_BlendLightmaps( void )
GL_SetupFogColorForSurfaces ();
if( !CVAR_TO_BOOL( r_lightmap ))
if( !r_lightmap->value )
pglEnable( GL_BLEND );
else pglDisable( GL_BLEND );
@ -943,7 +943,7 @@ void R_BlendLightmaps( void )
}
// render dynamic lightmaps
if( CVAR_TO_BOOL( r_dynamic ))
if( r_dynamic->value )
{
LM_InitBlock();
@ -1153,7 +1153,7 @@ void R_RenderBrushPoly( msurface_t *fa, int cull_type )
draw_fullbrights = true;
}
if( CVAR_TO_BOOL( r_detailtextures ))
if( r_detailtextures.value )
{
if( glState.isFogEnabled )
{
@ -1522,7 +1522,7 @@ void R_DrawBrushModel( cl_entity_t *e )
model_t *clmodel;
qboolean rotated;
dlight_t *l;
qboolean allow_vbo = CVAR_TO_BOOL( r_vbo );
qboolean allow_vbo = r_vbo.value;
if( !RI.drawWorld ) return;
@ -1627,7 +1627,7 @@ void R_DrawBrushModel( cl_entity_t *e )
}
// 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 );
// draw sorted translucent surfaces
@ -1803,8 +1803,8 @@ void R_GenerateVBO( void )
}
// save in config if enabled manually
if( CVAR_TO_BOOL( r_vbo ) )
r_vbo->flags |= FCVAR_ARCHIVE;
if( r_vbo.value )
r_vbo.flags |= FCVAR_ARCHIVE;
vbos.mempool = Mem_AllocPool("Render VBO Zone");
@ -1979,7 +1979,7 @@ void R_GenerateVBO( void )
// 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) );
if( CVAR_TO_BOOL(r_vbo_dlightmode) )
if( r_vbo_dlightmode.value )
{
pglGenBuffersARB( 1, &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 )
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;
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();
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;
}
@ -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 )
{
// 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 );
@ -2266,7 +2266,7 @@ static void R_DrawLightmappedVBO( vboarray_t *vbo, vbotexture_t *vbotex, texture
R_AdditionalPasses( vbo, vbotex->curindex, vbotex->indexarray, texture, false );
// draw debug lines
if( CVAR_TO_BOOL(gl_wireframe) && !skiplighting )
if( gl_wireframe.value && !skiplighting )
{
R_SetDecalMode( true );
pglDisable( GL_TEXTURE_2D );
@ -2640,7 +2640,7 @@ void R_DrawVBO( qboolean drawlightmap, qboolean drawtextures )
int k;
vboarray_t *vbo = vbos.arraylist;
if( !CVAR_TO_BOOL( r_vbo ) )
if( !r_vbo.value )
return;
// bind array
@ -2969,7 +2969,7 @@ static qboolean R_CheckLightMap( msurface_t *fa )
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
int idx = surf - WORLDMODEL->surfaces;
@ -2988,7 +2988,7 @@ qboolean R_AddSurfToVBO( msurface_t *surf, qboolean buildlightmap )
if( 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 ) )
{
@ -3047,7 +3047,7 @@ loc0:
if( node->visframe != tr.visframecount )
return;
if( clipflags && !CVAR_TO_BOOL( r_nocull ))
if( clipflags && !r_nocull.value )
{
for( i = 0; i < 6; i++ )
{
@ -3198,7 +3198,7 @@ void R_DrawWorldTopView( mnode_t *node, uint clipflags )
if( node->visframe != tr.visframecount )
return;
if( clipflags && !r_nocull->value )
if( clipflags && !r_nocull.value )
{
for( i = 0; i < 6; i++ )
{
@ -3262,7 +3262,7 @@ void R_DrawTriangleOutlines( void )
glpoly_t *p;
float *v;
if( !gl_wireframe->value )
if( !gl_wireframe.value )
return;
pglDisable( GL_TEXTURE_2D );
@ -3347,7 +3347,7 @@ void R_DrawWorld( void )
r_stats.t_world_node = end - start;
start = gEngfuncs.pfnTime();
R_DrawVBO( !CVAR_TO_BOOL(r_fullbright) && !!WORLDMODEL->lightdata, true );
R_DrawVBO( !r_fullbright->value && !!WORLDMODEL->lightdata, true );
R_DrawTextureChains();
@ -3392,10 +3392,10 @@ void R_MarkLeaves( void )
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
ClearBits( r_novis->flags, FCVAR_CHANGED );
ClearBits( r_novis.flags, FCVAR_CHANGED );
tr.fResetVis = false;
RI.viewleaf = NULL;
}
@ -3425,12 +3425,12 @@ void R_MarkLeaves( void )
// development aid to let you run around
// and see exactly where the pvs ends
if( r_lockpvs->value ) return;
if( r_lockpvs.value ) return;
RI.oldviewleaf = RI.viewleaf;
tr.visframecount++;
if( r_novis->value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
if( r_novis.value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );

View File

@ -666,7 +666,7 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
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 )
return 0.0f;

View File

@ -121,9 +121,9 @@ typedef struct
} studio_draw_state_t;
// 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 *r_studio_drawelements;
static CVAR_DEFINE_AUTO( r_studio_drawelements, "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
static r_studio_interface_t *pStudioDraw;
static studio_draw_state_t g_studio; // global studio state
@ -146,8 +146,8 @@ R_StudioInit
*/
void R_StudioInit( void )
{
r_studio_sort_textures = gEngfuncs.Cvar_Get( "r_studio_sort_textures", "0", FCVAR_GLCONFIG, "change draw order for additive meshes" );
r_studio_drawelements = gEngfuncs.Cvar_Get( "r_studio_drawelements", "1", FCVAR_GLCONFIG, "use glDrawElements for studiomodels" );
gEngfuncs.Cvar_RegisterVariable( &r_studio_sort_textures );
gEngfuncs.Cvar_RegisterVariable( &r_studio_drawelements );
#if XASH_PSVITA
// 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
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] );
if( CVAR_TO_BOOL(r_studio_drawelements) )
if( r_studio_drawelements.value )
{
if( FBitSet( g_nFaceFlags, STUDIO_NF_CHROME ))
R_StudioBuildArrayChromeMesh( ptricmds, pstudionorms, s, t, shellscale );