Browse Source

engine: ref_api: draft RefAPI 6.

Remove timings from ref_globals_t struct

Remove R_UpdateRefState accordingly.

Remove unused PARMs

Remove reduntant functions
pull/2/head
Alibek Omarov 11 months ago
parent
commit
707a9228e1
  1. 3
      engine/client/cl_parse.c
  2. 3
      engine/client/cl_parse_48.c
  3. 10
      engine/client/cl_render.c
  4. 36
      engine/client/ref_common.c
  5. 1
      engine/client/ref_common.h
  6. 33
      engine/ref_api.h

3
engine/client/cl_parse.c

@ -1642,9 +1642,6 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld (); CL_ClearWorld ();
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();

3
engine/client/cl_parse_48.c

@ -660,9 +660,6 @@ void CL_LegacyPrecache_f( void )
if( clgame.entities ) if( clgame.entities )
clgame.entities->model = cl.worldmodel; clgame.entities->model = cl.worldmodel;
// update the ref state.
R_UpdateRefState ();
// tell rendering system we have a new set of models. // tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap (); ref.dllFuncs.R_NewMap ();

10
engine/client/cl_render.c

@ -187,28 +187,18 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return CL_IsThirdPerson(); return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE: case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible(); return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE: case PARM_CONNSTATE:
return (int)cls.state; return (int)cls.state;
case PARM_PLAYING_DEMO: case PARM_PLAYING_DEMO:
return cls.demoplayback; return cls.demoplayback;
case PARM_WATER_LEVEL: case PARM_WATER_LEVEL:
return cl.local.waterlevel; return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH: case PARM_LOCAL_HEALTH:
return cl.local.health; return cl.local.health;
case PARM_LOCAL_GAME: case PARM_LOCAL_GAME:
return Host_IsLocalGame(); return Host_IsLocalGame();
case PARM_NUMENTITIES: case PARM_NUMENTITIES:
return pfnNumberOfEntities(); return pfnNumberOfEntities();
case PARM_NUMMODELS:
return cl.nummodels;
case PARM_WORLD_VERSION:
return world.version;
case PARM_GET_CLIENT_PTR: case PARM_GET_CLIENT_PTR:
return (intptr_t)&cl.time; // with the offset return (intptr_t)&cl.time; // with the offset
case PARM_GET_HOST_PTR: case PARM_GET_HOST_PTR:

36
engine/client/ref_common.c

