ref: implement API interface for ref_gl, get rid of RenderAPI, RenderInterface and vgui_support API references

This commit is contained in:
Alibek Omarov
2019-03-15 21:23:59 +03:00
parent 234507b7f1
commit 97aba69ed0
27 changed files with 733 additions and 249 deletions
+1 -1
View File
@@ -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 )
+1 -3
View File
@@ -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 =
+3 -3
View File
@@ -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( &copy );
ref.dllFuncs.GL_RenderFrame( &copy );
ref.dllFuncs.R_Set2DMode( true );
ref.dllFuncs.R_PopScene();
}
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -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;
+6 -6
View File
@@ -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
+39 -1
View File
@@ -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
View File
@@ -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 );
}
/*
+1 -1
View File
@@ -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();
}
+2 -7
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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" );
+1 -3
View File
@@ -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 )