Skip to content

Commit

Permalink
engine: ref_api: draft RefAPI 6.
Browse files Browse the repository at this point in the history
Remove timings from ref_globals_t struct

Remove R_UpdateRefState accordingly.

Remove unused PARMs

Remove reduntant functions
  • Loading branch information
a1batross committed Dec 30, 2023
1 parent 59ddfb7 commit 707a922
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 76 deletions.
3 changes: 0 additions & 3 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1642,9 +1642,6 @@ void CL_RegisterResources( sizebuf_t *msg )

CL_ClearWorld ();

// update the ref state.
R_UpdateRefState ();

// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();

Expand Down
3 changes: 0 additions & 3 deletions engine/client/cl_parse_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,6 @@ void CL_LegacyPrecache_f( void )
if( clgame.entities )
clgame.entities->model = cl.worldmodel;

// update the ref state.
R_UpdateRefState ();

// tell rendering system we have a new set of models.
ref.dllFuncs.R_NewMap ();

Expand Down
10 changes: 0 additions & 10 deletions engine/client/cl_render.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,28 +187,18 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE:
return (int)cls.state;
case PARM_PLAYING_DEMO:
return cls.demoplayback;
case PARM_WATER_LEVEL:
return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH:
return cl.local.health;
case PARM_LOCAL_GAME:
return Host_IsLocalGame();
case PARM_NUMENTITIES:
return pfnNumberOfEntities();
case PARM_NUMMODELS:
return cl.nummodels;
case PARM_WORLD_VERSION:
return world.version;
case PARM_GET_CLIENT_PTR:
return (intptr_t)&cl.time; // with the offset
case PARM_GET_HOST_PTR:
Expand Down
36 changes: 0 additions & 36 deletions engine/client/ref_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,8 @@ void GAME_EXPORT GL_FreeImage( const char *name )
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 )
{
R_UpdateRefState();

VectorCopy( rvp->vieworigin, refState.vieworg );
VectorCopy( rvp->viewangles, refState.viewangles );

Expand All @@ -90,11 +80,6 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
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 )
{
clgame.dllFuncs.pfnStudioEvent( event, e );
Expand Down Expand Up @@ -124,16 +109,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
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
{
if( width ) *width = clgame.scrInfo.iWidth;
Expand Down Expand Up @@ -232,11 +207,6 @@ static qboolean R_Init_Video_( const int type )
return R_Init_Video( type );
}

static model_t **pfnGetModels( void )
{
return cl.models;
}

static ref_api_t gEngfuncs =
{
pfnEngineGetParm,
Expand Down Expand Up @@ -271,14 +241,12 @@ static ref_api_t gEngfuncs =
Con_DrawString,
CL_DrawCenterPrint,

CL_GetViewModel,
R_BeamGetEntity,
CL_GetWaterEntity,
CL_AddVisibleEntity,

Mod_SampleSizeForFace,
Mod_BoxVisible,
pfnGetWorld,
Mod_PointInLeaf,
Mod_CreatePolygonsForHull,

Expand All @@ -295,7 +263,6 @@ static ref_api_t gEngfuncs =

Mod_ForName,
pfnMod_Extradata,
pfnGetModels,

CL_EntitySetRemapColors,
CL_GetRemapInfoForEntity,
Expand All @@ -306,8 +273,6 @@ static ref_api_t gEngfuncs =
COM_RandomFloat,
COM_RandomLong,
pfnRefGetScreenFade,
pfnGetPredictedOrigin,
pfnCL_GetPaletteColor,
pfnCL_GetScreenInfo,
pfnSetLocalLightLevel,
Sys_CheckParm,
Expand Down Expand Up @@ -357,7 +322,6 @@ static ref_api_t gEngfuncs =
PM_CL_TraceLine,
CL_VisTraceLine,
CL_TraceLine,
pfnGetMoveVars,

Image_AddCmdFlags,
Image_SetForceFlags,
Expand Down
1 change: 0 additions & 1 deletion engine/client/ref_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ extern convar_t gl_clear;

qboolean R_Init( void );
void R_Shutdown( void );
void R_UpdateRefState( void );

extern triangleapi_t gTriApi;

Expand Down
33 changes: 10 additions & 23 deletions engine/ref_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ GNU General Public License for more details.
// Removed previously unused calls
// Simplified remapping calls
// 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)
Expand Down Expand Up @@ -95,11 +98,6 @@ typedef struct ref_globals_s
{
qboolean developer;

float time; // cl.time
float oldtime; // cl.oldtime
double realtime; // host.realtime
double frametime; // host.frametime

// viewport width and height
int width;
int height;
Expand Down Expand Up @@ -272,23 +270,18 @@ typedef enum
PARM_DEV_OVERVIEW = -1,
PARM_THIRDPERSON = -2,
PARM_QUAKE_COMPATIBLE = -3,
PARM_PLAYER_INDEX = -4, // cl.playernum + 1
PARM_VIEWENT_INDEX = -5, // cl.viewentity
PARM_GET_CLIENT_PTR = -4, // ref_client_t
PARM_GET_HOST_PTR = -5, // ref_host_t
PARM_CONNSTATE = -6, // cls.state
PARM_PLAYING_DEMO = -7, // cls.demoplayback
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_GAME = -11,
PARM_NUMENTITIES = -12, // local game only
PARM_NUMMODELS = -13, // cl.nummodels
PARM_WORLD_VERSION = -14,
PARM_GET_CLIENT_PTR = -15, // ref_client_t
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
PARM_GET_MOVEVARS_PTR = -13, // clgame.movevars
PARM_GET_PALETTE_PTR = -14, // clgame.palette
PARM_GET_VIEWENT_PTR = -15, // clgame.viewent
} ref_parm_e;

typedef struct ref_api_s
Expand Down Expand Up @@ -331,15 +324,13 @@ typedef struct ref_api_s
void (*CL_DrawCenterPrint)( void );

// entity management
struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );

// brushes
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
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 );
void (*Mod_CreatePolygonsForHull)( int hullnum );

Expand All @@ -359,7 +350,6 @@ typedef struct ref_api_s
// model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model );
struct model_s **(*pfnGetModels)( void );

// remap
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
Expand All @@ -372,8 +362,6 @@ typedef struct ref_api_s
float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax );
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 (*SetLocalLightLevel)( int level ); // cl.local.light_level
int (*Sys_CheckParm)( const char *flag );
Expand Down Expand Up @@ -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 *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );

// imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
Expand Down

0 comments on commit 707a922

Please sign in to comment.