@ -67,18 +67,8 @@ void GAME_EXPORT GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum ); ref.dllFuncs.GL_FreeTexture( texnum );
} }
void R_UpdateRefState( void )
{
refState.time = cl.time;
refState.oldtime = cl.oldtime;
refState.realtime = host.realtime;
refState.frametime = host.frametime;
}
void GL_RenderFrame( const ref_viewpass_t *rvp ) void GL_RenderFrame( const ref_viewpass_t *rvp )
{ {
R_UpdateRefState();
VectorCopy( rvp->vieworigin, refState.vieworg ); VectorCopy( rvp->vieworigin, refState.vieworg );
VectorCopy( rvp->viewangles, refState.viewangles ); VectorCopy( rvp->viewangles, refState.viewangles );
@ -90,11 +80,6 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
return CL_RenderGetParm( parm, arg, false ); // prevent recursion return CL_RenderGetParm( parm, arg, false ); // prevent recursion
} }
static world_static_t *pfnGetWorld( void )
{
return &world;
}
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e ) static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
{ {
clgame.dllFuncs.pfnStudioEvent( event, e ); clgame.dllFuncs.pfnStudioEvent( event, e );
@ -124,16 +109,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
return NULL; return NULL;
} }
static void pfnGetPredictedOrigin( vec3_t v )
{
VectorCopy( cl.simorg, v );
}
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
{
return clgame.palette;
}
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
{ {
if( width ) *width = clgame.scrInfo.iWidth; if( width ) *width = clgame.scrInfo.iWidth;
@ -232,11 +207,6 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type ); return R_Init_Video( type );
} }
static model_t **pfnGetModels( void )
{
return cl.models;
}
static ref_api_t gEngfuncs = static ref_api_t gEngfuncs =
{ {
pfnEngineGetParm, pfnEngineGetParm,
@ -271,14 +241,12 @@ static ref_api_t gEngfuncs =
Con_DrawString, Con_DrawString,
CL_DrawCenterPrint, CL_DrawCenterPrint,
CL_GetViewModel,
R_BeamGetEntity, R_BeamGetEntity,
CL_GetWaterEntity, CL_GetWaterEntity,
CL_AddVisibleEntity, CL_AddVisibleEntity,
Mod_SampleSizeForFace, Mod_SampleSizeForFace,
Mod_BoxVisible, Mod_BoxVisible,
pfnGetWorld,
Mod_PointInLeaf, Mod_PointInLeaf,
Mod_CreatePolygonsForHull, Mod_CreatePolygonsForHull,
@ -295,7 +263,6 @@ static ref_api_t gEngfuncs =
Mod_ForName, Mod_ForName,
pfnMod_Extradata, pfnMod_Extradata,
pfnGetModels,
CL_EntitySetRemapColors, CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
@ -306,8 +273,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
pfnRefGetScreenFade, pfnRefGetScreenFade,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo, pfnCL_GetScreenInfo,
pfnSetLocalLightLevel, pfnSetLocalLightLevel,
Sys_CheckParm, Sys_CheckParm,
@ -357,7 +322,6 @@ static ref_api_t gEngfuncs =
PM_CL_TraceLine, PM_CL_TraceLine,
CL_VisTraceLine, CL_VisTraceLine,
CL_TraceLine, CL_TraceLine,
pfnGetMoveVars,
Image_AddCmdFlags, Image_AddCmdFlags,
Image_SetForceFlags, Image_SetForceFlags,

1
engine/client/ref_common.h

@ -52,7 +52,6 @@ extern convar_t gl_clear;
qboolean R_Init( void ); qboolean R_Init( void );
void R_Shutdown( void ); void R_Shutdown( void );
void R_UpdateRefState( void );
extern triangleapi_t gTriApi; extern triangleapi_t gTriApi;

33
engine/ref_api.h

@ -39,7 +39,10 @@ GNU General Public License for more details.
// Removed previously unused calls // Removed previously unused calls
// Simplified remapping calls // Simplified remapping calls
// GetRefAPI is now expected to return REF_API_VERSION // GetRefAPI is now expected to return REF_API_VERSION
#define REF_API_VERSION 5 // 6. Removed timing from ref_globals_t.
// Renderers are supposed to migrate to ref_client_t/ref_host_t using PARM_GET_CLIENT_PTR and PARM_GET_HOST_PTR
// Removed functions to get internal engine structions. Use PARM_GET_*_PTR instead.
#define REF_API_VERSION 6
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP) #define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
@ -95,11 +98,6 @@ typedef struct ref_globals_s
{ {
qboolean developer; qboolean developer;
float time; // cl.time
float oldtime; // cl.oldtime
double realtime; // host.realtime
double frametime; // host.frametime
// viewport width and height // viewport width and height
int width; int width;
int height; int height;
@ -272,23 +270,18 @@ typedef enum
PARM_DEV_OVERVIEW = -1, PARM_DEV_OVERVIEW = -1,
PARM_THIRDPERSON = -2, PARM_THIRDPERSON = -2,
PARM_QUAKE_COMPATIBLE = -3, PARM_QUAKE_COMPATIBLE = -3,
PARM_PLAYER_INDEX = -4, // cl.playernum + 1 PARM_GET_CLIENT_PTR = -4, // ref_client_t
PARM_VIEWENT_INDEX = -5, // cl.viewentity PARM_GET_HOST_PTR = -5, // ref_host_t
PARM_CONNSTATE = -6, // cls.state PARM_CONNSTATE = -6, // cls.state
PARM_PLAYING_DEMO = -7, // cls.demoplayback PARM_PLAYING_DEMO = -7, // cls.demoplayback
PARM_WATER_LEVEL = -8, // cl.local.water_level PARM_WATER_LEVEL = -8, // cl.local.water_level
PARM_MAX_CLIENTS = -9, // cl.maxclients PARM_GET_WORLD_PTR = -9, // world
PARM_LOCAL_HEALTH = -10, // cl.local.health PARM_LOCAL_HEALTH = -10, // cl.local.health
PARM_LOCAL_GAME = -11, PARM_LOCAL_GAME = -11,
PARM_NUMENTITIES = -12, // local game only PARM_NUMENTITIES = -12, // local game only
PARM_NUMMODELS = -13, // cl.nummodels PARM_GET_MOVEVARS_PTR = -13, // clgame.movevars
PARM_WORLD_VERSION = -14, PARM_GET_PALETTE_PTR = -14, // clgame.palette
PARM_GET_CLIENT_PTR = -15, // ref_client_t PARM_GET_VIEWENT_PTR = -15, // clgame.viewent
PARM_GET_HOST_PTR = -16, // ref_host_t
PARM_GET_WORLD_PTR = -17, // world
PARM_GET_MOVEVARS_PTR = -18, // clgame.movevars
PARM_GET_PALETTE_PTR = -19, // clgame.palette
PARM_GET_VIEWENT_PTR = -20, // clgame.viewent
} ref_parm_e; } ref_parm_e;
typedef struct ref_api_s typedef struct ref_api_s
@ -331,7 +324,6 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void ); void (*CL_DrawCenterPrint)( void );
// entity management // entity management
struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index ); struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p ); struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType ); qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
@ -339,7 +331,6 @@ typedef struct ref_api_s
// brushes // brushes
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf ); int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits ); qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
struct world_static_s *(*GetWorld)( void ); // returns &world
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node ); mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
void (*Mod_CreatePolygonsForHull)( int hullnum ); void (*Mod_CreatePolygonsForHull)( int hullnum );
@ -359,7 +350,6 @@ typedef struct ref_api_s
// model management // model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC ); model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model ); void *(*Mod_Extradata)( int type, model_t *model );
struct model_s **(*pfnGetModels)( void );
// remap // remap
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom ); qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
@ -372,8 +362,6 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax ); float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax ); int (*COM_RandomLong)( int rmin, int rmax );
struct screenfade_s *(*GetScreenFade)( void ); struct screenfade_s *(*GetScreenFade)( void );
void (*GetPredictedOrigin)( vec3_t v );
color24 *(*CL_GetPaletteColor)( void ); // clgame.palette[color]
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
void (*SetLocalLightLevel)( int level ); // cl.local.light_level void (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag ); int (*Sys_CheckParm)( const char *flag );
@ -434,7 +422,6 @@ typedef struct ref_api_s
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe ); struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags ); struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags ); struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );
// imagelib // imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported

Loading…
Cancel
Save