From 6a4bf4965f603c539212928e2420ff8dcc9ca064 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Dec 2023 22:19:30 +0300 Subject: [PATCH] ref: gl: acquire engine pointers --- ref/gl/gl_context.c | 5 +++++ ref/gl/gl_local.h | 7 ++++--- ref/gl/gl_opengl.c | 9 ++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ref/gl/gl_context.c b/ref/gl/gl_context.c index 5b388511..356d23c6 100644 --- a/ref/gl/gl_context.c +++ b/ref/gl/gl_context.c @@ -24,6 +24,8 @@ GNU General Public License for more details. ref_api_t gEngfuncs; ref_globals_t *gpGlobals; +ref_client_t *gp_cl; +ref_host_t *gp_host; static void R_ClearScreen( void ) { @@ -518,5 +520,8 @@ int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, memcpy( &gEngfuncs, engfuncs, sizeof( ref_api_t )); gpGlobals = globals; + gp_cl = (ref_client_t *)ENGINE_GET_PARM( PARM_GET_CLIENT_PTR ); + gp_host = (ref_host_t *)ENGINE_GET_PARM( PARM_GET_HOST_PTR ); + return REF_API_VERSION; } diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index 2eb59e6d..4bc028b8 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -258,7 +258,6 @@ typedef struct struct world_static_s *world; cl_entity_t *entities; movevars_t *movevars; - model_t **models; color24 *palette; cl_entity_t *viewent; @@ -725,6 +724,8 @@ extern glstate_t glState; extern glwstate_t glw_state; extern ref_api_t gEngfuncs; extern ref_globals_t *gpGlobals; +extern ref_client_t *gp_cl; +extern ref_host_t *gp_host; #define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm) #define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 ) @@ -739,10 +740,10 @@ static inline cl_entity_t *CL_GetEntityByIndex( int index ) static inline model_t *CL_ModelHandle( int index ) { - return tr.models[index]; + return gp_cl->models[index]; } -#define WORLDMODEL (tr.models[1]) +#define WORLDMODEL (gp_cl->models[1]) // // renderer cvars diff --git a/ref/gl/gl_opengl.c b/ref/gl/gl_opengl.c index 0ae9d767..ae3d87cf 100644 --- a/ref/gl/gl_opengl.c +++ b/ref/gl/gl_opengl.c @@ -1287,11 +1287,10 @@ qboolean R_Init( void ) } // see R_ProcessEntData for tr.entities initialization - tr.world = gEngfuncs.GetWorld(); - tr.models = gEngfuncs.pfnGetModels(); - tr.movevars = gEngfuncs.pfnGetMoveVars(); - tr.palette = gEngfuncs.CL_GetPaletteColor(); - tr.viewent = gEngfuncs.GetViewModel(); + tr.world = (struct world_static_s *)ENGINE_GET_PARM( PARM_GET_WORLD_PTR ); + tr.movevars = (movevars_t *)ENGINE_GET_PARM( PARM_GET_MOVEVARS_PTR ); + tr.palette = (color24 *)ENGINE_GET_PARM( PARM_GET_PALETTE_PTR ); + tr.viewent = (cl_entity_t *)ENGINE_GET_PARM( PARM_GET_VIEWENT_PTR ); GL_SetDefaults(); R_CheckVBO();