Browse Source

engine, ref: RefAPI 5. Remove unused calls

pull/2/head
Alibek Omarov 1 year ago
parent
commit
9c66e86be1
  1. 12
      engine/client/ref_common.c
  2. 9
      engine/ref_api.h
  3. 4
      ref/gl/gl_alias.c
  4. 2
      ref/gl/gl_cull.c
  5. 4
      ref/gl/gl_image.c
  6. 2
      ref/gl/gl_local.h
  7. 2
      ref/gl/gl_opengl.c
  8. 16
      ref/gl/gl_rpart.c
  9. 12
      ref/gl/gl_studio.c
  10. 2
      ref/soft/r_local.h
  11. 2
      ref/soft/r_main.c
  12. 20
      ref/soft/r_part.c
  13. 12
      ref/soft/r_studio.c

12
engine/client/ref_common.c

@ -104,9 +104,9 @@ static void pfnGetPredictedOrigin( vec3_t v ) @@ -104,9 +104,9 @@ static void pfnGetPredictedOrigin( vec3_t v )
VectorCopy( cl.simorg, v );
}
static color24 *pfnCL_GetPaletteColor( int color ) // clgame.palette[color]
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
{
return &clgame.palette[color];
return clgame.palette;
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
@ -158,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s @@ -158,11 +158,6 @@ static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s
0;
}
static poolhandle_t pfnImage_GetPool( void )
{
return host.imagepool;
}
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
{
return &PFDesc[idx];
@ -251,7 +246,6 @@ static ref_api_t gEngfuncs = @@ -251,7 +246,6 @@ static ref_api_t gEngfuncs =
Con_DrawString,
CL_DrawCenterPrint,
CL_GetLocalPlayer,
CL_GetViewModel,
R_BeamGetEntity,
CL_GetWaterEntity,
@ -289,7 +283,6 @@ static ref_api_t gEngfuncs = @@ -289,7 +283,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat,
COM_RandomLong,
pfnRefGetScreenFade,
CL_TextMessageGet,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo,
@ -353,7 +346,6 @@ static ref_api_t gEngfuncs = @@ -353,7 +346,6 @@ static ref_api_t gEngfuncs =
FS_CopyImage,
FS_FreeImage,
Image_SetMDLPointer,
pfnImage_GetPool,
pfnImage_GetPFDesc,
pfnDrawNormalTriangles,

9
engine/ref_api.h

@ -34,7 +34,9 @@ GNU General Public License for more details. @@ -34,7 +34,9 @@ GNU General Public License for more details.
// 2. FS functions are removed, instead we have full fs_api_t
// 3. SlerpBones, CalcBonePosition/Quaternion calls were moved to libpublic/mathlib
// 4. R_StudioEstimateFrame now has time argument
#define REF_API_VERSION 4
// 5. Removed GetSomethingByIndex calls, renderers are supposed to cache pointer values.
// Removed previously unused calls
#define REF_API_VERSION 5
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
@ -299,7 +301,6 @@ typedef struct ref_api_s @@ -299,7 +301,6 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void );
// entity management
struct cl_entity_s *(*GetLocalPlayer)( void );
struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
@ -343,9 +344,8 @@ typedef struct ref_api_s @@ -343,9 +344,8 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax );
struct screenfade_s *(*GetScreenFade)( void );
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
void (*GetPredictedOrigin)( vec3_t v );
color24 *(*CL_GetPaletteColor)(int color); // clgame.palette[color]
color24 *(*CL_GetPaletteColor)( void ); // clgame.palette[color]
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag );
@ -419,7 +419,6 @@ typedef struct ref_api_s @@ -419,7 +419,6 @@ typedef struct ref_api_s
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
void (*FS_FreeImage)( rgbdata_t *pack );
void (*Image_SetMDLPointer)( byte *p );
poolhandle_t (*Image_GetPool)( void );
const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
// client exports

4
ref/gl/gl_alias.c

