diff --git a/ref/common/ref_common.h b/ref/common/ref_common.h index 639d5057..f6b93f5c 100644 --- a/ref/common/ref_common.h +++ b/ref/common/ref_common.h @@ -28,6 +28,8 @@ extern ref_client_t *gp_cl; extern ref_host_t *gp_host; extern const ref_interface_t gReffuncs; +DECLARE_ENGINE_SHARED_CVAR_LIST() + #define Assert( x ) if( !( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ ) #define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm) @@ -61,4 +63,9 @@ void Matrix4x4_CreateOrtho( matrix4x4 m, float xLeft, float xRight, float yBotto void Matrix4x4_CreateModelview( matrix4x4 out ); void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] ); +// +// ref_light.c +// +void CL_RunLightStyles_( lightstyle_t *ls, int *lightstylevalue ); + #endif // REF_COMMON_H diff --git a/ref/common/ref_context.c b/ref/common/ref_context.c index 2ee72052..ed767665 100644 --- a/ref/common/ref_context.c +++ b/ref/common/ref_context.c @@ -14,6 +14,9 @@ GNU General Public License for more details. */ #include "ref_common.h" +#include "com_strings.h" + +DEFINE_ENGINE_SHARED_CVAR_LIST() ref_api_t gEngfuncs; ref_globals_t *gpGlobals; @@ -65,5 +68,7 @@ int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, gp_cl = (ref_client_t *)ENGINE_GET_PARM( PARM_GET_CLIENT_PTR ); gp_host = (ref_host_t *)ENGINE_GET_PARM( PARM_GET_HOST_PTR ); + RETRIEVE_ENGINE_SHARED_CVAR_LIST(); + return REF_API_VERSION; } diff --git a/ref/common/wscript b/ref/common/wscript index fec2b45b..49930baf 100644 --- a/ref/common/wscript +++ b/ref/common/wscript @@ -14,6 +14,7 @@ def build(bld): target = 'ref_common', includes = '.', export_includes = '.', + defines = 'REF_DLL=1', use = 'engine_includes public werror', subsystem = bld.env.MSVC_SUBSYSTEM ) diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index d9df6c7b..a8c06dc1 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -787,7 +787,6 @@ extern convar_t r_dlight_virtual_radius; // // engine shared convars // -DECLARE_ENGINE_SHARED_CVAR_LIST() // // engine callbacks diff --git a/ref/gl/gl_opengl.c b/ref/gl/gl_opengl.c index 99d1a5c0..d067955e 100644 --- a/ref/gl/gl_opengl.c +++ b/ref/gl/gl_opengl.c @@ -41,7 +41,6 @@ CVAR_DEFINE_AUTO( r_ripple_spawntime, "0.1", FCVAR_GLCONFIG, "how fast new rippl CVAR_DEFINE_AUTO( r_large_lightmaps, "0", FCVAR_GLCONFIG|FCVAR_LATCH, "enable larger lightmap atlas textures (might break custom renderer mods)" ); CVAR_DEFINE_AUTO( r_dlight_virtual_radius, "3", FCVAR_GLCONFIG, "increase dlight radius virtually by this amount, should help against ugly cut off dlights on highly scaled textures" ); -DEFINE_ENGINE_SHARED_CVAR_LIST() poolhandle_t r_temppool; @@ -1141,8 +1140,6 @@ GL_InitCommands */ static void GL_InitCommands( void ) { - RETRIEVE_ENGINE_SHARED_CVAR_LIST(); - gEngfuncs.Cvar_RegisterVariable( &r_lighting_extended ); gEngfuncs.Cvar_RegisterVariable( &r_lighting_ambient ); gEngfuncs.Cvar_RegisterVariable( &r_novis ); diff --git a/ref/gl/gl_rlight.c b/ref/gl/gl_rlight.c index e63adaac..ff275578 100644 --- a/ref/gl/gl_rlight.c +++ b/ref/gl/gl_rlight.c @@ -34,64 +34,7 @@ CL_RunLightStyles */ void CL_RunLightStyles( lightstyle_t *ls ) { - int i; - float frametime = (gp_cl->time - gp_cl->oldtime); - - if( !WORLDMODEL ) - return; - - if( !WORLDMODEL->lightdata ) - { - for( i = 0; i < MAX_LIGHTSTYLES; i++ ) - tr.lightstylevalue[i] = 256 * 256; - return; - } - - // light animations - // 'm' is normal light, 'a' is no light, 'z' is double bright - for( i = 0; i < MAX_LIGHTSTYLES; i++ ) - { - int k, flight, clight; - float l, lerpfrac, backlerp; - - if( !gp_cl->paused && frametime <= 0.1f ) - ls[i].time += frametime; // evaluate local time - - if( !ls[i].length ) - { - tr.lightstylevalue[i] = 256; - continue; - } - else if( ls[i].length == 1 ) - { - // single length style so don't bother interpolating - tr.lightstylevalue[i] = ( ls[i].map[0] ) * 22; - continue; - } - - flight = (int)Q_floor( ls[i].time * 10 ); - - if( !ls[i].interp || !cl_lightstyle_lerping->value ) - { - tr.lightstylevalue[i] = ls[i].map[flight%ls[i].length] * 22; - continue; - } - - clight = (int)Q_ceil( ls[i].time * 10 ); - lerpfrac = ( ls[i].time * 10 ) - flight; - backlerp = 1.0f - lerpfrac; - - // interpolate animating light - // frame just gone - k = ls[i].map[flight % ls[i].length]; - l = (float)( k * 22.0f ) * backlerp; - - // upcoming frame - k = ls[i].map[clight % ls[i].length]; - l += (float)( k * 22.0f ) * lerpfrac; - - tr.lightstylevalue[i] = (int)l; - } + CL_RunLightStyles_( ls, tr.lightstylevalue ); } /* diff --git a/ref/soft/r_light.c b/ref/soft/r_light.c index 81acf1bc..be8b13a8 100644 --- a/ref/soft/r_light.c +++ b/ref/soft/r_light.c @@ -37,64 +37,7 @@ CL_RunLightStyles */ void CL_RunLightStyles( lightstyle_t *ls ) { - int i; - float frametime = ( gp_cl->time - gp_cl->oldtime ); - - if( !WORLDMODEL ) - return; - - if( r_fullbright->value || !WORLDMODEL->lightdata ) - { - for( i = 0; i < MAX_LIGHTSTYLES; i++ ) - tr.lightstylevalue[i] = 256 * 256; - return; - } - - // light animations - // 'm' is normal light, 'a' is no light, 'z' is double bright - for( i = 0; i < MAX_LIGHTSTYLES; i++ ) - { - int k, flight, clight; - float l, lerpfrac, backlerp; - - if( !gp_cl->paused && frametime <= 0.1f ) - ls[i].time += frametime; // evaluate local time - - if( !ls[i].length ) - { - tr.lightstylevalue[i] = 256; - continue; - } - else if( ls[i].length == 1 ) - { - // single length style so don't bother interpolating - tr.lightstylevalue[i] = ( ls[i].map[0] ) * 22; - continue; - } - - flight = (int)Q_floor( ls[i].time * 10 ); - - if( !ls[i].interp || !cl_lightstyle_lerping->value ) - { - tr.lightstylevalue[i] = ls[i].map[flight % ls[i].length] * 22; - continue; - } - - clight = (int)Q_ceil( ls[i].time * 10 ); - lerpfrac = ( ls[i].time * 10 ) - flight; - backlerp = 1.0f - lerpfrac; - - // interpolate animating light - // frame just gone - k = ls[i].map[flight % ls[i].length]; - l = (float)( k * 22.0f ) * backlerp; - - // upcoming frame - k = ls[i].map[clight % ls[i].length]; - l += (float)( k * 22.0f ) * lerpfrac; - - tr.lightstylevalue[i] = (int)l; - } + CL_RunLightStyles_( ls, tr.lightstylevalue ); } /* diff --git a/ref/soft/r_local.h b/ref/soft/r_local.h index 77269448..6317becf 100644 --- a/ref/soft/r_local.h +++ b/ref/soft/r_local.h @@ -528,7 +528,6 @@ void TriCullFace( TRICULLSTYLE mode ); void TriBrightness( float brightness ); -DECLARE_ENGINE_SHARED_CVAR_LIST() // // helper funcs diff --git a/ref/soft/r_main.c b/ref/soft/r_main.c index 3e698f1e..7688acd4 100644 --- a/ref/soft/r_main.c +++ b/ref/soft/r_main.c @@ -71,7 +71,6 @@ CVAR_DEFINE_AUTO( sw_texfilt, "0", FCVAR_GLCONFIG, "texture dither" ); static CVAR_DEFINE_AUTO( r_novis, "0", 0, "" ); -DEFINE_ENGINE_SHARED_CVAR_LIST() int r_viewcluster, r_oldviewcluster; @@ -1407,9 +1406,6 @@ qboolean GAME_EXPORT R_Init( void ) { qboolean glblit = false; - RETRIEVE_ENGINE_SHARED_CVAR_LIST(); - - gEngfuncs.Cvar_RegisterVariable( &sw_clearcolor ); gEngfuncs.Cvar_RegisterVariable( &sw_drawflat ); gEngfuncs.Cvar_RegisterVariable( &sw_draworder );