mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-10 22:22:10 +08:00
ref: implement API interface for ref_gl, get rid of RenderAPI, RenderInterface and vgui_support API references
This commit is contained in:
@@ -1288,7 +1288,7 @@ void CL_EmitEntities( void )
|
||||
{
|
||||
if( cl.paused ) return; // don't waste time
|
||||
|
||||
RefRenderIface->R_ClearScene ();
|
||||
ref.dllFuncs.R_ClearScene ();
|
||||
|
||||
// not in server yet, no entities to redraw
|
||||
if( cls.state != ca_active || !cl.validsequence )
|
||||
|
||||
@@ -3204,7 +3204,7 @@ check box in pvs (absmin, absmax)
|
||||
*/
|
||||
int TriBoxInPVS( float *mins, float *maxs )
|
||||
{
|
||||
return Mod_BoxVisible( mins, maxs, RefRenderIface->Mod_GetCurrentVis( ));
|
||||
return Mod_BoxVisible( mins, maxs, ref.dllFuncs.Mod_GetCurrentVis( ));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3606,7 +3606,6 @@ triangleapi_t gTriApi;
|
||||
|
||||
static efx_api_t gEfxApi =
|
||||
{
|
||||
#if 1
|
||||
R_AllocParticle,
|
||||
R_BlobExplosion,
|
||||
R_Blood,
|
||||
@@ -3681,7 +3680,6 @@ static efx_api_t gEfxApi =
|
||||
R_LookupColor,
|
||||
CL_DecalRemoveAll,
|
||||
CL_FireCustomDecal,
|
||||
#endif
|
||||
};
|
||||
|
||||
static event_api_t gEventApi =
|
||||
|
||||
@@ -390,7 +390,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, int ima
|
||||
SetBits( flags, TF_IMAGE );
|
||||
|
||||
Image_SetForceFlags( IL_LOAD_DECAL ); // allow decal images for menu
|
||||
tx = RefRenderAPI->GL_LoadTexture( szPicName, image_buf, image_size, flags );
|
||||
tx = ref.dllFuncs.GL_LoadTexture( szPicName, image_buf, image_size, flags );
|
||||
Image_ClearForceFlags();
|
||||
|
||||
return tx;
|
||||
@@ -703,7 +703,7 @@ for drawing playermodel previews
|
||||
static void pfnClearScene( void )
|
||||
{
|
||||
ref.dllFuncs.R_PushScene();
|
||||
RefRenderIface->R_ClearScene();
|
||||
ref.dllFuncs.R_ClearScene();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -727,7 +727,7 @@ static void pfnRenderScene( const ref_viewpass_t *rvp )
|
||||
copy.flags = 0;
|
||||
|
||||
ref.dllFuncs.R_Set2DMode( false );
|
||||
RefRenderIface->GL_RenderFrame( © );
|
||||
ref.dllFuncs.GL_RenderFrame( © );
|
||||
ref.dllFuncs.R_Set2DMode( true );
|
||||
ref.dllFuncs.R_PopScene();
|
||||
}
|
||||
|
||||
@@ -1547,7 +1547,7 @@ void CL_RegisterResources( sizebuf_t *msg )
|
||||
CL_ClearWorld ();
|
||||
|
||||
// tell rendering system we have a new set of models.
|
||||
RefRenderIface->R_NewMap ();
|
||||
ref.dllFuncs.R_NewMap ();
|
||||
|
||||
CL_SetupOverviewParams();
|
||||
|
||||
@@ -3131,7 +3131,7 @@ void CL_LegacyPrecache_f( void )
|
||||
clgame.entities->model = cl.worldmodel;
|
||||
|
||||
// tell rendering system we have a new set of models.
|
||||
RefRenderIface->R_NewMap ();
|
||||
ref.dllFuncs.R_NewMap ();
|
||||
|
||||
CL_SetupOverviewParams();
|
||||
|
||||
|
||||
@@ -989,7 +989,7 @@ void CL_InitClientMove( void )
|
||||
|
||||
// common utilities
|
||||
clgame.pmove->PM_Info_ValueForKey = Info_ValueForKey;
|
||||
clgame.pmove->PM_Particle = ref.dllFuncs.CL_Particle; // ref should be initialized here already
|
||||
clgame.pmove->PM_Particle = CL_Particle; // ref should be initialized here already
|
||||
clgame.pmove->PM_TestPlayerPosition = pfnTestPlayerPosition;
|
||||
clgame.pmove->Con_NPrintf = Con_NPrintf;
|
||||
clgame.pmove->Con_DPrintf = Con_DPrintf;
|
||||
|
||||
@@ -110,7 +110,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
|
||||
|
||||
// save off the real texture index
|
||||
index = ptexture->index;
|
||||
name = RefRenderAPI->GL_TextureName( index );
|
||||
name = ref.dllFuncs.GL_TextureName( index );
|
||||
Q_snprintf( texname, sizeof( texname ), "#%i_%s", refState.currententity->curstate.number, name + 1 );
|
||||
|
||||
// search for pixels
|
||||
@@ -128,7 +128,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
|
||||
memcpy( paletteBackup, pal, 768 );
|
||||
|
||||
raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
|
||||
ptexture->index = RefRenderAPI->GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
|
||||
ptexture->index = ref.dllFuncs.GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
|
||||
|
||||
// restore original palette
|
||||
memcpy( pal, paletteBackup, 768 );
|
||||
@@ -153,7 +153,7 @@ void CL_UpdateStudioTexture( mstudiotexture_t *ptexture, int topcolor, int botto
|
||||
byte *raw, *pal;
|
||||
|
||||
// save off the real texture index
|
||||
origtexname = RefRenderAPI->GL_TextureName( ptexture->index );
|
||||
origtexname = ref.dllFuncs.GL_TextureName( ptexture->index );
|
||||
|
||||
// build name of original texture
|
||||
Q_strncpy( mdlname, refState.currentmodel->name, sizeof( mdlname ));
|
||||
@@ -161,7 +161,7 @@ void CL_UpdateStudioTexture( mstudiotexture_t *ptexture, int topcolor, int botto
|
||||
COM_StripExtension( mdlname );
|
||||
|
||||
Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );
|
||||
index = RefRenderAPI->GL_FindTexture( texname );
|
||||
index = ref.dllFuncs.GL_FindTexture( texname );
|
||||
if( !index ) return; // couldn't find texture
|
||||
|
||||
// search for pixels
|
||||
@@ -402,11 +402,11 @@ void CL_FreeRemapInfo( remap_info_t *info )
|
||||
if( info->ptexture != NULL )
|
||||
{
|
||||
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
|
||||
RefRenderAPI->GL_FreeTexture( info->ptexture[i].index );
|
||||
ref.dllFuncs.GL_FreeTexture( info->ptexture[i].index );
|
||||
}
|
||||
|
||||
if( info->textures[i] != 0 )
|
||||
RefRenderAPI->GL_FreeTexture( info->textures[i] );
|
||||
ref.dllFuncs.GL_FreeTexture( info->textures[i] );
|
||||
}
|
||||
|
||||
Mem_Free( info ); // release struct
|
||||
|
||||
@@ -134,9 +134,47 @@ const char *CL_GenericHandle( int fileindex )
|
||||
return cl.files_precache[fileindex];
|
||||
}
|
||||
|
||||
int CL_RenderGetParm( int parm, int arg, const qboolean checkRef )
|
||||
{
|
||||
switch( parm )
|
||||
{
|
||||
case PARM_BSP2_SUPPORTED:
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
case PARM_SKY_SPHERE:
|
||||
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
|
||||
case PARAM_GAMEPAUSED:
|
||||
return cl.paused;
|
||||
case PARM_CLIENT_INGAME:
|
||||
return CL_IsInGame();
|
||||
case PARM_MAX_ENTITIES:
|
||||
return clgame.maxEntities;
|
||||
case PARM_FEATURES:
|
||||
return host.features;
|
||||
case PARM_MAP_HAS_DELUXE:
|
||||
return FBitSet( world.flags, FWORLD_HAS_DELUXEMAP );
|
||||
case PARM_CLIENT_ACTIVE:
|
||||
return (cls.state == ca_active);
|
||||
case PARM_DEDICATED_SERVER:
|
||||
return (host.type == HOST_DEDICATED);
|
||||
case PARM_WATER_ALPHA:
|
||||
return FBitSet( world.flags, FWORLD_WATERALPHA );
|
||||
default:
|
||||
if( checkRef ) return ref.dllFuncs.RenderGetParm( parm, arg );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pfnRenderGetParm( int parm, int arg )
|
||||
{
|
||||
return CL_RenderGetParm( parm, arg, true );
|
||||
}
|
||||
|
||||
static render_api_t gRenderAPI =
|
||||
{
|
||||
NULL, // GL_RenderGetParm,
|
||||
pfnRenderGetParm, // GL_RenderGetParm,
|
||||
NULL, // R_GetDetailScaleForTexture,
|
||||
NULL, // R_GetExtraParmsForTexture,
|
||||
CL_GetLightStyle,
|
||||
|
||||
+11
-11
@@ -180,7 +180,7 @@ void SCR_RSpeeds( void )
|
||||
if( !host.allow_console )
|
||||
return;
|
||||
|
||||
if( RefRenderIface->R_SpeedsMessage( msg, sizeof( msg )))
|
||||
if( ref.dllFuncs.R_SpeedsMessage( msg, sizeof( msg )))
|
||||
{
|
||||
int x, y, height;
|
||||
char *p, *start, *end;
|
||||
@@ -327,7 +327,7 @@ void SCR_DrawPlaque( void )
|
||||
{
|
||||
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
|
||||
{
|
||||
int levelshot = RefRenderAPI->GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
|
||||
int levelshot = ref.dllFuncs.GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
|
||||
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
|
||||
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
|
||||
if( !cl.background ) CL_DrawHUD( CL_LOADING );
|
||||
@@ -527,7 +527,7 @@ qboolean SCR_LoadFixedWidthFont( const char *fontname )
|
||||
if( !FS_FileExists( fontname, false ))
|
||||
return false;
|
||||
|
||||
cls.creditsFont.hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
|
||||
cls.creditsFont.hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
|
||||
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
|
||||
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = fontWidth / 16;
|
||||
cls.creditsFont.type = FONT_FIXED;
|
||||
@@ -559,7 +559,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname )
|
||||
if( !FS_FileExists( fontname, false ))
|
||||
return false;
|
||||
|
||||
cls.creditsFont.hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
|
||||
cls.creditsFont.hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
|
||||
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
|
||||
|
||||
// half-life font with variable chars witdh
|
||||
@@ -668,24 +668,24 @@ void SCR_RegisterTextures( void )
|
||||
// register gfx.wad images
|
||||
|
||||
if( FS_FileExists( "gfx/paused.lmp", false ))
|
||||
cls.pauseIcon = RefRenderAPI->GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "gfx/pause.lmp", false ))
|
||||
cls.pauseIcon = RefRenderAPI->GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
|
||||
cls.pauseIcon = ref.dllFuncs.GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( FS_FileExists( "gfx/lambda.lmp", false ))
|
||||
{
|
||||
if( cl_allow_levelshots->value )
|
||||
cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
else if( FS_FileExists( "gfx/loading.lmp", false ))
|
||||
{
|
||||
if( cl_allow_levelshots->value )
|
||||
cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
|
||||
cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
|
||||
else cls.loadingBar = ref.dllFuncs.GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
|
||||
cls.tileImage = RefRenderAPI->GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
|
||||
cls.tileImage = ref.dllFuncs.GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3081,7 +3081,7 @@ int CL_DecalIndex( int id )
|
||||
if( cl.decal_index[id] == 0 )
|
||||
{
|
||||
Image_SetForceFlags( IL_LOAD_DECAL );
|
||||
cl.decal_index[id] = RefRenderAPI->GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
|
||||
cl.decal_index[id] = ref.dllFuncs.GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
|
||||
Image_ClearForceFlags();
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ void V_RefApplyOverview( ref_viewpass_t *rvp )
|
||||
|
||||
SetBits( rvp->flags, RF_DRAW_OVERVIEW );
|
||||
|
||||
RefRenderIface->GL_OrthoBounds( mins, maxs );
|
||||
ref.dllFuncs.GL_OrthoBounds( mins, maxs );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -332,15 +332,10 @@ void V_RenderView( void )
|
||||
|
||||
if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||
{
|
||||
#if 0
|
||||
pglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
pglClear( GL_COLOR_BUFFER_BIT );
|
||||
#else
|
||||
ref.dllFuncs.R_ClearScreen();
|
||||
#endif
|
||||
}
|
||||
|
||||
RefRenderIface->GL_RenderFrame( &rvp );
|
||||
ref.dllFuncs.GL_RenderFrame( &rvp );
|
||||
S_UpdateFrame( &rvp );
|
||||
viewnum++;
|
||||
|
||||
|
||||
+10
-5
@@ -750,6 +750,11 @@ void CL_ResetFrame( frame_t *frame );
|
||||
void CL_WriteMessageHistory( void );
|
||||
const char *CL_MsgInfo( int cmd );
|
||||
|
||||
//
|
||||
// cl_efx.c
|
||||
//
|
||||
void CL_Particle( const vec3_t org, int color, float life, int zpos, int zvel );
|
||||
|
||||
//
|
||||
// cl_main.c
|
||||
//
|
||||
@@ -933,11 +938,6 @@ void CL_SetUpPlayerPrediction( int dopred, int bIncludeLocalClient );
|
||||
//
|
||||
void CL_ParseQuakeMessage( sizebuf_t *msg, qboolean normal_message );
|
||||
|
||||
//
|
||||
// cl_studio.c
|
||||
//
|
||||
void CL_InitStudioAPI( void );
|
||||
|
||||
//
|
||||
// cl_frame.c
|
||||
//
|
||||
@@ -965,6 +965,11 @@ void CL_FreeRemapInfo( remap_info_t *info );
|
||||
void CL_UpdateRemapInfo( int topcolor, int bottomcolor );
|
||||
void CL_ClearAllRemaps( void );
|
||||
|
||||
//
|
||||
// cl_render.c
|
||||
//
|
||||
int CL_RenderGetParm( int parm, int arg, const qboolean checkRef );
|
||||
|
||||
//
|
||||
// cl_tent.c
|
||||
//
|
||||
|
||||
+10
-10
@@ -531,7 +531,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font )
|
||||
return false;
|
||||
|
||||
// keep source to print directly into conback image
|
||||
font->hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
|
||||
font->hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
|
||||
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
|
||||
|
||||
if( font->hFontTexture && fontWidth != 0 )
|
||||
@@ -567,7 +567,7 @@ static qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font
|
||||
if( !FS_FileExists( fontname, false ))
|
||||
return false;
|
||||
|
||||
font->hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
|
||||
font->hFontTexture = ref.dllFuncs.GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
|
||||
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
|
||||
|
||||
// setup consolefont
|
||||
@@ -2319,28 +2319,28 @@ void Con_VidInit( void )
|
||||
{
|
||||
// trying to load truecolor image first
|
||||
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( !con.background )
|
||||
{
|
||||
if( FS_FileExists( "cached/conback640", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "cached/conback", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// trying to load truecolor image first
|
||||
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
|
||||
|
||||
if( !con.background )
|
||||
{
|
||||
if( FS_FileExists( "cached/loading640", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
|
||||
else if( FS_FileExists( "cached/loading", false ))
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2376,13 +2376,13 @@ void Con_VidInit( void )
|
||||
y = Q_strlen( ver );
|
||||
for( x = 0; x < y; x++ )
|
||||
Con_DrawCharToConback( ver[x], buf, dest + (x << 3));
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
|
||||
}
|
||||
if( cb ) Mem_Free( cb );
|
||||
}
|
||||
|
||||
if( !con.background ) // trying the load unmodified conback
|
||||
con.background = RefRenderAPI->GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
|
||||
con.background = ref.dllFuncs.GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
|
||||
}
|
||||
|
||||
// missed console image will be replaced as gray background like X-Ray or Crysis
|
||||
|
||||
+18
-37
@@ -29,8 +29,8 @@ void GL_FreeImage( const char *name )
|
||||
{
|
||||
int texnum;
|
||||
|
||||
if(( texnum = RefRenderAPI->GL_FindTexture( name )) != 0 )
|
||||
RefRenderAPI->GL_FreeTexture( texnum );
|
||||
if(( texnum = ref.dllFuncs.GL_FindTexture( name )) != 0 )
|
||||
ref.dllFuncs.GL_FreeTexture( texnum );
|
||||
}
|
||||
|
||||
static int TriGetRenderMode( void )
|
||||
@@ -38,9 +38,13 @@ static int TriGetRenderMode( void )
|
||||
return clgame.ds.renderMode;
|
||||
}
|
||||
|
||||
static int pfnRefRenderGetParm( int parm, int arg )
|
||||
{
|
||||
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
||||
}
|
||||
|
||||
static ref_api_t gEngfuncs =
|
||||
{
|
||||
TriGetRenderMode
|
||||
};
|
||||
|
||||
static void R_UnloadProgs( void )
|
||||
@@ -61,37 +65,6 @@ static void R_UnloadProgs( void )
|
||||
Cmd_Unlink( CMD_REFDLL );
|
||||
}
|
||||
|
||||
static int CL_RenderGetParm( int parm, int arg )
|
||||
{
|
||||
switch( parm )
|
||||
{
|
||||
case PARM_BSP2_SUPPORTED:
|
||||
#ifdef SUPPORT_BSP2_FORMAT
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
case PARM_SKY_SPHERE:
|
||||
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
|
||||
case PARAM_GAMEPAUSED:
|
||||
return cl.paused;
|
||||
case PARM_CLIENT_INGAME:
|
||||
return CL_IsInGame();
|
||||
case PARM_MAX_ENTITIES:
|
||||
return clgame.maxEntities;
|
||||
case PARM_FEATURES:
|
||||
return host.features;
|
||||
case PARM_MAP_HAS_DELUXE:
|
||||
return FBitSet( world.flags, FWORLD_HAS_DELUXEMAP );
|
||||
case PARM_CLIENT_ACTIVE:
|
||||
return (cls.state == ca_active);
|
||||
case PARM_DEDICATED_SERVER:
|
||||
return (host.type == HOST_DEDICATED);
|
||||
case PARM_WATER_ALPHA:
|
||||
return FBitSet( world.flags, FWORLD_WATERALPHA );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
|
||||
{
|
||||
dst->version = TRI_API_VERSION;
|
||||
@@ -165,10 +138,10 @@ static qboolean R_LoadProgs( const char *name )
|
||||
|
||||
refState.developer = host_developer.value;
|
||||
|
||||
if( !ref.dllFuncs.R_Init( true ) )
|
||||
if( !ref.dllFuncs.R_Init( ) )
|
||||
{
|
||||
COM_FreeLibrary( ref.hInstance );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer: %s\n", ref.dllFuncs.R_GetInitError() );
|
||||
Con_Reportf( "R_LoadProgs: can't init renderer!\n" ); //, ref.dllFuncs.R_GetInitError() );
|
||||
ref.hInstance = NULL;
|
||||
return false;
|
||||
}
|
||||
@@ -203,9 +176,17 @@ qboolean R_Init( void )
|
||||
{
|
||||
char refdll[64];
|
||||
|
||||
refdll[0] = 0;
|
||||
|
||||
if( !Sys_GetParmFromCmdLine( "-ref", refdll ) )
|
||||
{
|
||||
Q_strncpy( refdll, DEFAULT_RENDERER, sizeof( refdll ));
|
||||
Q_snprintf( refdll, sizeof( refdll ), "%s%s.%s",
|
||||
#ifdef OS_LIB_PREFIX
|
||||
OS_LIB_PREFIX,
|
||||
#else
|
||||
"",
|
||||
#endif
|
||||
DEFAULT_RENDERER, OS_LIB_EXT );
|
||||
}
|
||||
|
||||
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
|
||||
|
||||
@@ -33,9 +33,7 @@ extern ref_globals_t refState;
|
||||
|
||||
// handy API wrappers
|
||||
void R_GetTextureParms( int *w, int *h, int texnum );
|
||||
#define RefRenderAPI ref.dllFuncs.RenderAPI
|
||||
#define RefRenderIface ref.dllFuncs.RenderIface
|
||||
#define RENDER_GET_PARM( parm, arg ) RefRenderAPI->RenderGetParm( (parm), (arg) )
|
||||
#define RENDER_GET_PARM( parm, arg ) ref.dllFuncs.RenderGetParm( (parm), (arg) )
|
||||
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false )
|
||||
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true )
|
||||
|
||||
|
||||
@@ -1801,7 +1801,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
|
||||
{
|
||||
#ifndef XASH_DEDICATED
|
||||
// release old sky layers first
|
||||
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE );
|
||||
ref.dllFuncs.R_FreeSharedTexture( REF_ALPHASKY_TEXTURE );
|
||||
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE );
|
||||
#endif
|
||||
}
|
||||
@@ -1896,7 +1896,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
|
||||
|
||||
if( FS_FileExists( texpath, false ))
|
||||
{
|
||||
tx->gl_texturenum = RefRenderAPI->GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS );
|
||||
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS );
|
||||
bmod->wadlist.wadusage[j]++; // this wad are really used
|
||||
break;
|
||||
}
|
||||
@@ -1912,7 +1912,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
|
||||
|
||||
if( custom_palette ) size += sizeof( short ) + 768;
|
||||
Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name );
|
||||
tx->gl_texturenum = RefRenderAPI->GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS );
|
||||
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS );
|
||||
}
|
||||
|
||||
// if texture is completely missed
|
||||
@@ -1935,7 +1935,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
|
||||
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
|
||||
|
||||
if( custom_palette ) size += sizeof( short ) + 768;
|
||||
tx->fb_texturenum = RefRenderAPI->GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA );
|
||||
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1960,7 +1960,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
|
||||
}
|
||||
|
||||
// okay, loading it from wad or hi-res version
|
||||
tx->fb_texturenum = RefRenderAPI->GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
|
||||
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
|
||||
if( src ) Mem_Free( src );
|
||||
}
|
||||
}
|
||||
@@ -2823,8 +2823,8 @@ void Mod_UnloadBrushModel( model_t *mod )
|
||||
if( !tx || tx->gl_texturenum == ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) )
|
||||
continue; // free slot
|
||||
|
||||
RefRenderAPI->GL_FreeTexture( tx->gl_texturenum ); // main texture
|
||||
RefRenderAPI->GL_FreeTexture( tx->fb_texturenum ); // luma texture
|
||||
ref.dllFuncs.GL_FreeTexture( tx->gl_texturenum ); // main texture
|
||||
ref.dllFuncs.GL_FreeTexture( tx->fb_texturenum ); // luma texture
|
||||
}
|
||||
#endif
|
||||
Mem_FreePool( &mod->mempool );
|
||||
|
||||
@@ -166,6 +166,8 @@ typedef struct studiohdr_s studiohdr_t;
|
||||
typedef struct mstudioseqdesc_s mstudioseqdesc_t;
|
||||
typedef struct mstudiobone_s mstudiobone_t;
|
||||
typedef struct mstudioanim_s mstudioanim_t;
|
||||
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded );
|
||||
void Mod_UnloadStudioModel( model_t *mod );
|
||||
void Mod_InitStudioAPI( void );
|
||||
void Mod_InitStudioHull( void );
|
||||
void Mod_ResetStudioAPI( void );
|
||||
|
||||
+23
-3
@@ -115,6 +115,24 @@ static void Mod_FreeModel( model_t *mod )
|
||||
if( ref.dllFuncs.Mod_UnloadModel )
|
||||
ref.dllFuncs.Mod_UnloadModel( mod );
|
||||
|
||||
switch( mod->type )
|
||||
{
|
||||
case mod_studio:
|
||||
Mod_UnloadStudioModel( mod );
|
||||
break;
|
||||
case mod_alias:
|
||||
// REFTODO:
|
||||
// Mod_UnloadAliasModel( mod );
|
||||
break;
|
||||
case mod_sprite:
|
||||
Mod_UnloadSpriteModel( mod );
|
||||
break;
|
||||
case mod_brush:
|
||||
Mod_UnloadBrushModel( mod );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
memset( mod, 0, sizeof( *mod ));
|
||||
}
|
||||
|
||||
@@ -287,18 +305,20 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
switch( *(uint *)buf )
|
||||
{
|
||||
case IDSTUDIOHEADER:
|
||||
ref.dllFuncs.Mod_LoadModel( mod_studio, mod, buf, &loaded, 0 );
|
||||
Mod_LoadStudioModel( mod, buf, &loaded );
|
||||
break;
|
||||
case IDSPRITEHEADER:
|
||||
ref.dllFuncs.Mod_LoadModel( mod_sprite, mod, buf, &loaded, 0 );
|
||||
Mod_LoadSpriteModel( mod, buf, &loaded, 0 );
|
||||
break;
|
||||
case IDALIASHEADER:
|
||||
// REFTODO: move alias loader to engine
|
||||
ref.dllFuncs.Mod_LoadModel( mod_alias, mod, buf, &loaded, 0 );
|
||||
break;
|
||||
case Q1BSP_VERSION:
|
||||
case HLBSP_VERSION:
|
||||
case QBSP2_VERSION:
|
||||
ref.dllFuncs.Mod_LoadModel( mod_brush, mod, buf, &loaded, 0 );
|
||||
Mod_LoadBrushModel( mod, buf, &loaded );
|
||||
// ref.dllFuncs.Mod_LoadModel( mod_brush, mod, buf, &loaded, 0 );
|
||||
break;
|
||||
default:
|
||||
Mem_Free( buf );
|
||||
|
||||
@@ -16,7 +16,9 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "mathlib.h"
|
||||
#include "pm_local.h"
|
||||
#include "ref_common.h"
|
||||
#ifndef XASH_DEDICATED
|
||||
#include "client.h" // CL_Particle
|
||||
#endif
|
||||
|
||||
// expand debugging BBOX particle hulls by this many units.
|
||||
#define BOX_GAP 0.0f
|
||||
@@ -42,7 +44,7 @@ void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float li
|
||||
while( curdist <= len )
|
||||
{
|
||||
VectorMA( start, curdist, diff, pos );
|
||||
ref.dllFuncs.CL_Particle( pos, pcolor, life, 0, zvel );
|
||||
CL_Particle( pos, pcolor, life, 0, zvel );
|
||||
curdist += 2.0f;
|
||||
}
|
||||
#endif // XASH_DEDICATED
|
||||
|
||||
+75
-14
@@ -359,8 +359,8 @@ struct mip_s;
|
||||
typedef struct ref_interface_s
|
||||
{
|
||||
// construct, destruct
|
||||
qboolean (*R_Init)( qboolean context ); // context is true if you need context management
|
||||
const char *(*R_GetInitError)( void );
|
||||
qboolean (*R_Init)( void ); // context is true if you need context management
|
||||
// const char *(*R_GetInitError)( void );
|
||||
void (*R_Shutdown)( void );
|
||||
|
||||
//
|
||||
@@ -370,11 +370,9 @@ typedef struct ref_interface_s
|
||||
|
||||
void (*R_BeginFrame)( qboolean clearScene );
|
||||
void (*R_RenderScene)( void );
|
||||
// void (*R_RenderFrame)( struct ref_viewpass_s *rvp ); part of RenderInterface
|
||||
void (*R_EndFrame)( void );
|
||||
void (*R_PushScene)( void );
|
||||
void (*R_PopScene)( void );
|
||||
// void (*R_ClearScene)( void ); part of RenderInterface
|
||||
void (*GL_BackendStartFrame)( void );
|
||||
void (*GL_BackendEndFrame)( void );
|
||||
|
||||
@@ -382,7 +380,7 @@ typedef struct ref_interface_s
|
||||
void (*R_AllowFog)( qboolean allow );
|
||||
void (*GL_SetRenderMode)( int renderMode );
|
||||
|
||||
int (*R_AddEntity)( int entityType, cl_entity_t *ent );
|
||||
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
||||
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
|
||||
|
||||
// view info
|
||||
@@ -448,9 +446,6 @@ typedef struct ref_interface_s
|
||||
void (*Mod_StudioLoadTextures)( model_t *mod, void *data );
|
||||
void (*Mod_StudioUnloadTextures)( void *data );
|
||||
|
||||
// particle renderer
|
||||
void (*CL_Particle)( const vec3_t origin, int color, float life, int zpos, int zvel ); // debug thing
|
||||
|
||||
// efx implementation
|
||||
void (*CL_DrawParticles)( double frametime, particle_t *particles, float partsize );
|
||||
void (*CL_DrawTracers)( double frametime, particle_t *tracers );
|
||||
@@ -458,8 +453,67 @@ typedef struct ref_interface_s
|
||||
qboolean (*R_BeamCull)( const vec3_t start, const vec3_t end, qboolean pvsOnly );
|
||||
|
||||
// Xash3D Render Interface
|
||||
render_api_t *RenderAPI; // partial RenderAPI implementation
|
||||
render_interface_t *RenderIface; // compatible RenderInterface implementation: renderer should call client RenderInterface by itself
|
||||
// Get renderer info (doesn't changes engine state at all)
|
||||
int (*RenderGetParm)( int parm, int arg ); // generic
|
||||
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
|
||||
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
|
||||
float (*GetFrameTime)( void );
|
||||
|
||||
// Set renderer info (tell engine about changes)
|
||||
void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel
|
||||
void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged
|
||||
void (*R_StoreEfrags)( struct efrag_s **ppefrag, int framecount );// store efrags for static entities
|
||||
|
||||
// Texture tools
|
||||
int (*GL_FindTexture)( const char *name );
|
||||
const char* (*GL_TextureName)( unsigned int texnum );
|
||||
const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL
|
||||
int (*GL_LoadTexture)( const char *name, const byte *buf, size_t size, int flags );
|
||||
int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, texFlags_t flags );
|
||||
int (*GL_LoadTextureArray)( const char **names, int flags );
|
||||
int (*GL_CreateTextureArray)( const char *name, int width, int height, int depth, const void *buffer, texFlags_t flags );
|
||||
void (*GL_FreeTexture)( unsigned int texnum );
|
||||
|
||||
// Decals manipulating (draw & remove)
|
||||
void (*DrawSingleDecal)( struct decal_s *pDecal, struct msurface_s *fa );
|
||||
float *(*R_DecalSetupVerts)( struct decal_s *pDecal, struct msurface_s *surf, int texture, int *outCount );
|
||||
void (*R_EntityRemoveDecals)( struct model_s *mod ); // remove all the decals from specified entity (BSP only)
|
||||
|
||||
// AVI
|
||||
void (*AVI_UploadRawFrame)( int texture, int cols, int rows, int width, int height, const byte *data );
|
||||
|
||||
// glState related calls (must use this instead of normal gl-calls to prevent de-synchornize local states between engine and the client)
|
||||
void (*GL_Bind)( int tmu, unsigned int texnum );
|
||||
void (*GL_SelectTexture)( int tmu );
|
||||
void (*GL_LoadTextureMatrix)( const float *glmatrix );
|
||||
void (*GL_TexMatrixIdentity)( void );
|
||||
void (*GL_CleanUpTextureUnits)( int last ); // pass 0 for clear all the texture units
|
||||
void (*GL_TexGen)( unsigned int coord, unsigned int mode );
|
||||
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
|
||||
void (*GL_TexCoordArrayMode)( unsigned int texmode );
|
||||
void (*GL_UpdateTexSize)( int texnum, int width, int height, int depth ); // recalc statistics
|
||||
void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility
|
||||
void (*GL_Reserved1)( void );
|
||||
|
||||
// Misc renderer functions
|
||||
void (*GL_DrawParticles)( const struct ref_viewpass_s *rvp, qboolean trans_pass, float frametime );
|
||||
colorVec (*LightVec)( const float *start, const float *end, float *lightspot, float *lightvec );
|
||||
struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e );
|
||||
|
||||
// passed through R_RenderFrame (0 - use engine renderer, 1 - use custom client renderer)
|
||||
int (*GL_RenderFrame)( const struct ref_viewpass_s *rvp );
|
||||
// build all the lightmaps on new level or when gamma is changed
|
||||
void (*GL_BuildLightmaps)( void );
|
||||
// setup map bounds for ortho-projection when we in dev_overview mode
|
||||
void (*GL_OrthoBounds)( const float *mins, const float *maxs );
|
||||
// grab r_speeds message
|
||||
qboolean (*R_SpeedsMessage)( char *out, size_t size );
|
||||
// get visdata for current frame from custom renderer
|
||||
byte* (*Mod_GetCurrentVis)( void );
|
||||
// tell the renderer what new map is started
|
||||
void (*R_NewMap)( void );
|
||||
// clear the render entities before each frame
|
||||
void (*R_ClearScene)( void );
|
||||
|
||||
// TriAPI Interface
|
||||
// NOTE: implementation isn't required to be compatible
|
||||
@@ -480,10 +534,17 @@ typedef struct ref_interface_s
|
||||
void (*CullFace)( TRICULLSTYLE mode );
|
||||
|
||||
// vgui drawing implementation
|
||||
vguiapi_t *VGuiAPI;
|
||||
|
||||
// efx api
|
||||
efx_api_t *EfxAPI;
|
||||
void (*VGUI_DrawInit)( void );
|
||||
void (*VGUI_DrawShutdown)( void );
|
||||
void (*VGUI_SetupDrawingText)( int *pColor );
|
||||
void (*VGUI_SetupDrawingRect)( int *pColor );
|
||||
void (*VGUI_SetupDrawingImage)( int *pColor );
|
||||
void (*VGUI_BindTexture)( int id );
|
||||
void (*VGUI_EnableTexture)( qboolean enable );
|
||||
void (*VGUI_CreateTexture)( int id, int width, int height );
|
||||
void (*VGUI_UploadTexture)( int id, const char *buffer, int width, int height );
|
||||
void (*VGUI_UploadTextureBlock)( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight );
|
||||
void (*VGUI_DrawQuad)( const vpoint_t *ul, const vpoint_t *lr );
|
||||
} ref_interface_t;
|
||||
|
||||
typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* engfuncs, ref_globals_t *pGlobals );
|
||||
|
||||
+12
-3
@@ -617,10 +617,19 @@ void SV_RestartDecals( void )
|
||||
|
||||
// g-cont. add space for studiodecals if present
|
||||
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
||||
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
|
||||
|
||||
// remove decals from map
|
||||
ref.dllFuncs.R_ClearAllDecals();
|
||||
if( ref.dllFuncs.R_CreateDecalList )
|
||||
{
|
||||
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
|
||||
|
||||
// remove decals from map
|
||||
ref.dllFuncs.R_ClearAllDecals();
|
||||
}
|
||||
else
|
||||
{
|
||||
// we probably running a dedicated server
|
||||
host.numdecals = 0;
|
||||
}
|
||||
|
||||
// write decals into reliable datagram
|
||||
msg = SV_GetReliableDatagram();
|
||||
|
||||
@@ -2005,7 +2005,7 @@ const char* pfnGetModelName( int modelindex )
|
||||
|
||||
static const byte *GL_TextureData( unsigned int texnum )
|
||||
{
|
||||
return RefRenderAPI->GL_TextureData( texnum );
|
||||
return ref.dllFuncs.GL_TextureData( texnum );
|
||||
}
|
||||
|
||||
static server_physics_api_t gPhysicsAPI =
|
||||
|
||||
@@ -1130,7 +1130,15 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
|
||||
decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
||||
|
||||
// initialize client header
|
||||
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
|
||||
if( ref.dllFuncs.R_CreateDecalList )
|
||||
{
|
||||
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
|
||||
}
|
||||
else
|
||||
{
|
||||
// we probably running a dedicated server
|
||||
header.decalCount = 0;
|
||||
}
|
||||
header.entityCount = sv.num_static_entities;
|
||||
|
||||
if( !changelevel )
|
||||
|
||||
Reference in New Issue
Block a user