@ -427,7 +427,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height ) @@ -427,7 +427,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
skin.encode = DXT_ENCODE_DEFAULT;
skin.numMips = 1;
skin.buffer = data;
skin.palette = (byte *)gEngfuncs.CL_GetPaletteColor( 0 );
skin.palette = (byte *)tr.palette;
skin.size = width * height;
if( !gEngfuncs.Image_CustomPalette() )
@ -1261,7 +1261,7 @@ static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_ @@ -1261,7 +1261,7 @@ static void R_AliasDrawAbsBBox( cl_entity_t *e, const vec3_t absmin, const vec3_
int i;
// looks ugly, skip
if( r_drawentities->value != 5 || e == gEngfuncs.GetViewModel() )
if( r_drawentities->value != 5 || e == tr.viewent )
return;
// compute a full bounding box

2
ref/gl/gl_cull.c

@ -42,7 +42,7 @@ R_CullModel @@ -42,7 +42,7 @@ R_CullModel
*/
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
{
if( e == gEngfuncs.GetViewModel() )
if( e == tr.viewent )
{
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
return 1;

4
ref/gl/gl_image.c

@ -1668,11 +1668,11 @@ int GL_LoadTextureArray( const char **names, int flags ) @@ -1668,11 +1668,11 @@ int GL_LoadTextureArray( const char **names, int flags )
else
{
// create new image
pic = Mem_Malloc( gEngfuncs.Image_GetPool(), sizeof( rgbdata_t ));
pic = Mem_Malloc( r_temppool, sizeof( rgbdata_t ));
memcpy( pic, src, sizeof( rgbdata_t ));
// expand pic buffer for all layers
pic->buffer = Mem_Malloc( gEngfuncs.Image_GetPool(), pic->size * numLayers );
pic->buffer = Mem_Malloc( r_temppool, pic->size * numLayers );
pic->depth = 0;
}

2
ref/gl/gl_local.h

@ -259,6 +259,8 @@ typedef struct @@ -259,6 +259,8 @@ typedef struct
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
uint max_entities;
} gl_globals_t;

2
ref/gl/gl_opengl.c

@ -1288,6 +1288,8 @@ qboolean R_Init( void ) @@ -1288,6 +1288,8 @@ qboolean R_Init( void )
tr.world = gEngfuncs.GetWorld();
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
GL_SetDefaults();
R_CheckVBO();

16
ref/gl/gl_rpart.c

@ -49,7 +49,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float @@ -49,7 +49,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
{
particle_t *p;
vec3_t right, up;
color24 *pColor;
color24 сolor;
int alpha;
float size;
@ -85,15 +85,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float @@ -85,15 +85,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
сolor = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
pglColor4ub( gEngfuncs.LightToTexGamma( сolor.r ),
gEngfuncs.LightToTexGamma( сolor.g ),
gEngfuncs.LightToTexGamma( сolor.b ), alpha );
pglTexCoord2f( 0.0f, 1.0f );
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
@ -205,7 +205,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers ) @@ -205,7 +205,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
{
vec3_t verts[4], tmp2;
vec3_t tmp, normal;
color24 *pColor;
color24 color;
// Transform point into screen space
TriWorldToScreen( start, screen );
@ -235,8 +235,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers ) @@ -235,8 +235,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
p->color = 0;
}
pColor = &gTracerColors[p->color];
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
color = gTracerColors[p->color];
pglColor4ub( color.r, color.g, color.b, p->packedColor );
pglBegin( GL_QUADS );
pglTexCoord2f( 0.0f, 0.8f );

12
ref/gl/gl_studio.c

@ -196,7 +196,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e ) @@ -196,7 +196,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
{
if( cl_righthand && cl_righthand->value > 0 )
{
if( e == gEngfuncs.GetViewModel() )
if( e == tr.viewent )
return true;
}
@ -412,7 +412,7 @@ pfnGetViewEntity @@ -412,7 +412,7 @@ pfnGetViewEntity
*/
static cl_entity_t *pfnGetViewEntity( void )
{
return gEngfuncs.GetViewModel();
return tr.viewent;
}
/*
@ -2488,7 +2488,7 @@ static void R_StudioDrawAbsBBox( void ) @@ -2488,7 +2488,7 @@ static void R_StudioDrawAbsBBox( void )
int i;
// looks ugly, skip
if( RI.currententity == gEngfuncs.GetViewModel() )
if( RI.currententity == tr.viewent )
return;
if( !R_StudioComputeBBox( p ))
@ -3605,7 +3605,7 @@ void R_RunViewmodelEvents( void ) @@ -3605,7 +3605,7 @@ void R_RunViewmodelEvents( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
RI.currententity = gEngfuncs.GetViewModel();
RI.currententity = tr.viewent;
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
return;
@ -3627,7 +3627,7 @@ R_GatherPlayerLight @@ -3627,7 +3627,7 @@ R_GatherPlayerLight
*/
void R_GatherPlayerLight( void )
{
cl_entity_t *view = gEngfuncs.GetViewModel();
cl_entity_t *view = tr.viewent;
colorVec c;
tr.ignore_lightgamma = true;
@ -3643,7 +3643,7 @@ R_DrawViewModel @@ -3643,7 +3643,7 @@ R_DrawViewModel
*/
void R_DrawViewModel( void )
{
cl_entity_t *view = gEngfuncs.GetViewModel();
cl_entity_t *view = tr.viewent;
R_GatherPlayerLight();

2
ref/soft/r_local.h

@ -298,6 +298,8 @@ typedef struct @@ -298,6 +298,8 @@ typedef struct
cl_entity_t *entities;
movevars_t *movevars;
model_t **models;
color24 *palette;
cl_entity_t *viewent;
uint max_entities;
} gl_globals_t;

2
ref/soft/r_main.c

@ -1941,6 +1941,8 @@ qboolean GAME_EXPORT R_Init( void ) @@ -1941,6 +1941,8 @@ qboolean GAME_EXPORT R_Init( void )
// see R_ProcessEntData for tr.entities initialization
tr.models = gEngfuncs.pfnGetModels();
tr.movevars = gEngfuncs.pfnGetMoveVars();
tr.palette = gEngfuncs.CL_GetPaletteColor();
tr.viewent = gEngfuncs.GetViewModel();
R_InitBlit( glblit );

20
ref/soft/r_part.c

@ -49,7 +49,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti @@ -49,7 +49,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
{
particle_t *p;
vec3_t right, up;
color24 *pColor;
color24 color;
int alpha;
float size;
@ -84,17 +84,17 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti @@ -84,17 +84,17 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 );
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
color = tr.palette[p->color];
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
//TriColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
// gEngfuncs.LightToTexGamma( pColor->g ),
// gEngfuncs.LightToTexGamma( pColor->b ), alpha );
//TriColor4ub( gEngfuncs.LightToTexGamma( color.r ),
// gEngfuncs.LightToTexGamma( color.g ),
// gEngfuncs.LightToTexGamma( color.b ), alpha );
//TriBrightness( alpha / 255.0f );
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
TriBegin( TRI_QUADS );
TriTexCoord2f( 0.0f, 1.0f );
@ -211,7 +211,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers @@ -211,7 +211,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
{
vec3_t verts[4], tmp2;
vec3_t tmp, normal;
color24 *pColor;
color24 color;
short alpha = p->packedColor;
// Transform point into screen space
@ -242,9 +242,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers @@ -242,9 +242,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
p->color = 0;
}
pColor = &gTracerColors[p->color];
//TriColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
_TriColor4f(1.0f*alpha/255/255*pColor->r,1.0f*alpha/255/255*pColor->g,1.0f*alpha/255/255* pColor->b,1.0f );
color = gTracerColors[p->color];
//TriColor4ub( color.r, color.g, color.b, p->packedColor );
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
TriBegin( TRI_QUADS );

12
ref/soft/r_studio.c

@ -185,7 +185,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e ) @@ -185,7 +185,7 @@ static qboolean R_AllowFlipViewModel( cl_entity_t *e )
{
if( cl_righthand && cl_righthand->value > 0 )
{
if( e == gEngfuncs.GetViewModel() )
if( e == tr.viewent )
return true;
}
@ -401,7 +401,7 @@ pfnGetViewEntity @@ -401,7 +401,7 @@ pfnGetViewEntity
*/
static cl_entity_t *pfnGetViewEntity( void )
{
return gEngfuncs.GetViewModel();
return tr.viewent;
}
/*
@ -2246,7 +2246,7 @@ static void R_StudioDrawAbsBBox( void ) @@ -2246,7 +2246,7 @@ static void R_StudioDrawAbsBBox( void )
int i;
// looks ugly, skip
if( RI.currententity == gEngfuncs.GetViewModel() )
if( RI.currententity == tr.viewent )
return;
if( !R_StudioComputeBBox( p ))
@ -3371,7 +3371,7 @@ void R_RunViewmodelEvents( void ) @@ -3371,7 +3371,7 @@ void R_RunViewmodelEvents( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return;
RI.currententity = gEngfuncs.GetViewModel();
RI.currententity = tr.viewent;
if( !RI.currententity->model || RI.currententity->model->type != mod_studio )
return;
@ -3393,7 +3393,7 @@ R_GatherPlayerLight @@ -3393,7 +3393,7 @@ R_GatherPlayerLight
*/
void R_GatherPlayerLight( void )
{
cl_entity_t *view = gEngfuncs.GetViewModel();
cl_entity_t *view = tr.viewent;
colorVec c;
tr.ignore_lightgamma = true;
@ -3409,7 +3409,7 @@ R_DrawViewModel @@ -3409,7 +3409,7 @@ R_DrawViewModel
*/
void R_DrawViewModel( void )
{
cl_entity_t *view = gEngfuncs.GetViewModel();
cl_entity_t *view = tr.viewent;
R_GatherPlayerLight();

Loading…
Cancel
Save