Browse Source

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

pull/2/head
Alibek Omarov 5 years ago
parent
commit
97aba69ed0
  1. 2
      common/port.h
  2. 2
      engine/client/cl_frame.c
  3. 4
      engine/client/cl_game.c
  4. 6
      engine/client/cl_gameui.c
  5. 4
      engine/client/cl_parse.c
  6. 2
      engine/client/cl_pmove.c
  7. 12
      engine/client/cl_remap.c
  8. 40
      engine/client/cl_render.c
  9. 22
      engine/client/cl_scrn.c
  10. 2
      engine/client/cl_tent.c
  11. 9
      engine/client/cl_view.c
  12. 15
      engine/client/client.h
  13. 20
      engine/client/console.c
  14. 55
      engine/client/ref_common.c
  15. 4
      engine/client/ref_common.h
  16. 14
      engine/common/mod_bmodel.c
  17. 2
      engine/common/mod_local.h
  18. 26
      engine/common/model.c
  19. 6
      engine/common/pm_debug.c
  20. 89
      engine/ref_api.h
  21. 15
      engine/server/sv_game.c
  22. 2
      engine/server/sv_phys.c
  23. 10
      engine/server/sv_save.c
  24. 450
      ref_gl/gl_context.c
  25. 40
      ref_gl/gl_local.h
  26. 127
      ref_gl/gl_rmain.c
  27. 2
      ref_gl/gl_rsurf.c

2
common/port.h

@ -54,6 +54,8 @@ GNU General Public License for more details. @@ -54,6 +54,8 @@ GNU General Public License for more details.
#define OPEN_COMMAND "xdg-open"
#endif
#define OS_LIB_PREFIX "lib"
#if defined(__ANDROID__)
#if defined(LOAD_HARDFP)
#define POSTFIX "_hardfp"

2
engine/client/cl_frame.c

@ -1288,7 +1288,7 @@ void CL_EmitEntities( void ) @@ -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 )

4
engine/client/cl_game.c

@ -3204,7 +3204,7 @@ check box in pvs (absmin, absmax) @@ -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; @@ -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 = @@ -3681,7 +3680,6 @@ static efx_api_t gEfxApi =
R_LookupColor,
CL_DecalRemoveAll,
CL_FireCustomDecal,
#endif
};
static event_api_t gEventApi =

6
engine/client/cl_gameui.c

@ -390,7 +390,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, int ima @@ -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 @@ -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 ) @@ -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();
}

4
engine/client/cl_parse.c

@ -1547,7 +1547,7 @@ void CL_RegisterResources( sizebuf_t *msg ) @@ -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 ) @@ -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();

2
engine/client/cl_pmove.c

@ -989,7 +989,7 @@ void CL_InitClientMove( void ) @@ -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;

12
engine/client/cl_remap.c

@ -110,7 +110,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco @@ -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 @@ -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 @@ -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 @@ -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 ) @@ -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

40
engine/client/cl_render.c

@ -134,9 +134,47 @@ const char *CL_GenericHandle( int fileindex ) @@ -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,

22
engine/client/cl_scrn.c

@ -180,7 +180,7 @@ void SCR_RSpeeds( void ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 );
}
/*

2
engine/client/cl_tent.c

@ -3081,7 +3081,7 @@ int CL_DecalIndex( int id ) @@ -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();
}

9
engine/client/cl_view.c

@ -216,7 +216,7 @@ void V_RefApplyOverview( ref_viewpass_t *rvp ) @@ -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 ) @@ -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++;

15
engine/client/client.h

@ -750,6 +750,11 @@ void CL_ResetFrame( frame_t *frame ); @@ -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 ); @@ -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 ); @@ -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
//

20
engine/client/console.c

@ -531,7 +531,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font ) @@ -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 @@ -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 ) @@ -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 ) @@ -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

55
engine/client/ref_common.c

@ -29,8 +29,8 @@ void GL_FreeImage( const char *name ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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" );

4
engine/client/ref_common.h

@ -33,9 +33,7 @@ extern ref_globals_t refState; @@ -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 )

14
engine/common/mod_bmodel.c

@ -1801,7 +1801,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 ) @@ -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 );

2
engine/common/mod_local.h

@ -166,6 +166,8 @@ typedef struct studiohdr_s studiohdr_t; @@ -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 );

26
engine/common/model.c

@ -115,6 +115,24 @@ static void Mod_FreeModel( model_t *mod ) @@ -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 ) @@ -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 );

6
engine/common/pm_debug.c

@ -16,7 +16,9 @@ GNU General Public License for more details. @@ -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 @@ -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

89
engine/ref_api.h

@ -359,8 +359,8 @@ struct mip_s; @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 );

15
engine/server/sv_game.c

@ -617,10 +617,19 @@ void SV_RestartDecals( void ) @@ -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();

2
engine/server/sv_phys.c

@ -2005,7 +2005,7 @@ const char* pfnGetModelName( int modelindex ) @@ -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 =

10
engine/server/sv_save.c

@ -1130,7 +1130,15 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int @@ -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 )

450
ref_gl/gl_context.c

@ -34,9 +34,459 @@ void Con_Printf( const char *fmt, ... ) @@ -34,9 +34,459 @@ void Con_Printf( const char *fmt, ... )
va_end( args );
}
static void R_ClearScreen( void )
{
pglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
pglClear( GL_COLOR_BUFFER_BIT );
}
static qboolean IsNormalPass( void )
{
return RP_NORMALPASS();
}
static void R_IncrementSpeedsCounter( int type )
{
switch( type )
{
case RS_ACTIVE_TENTS:
r_stats.c_active_tents_count++;
break;
default:
gEngfuncs.Host_Error( "R_IncrementSpeedsCounter: unsupported type %d\n", type );
}
}
static const byte *R_GetTextureOriginalBuffer( unsigned int idx )
{
gl_texture_t *glt = R_GetTexture( idx );
if( !glt || !glt->original || !glt->original->buffer )
return NULL;
return glt->original->buffer;
}
static int R_GetBuiltinTexture( enum ref_shared_texture_e type )
{
switch( type )
{
case REF_DEFAULT_TEXTURE: return tr.defaultTexture;
case REF_GRAY_TEXTURE: return tr.grayTexture;
case REF_WHITE_TEXTURE: return tr.whiteTexture;
case REF_SOLIDSKY_TEXTURE: return tr.solidskyTexture;
case REF_ALPHASKY_TEXTURE: return tr.alphaskyTexture;
default: gEngfuncs.Host_Error( "R_GetBuiltinTexture: unsupported type %d\n", type );
}
return 0;
}
static void R_FreeSharedTexture( enum ref_shared_texture_e type )
{
int num = 0;
switch( type )
{
case REF_SOLIDSKY_TEXTURE:
num = tr.solidskyTexture;
tr.solidskyTexture = 0;
break;
case REF_ALPHASKY_TEXTURE:
num = tr.alphaskyTexture;
tr.alphaskyTexture = 0;
break;
case REF_DEFAULT_TEXTURE:
case REF_GRAY_TEXTURE:
case REF_WHITE_TEXTURE:
gEngfuncs.Host_Error( "R_FreeSharedTexture: invalid type %d\n", type );
default: gEngfuncs.Host_Error( "R_FreeSharedTexture: unsupported type %d\n", type );
}
GL_FreeTexture( num );
}
/*
=============
CL_FillRGBA
=============
*/
static void CL_FillRGBA( float _x, float _y, float _w, float _h, int r, int g, int b, int a )
{
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
pglBegin( GL_QUADS );
pglVertex2f( _x, _y );
pglVertex2f( _x + _w, _y );
pglVertex2f( _x + _w, _y + _h );
pglVertex2f( _x, _y + _h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
}
/*
=============
pfnFillRGBABlend
=============
*/
static void GAME_EXPORT CL_FillRGBABlend( float _x, float _y, float _w, float _h, int r, int g, int b, int a )
{
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
pglBegin( GL_QUADS );
pglVertex2f( _x, _y );
pglVertex2f( _x + _w, _y );
pglVertex2f( _x + _w, _y + _h );
pglVertex2f( _x, _y + _h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
}
static void Mod_LoadModel( modtype_t desiredType, model_t *mod, const byte *buf, qboolean *loaded, int flags )
{
switch( desiredType )
{
case mod_studio:
// Mod_LoadStudioModel( mod, buf, loaded );
break;
case mod_sprite:
Mod_LoadSpriteModel( mod, buf, loaded, flags );
break;
case mod_alias:
Mod_LoadAliasModel( mod, buf, loaded );
break;
case mod_brush:
// Mod_LoadBrushModel( mod, buf, loaded );
break;
default: gEngfuncs.Host_Error( "Mod_LoadModel: unsupported type %d\n", mod->type );
}
}
static void Mod_UnloadModel( model_t *mod )
{
switch( mod->type )
{
case mod_studio:
// Mod_UnloadStudioModel( mod );
break;
case mod_alias:
Mod_UnloadAliasModel( mod );
break;
case mod_brush:
// Mod_UnloadBrushModel( mod );
break;
case mod_sprite:
Mod_UnloadSpriteModel( mod );
break;
default: gEngfuncs.Host_Error( "Mod_UnloadModel: unsupported type %d\n", mod->type );
}
}
static int GL_RenderGetParm( int parm, int arg )
{
gl_texture_t *glt;
switch( parm )
{
case PARM_TEX_WIDTH:
glt = R_GetTexture( arg );
return glt->width;
case PARM_TEX_HEIGHT:
glt = R_GetTexture( arg );
return glt->height;
case PARM_TEX_SRC_WIDTH:
glt = R_GetTexture( arg );
return glt->srcWidth;
case PARM_TEX_SRC_HEIGHT:
glt = R_GetTexture( arg );
return glt->srcHeight;
case PARM_TEX_GLFORMAT:
glt = R_GetTexture( arg );
return glt->format;
case PARM_TEX_ENCODE:
glt = R_GetTexture( arg );
return glt->encode;
case PARM_TEX_MIPCOUNT:
glt = R_GetTexture( arg );
return glt->numMips;
case PARM_TEX_DEPTH:
glt = R_GetTexture( arg );
return glt->depth;
case PARM_TEX_SKYBOX:
Assert( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
case PARM_TEX_SKYTEXNUM:
return tr.skytexturenum;
case PARM_TEX_LIGHTMAP:
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
return tr.lightmapTextures[arg];
case PARM_WIDESCREEN:
return gpGlobals->wideScreen;
case PARM_FULLSCREEN:
return gpGlobals->fullScreen;
case PARM_SCREEN_WIDTH:
return gpGlobals->width;
case PARM_SCREEN_HEIGHT:
return gpGlobals->height;
case PARM_TEX_TARGET:
glt = R_GetTexture( arg );
return glt->target;
case PARM_TEX_TEXNUM:
glt = R_GetTexture( arg );
return glt->texnum;
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_ACTIVE_TMU:
return glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
return tr.lightstylevalue[arg];
case PARM_MAX_IMAGE_UNITS:
return GL_MaxTextureUnits();
case PARM_REBUILD_GAMMA:
return glConfig.softwareGammaUpdate;
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < WORLDMODEL->numsurfaces )
return gEngfuncs.Mod_SampleSizeForFace( &WORLDMODEL->surfaces[arg] );
return LM_SAMPLE_SIZE;
case PARM_GL_CONTEXT_TYPE:
return glConfig.context;
case PARM_GLES_WRAPPER:
return glConfig.wrapper;
case PARM_STENCIL_ACTIVE:
return glState.stencilEnabled;
case PARM_SKY_SPHERE:
return gEngfuncs.CL_GetRenderParm( parm, arg ) && !tr.fCustomSkybox;
default:
return gEngfuncs.CL_GetRenderParm( parm, arg );
}
return 0;
}
static void R_GetDetailScaleForTexture( int texture, float *xScale, float *yScale )
{
gl_texture_t *glt = R_GetTexture( texture );
if( xScale ) *xScale = glt->xscale;
if( yScale ) *yScale = glt->yscale;
}
static void R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
{
gl_texture_t *glt = R_GetTexture( texture );
if( red ) *red = glt->fogParams[0];
if( green ) *green = glt->fogParams[1];
if( blue ) *blue = glt->fogParams[2];
if( density ) *density = glt->fogParams[3];
}
static void R_SetCurrentEntity( cl_entity_t *ent )
{
RI.currententity = ent;
// set model also
if( RI.currententity != NULL )
{
RI.currentmodel = RI.currententity->model;
}
}
static void R_SetCurrentModel( model_t *mod )
{
RI.currentmodel = mod;
}
static float R_GetFrameTime( void )
{
return tr.frametime;
}
static const char *GL_TextureName( unsigned int texnum )
{
return R_GetTexture( texnum )->name;
}
const byte *GL_TextureData( unsigned int texnum )
{
rgbdata_t *pic = R_GetTexture( texnum )->original;
if( pic != NULL )
return pic->buffer;
return NULL;
}
ref_interface_t gReffuncs =
{
R_Init,
R_Shutdown,
GL_InitExtensions,
GL_ClearExtensions,
R_BeginFrame,
R_RenderScene,
R_EndFrame,
R_PushScene,
R_PopScene,
GL_BackendStartFrame,
GL_BackendEndFrame,
R_ClearScreen,
R_AllowFog,
GL_SetRenderMode,
R_AddEntity,
CL_AddCustomBeam,
IsNormalPass,
R_ShowTextures,
R_ShowTree,
R_IncrementSpeedsCounter,
R_GetTextureOriginalBuffer,
GL_LoadTextureFromBuffer,
R_GetBuiltinTexture,
R_FreeSharedTexture,
GL_ProcessTexture,
R_SetupSky,
R_Set2DMode,
R_DrawStretchRaw,
R_DrawStretchPic,
R_DrawTileClear,
CL_FillRGBA,
CL_FillRGBABlend,
VID_ScreenShot,
VID_CubemapShot,
R_LightPoint,
R_AddEfrags,
R_RemoveEfrags,
R_DecalShoot,
R_DecalRemoveAll,
R_CreateDecalList,
R_ClearAllDecals,
R_StudioEstimateFrame,
R_StudioLerpMovement,
CL_InitStudioAPI,
R_InitSkyClouds,
GL_SubdivideSurface,
CL_RunLightStyles,
R_GetSpriteParms,
Mod_LoadModel,
Mod_LoadMapSprite,
Mod_UnloadModel,
Mod_StudioLoadTextures,
Mod_StudioUnloadTextures,
CL_DrawParticles,
CL_DrawTracers,
CL_DrawBeams,
R_BeamCull,
GL_RenderGetParm,
R_GetDetailScaleForTexture,
R_GetExtraParmsForTexture,
R_GetFrameTime,
R_SetCurrentEntity,
R_SetCurrentModel,
R_StoreEfrags,
GL_FindTexture,
GL_TextureName,
GL_TextureData,
GL_LoadTexture,
GL_CreateTexture,
GL_LoadTextureArray,
GL_CreateTextureArray,
GL_FreeTexture,
DrawSingleDecal,
R_DecalSetupVerts,
R_EntityRemoveDecals,
R_UploadStretchRaw,
GL_Bind,
GL_SelectTexture,
GL_LoadTexMatrixExt,
GL_LoadIdentityTexMatrix,
GL_CleanUpTextureUnits,
GL_TexGen,
GL_TextureTarget,
GL_SetTexCoordArrayMode,
GL_UpdateTexSize,
NULL,
NULL,
CL_DrawParticlesExternal,
R_LightVec,
R_StudioGetTexture,
R_RenderFrame,
GL_BuildLightmaps,
Mod_SetOrthoBounds,
R_SpeedsMessage,
Mod_GetCurrentVis,
R_NewMap,
R_ClearScene,
TriRenderMode,
TriBegin,
TriEnd,
_TriColor4f,
TriColor4ub,
TriTexCoord2f,
TriVertex3fv,
TriVertex3f,
TriSpriteTexture,
TriWorldToScreen,
TriFog,
R_ScreenToWorld,
TriGetMatrix,
TriFogParams,
TriCullFace,
VGUI_DrawInit,
VGUI_DrawShutdown,
VGUI_SetupDrawingText,
VGUI_SetupDrawingRect,
VGUI_SetupDrawingImage,
VGUI_BindTexture,
VGUI_EnableTexture,
VGUI_CreateTexture,
VGUI_UploadTexture,
VGUI_UploadTextureBlock,
VGUI_DrawQuad
};
int GAME_EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, ref_globals_t *globals )

40
ref_gl/gl_local.h

@ -297,6 +297,12 @@ void R_ShowTextures( void ); @@ -297,6 +297,12 @@ void R_ShowTextures( void );
void R_ShowTree( void );
void SCR_TimeRefresh_f( void );
//
// gl_beams.c
//
void CL_DrawBeams( int fTrans, BEAM *active_beams );
qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
//
// gl_cull.c
//
@ -382,7 +388,7 @@ void R_TranslateForEntity( cl_entity_t *e ); @@ -382,7 +388,7 @@ void R_TranslateForEntity( cl_entity_t *e );
void R_RotateForEntity( cl_entity_t *e );
void R_SetupGL( qboolean set_gl_state );
qboolean R_InitRenderAPI( void );
void R_AllowFog( int allowed );
void R_AllowFog( qboolean allowed );
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
void R_PushScene( void );
@ -408,7 +414,7 @@ void Matrix4x4_CreateOrtho(matrix4x4 m, float xLeft, float xRight, float yBottom @@ -408,7 +414,7 @@ void Matrix4x4_CreateOrtho(matrix4x4 m, float xLeft, float xRight, float yBottom
void Matrix4x4_CreateModelview( matrix4x4 out );
//
// gl_rmisc.
// gl_rmisc.c
//
void R_ClearStaticEntities( void );
@ -433,6 +439,14 @@ void R_GenerateVBO(); @@ -433,6 +439,14 @@ void R_GenerateVBO();
void R_ClearVBO();
void R_AddDecalVBO( decal_t *pdecal, msurface_t *surf );
//
// gl_rpart.c
//
void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass, float frametime );
void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float partsize );
void CL_DrawTracers( double frametime, particle_t *cl_active_tracers );
//
// gl_sprite.c
//
@ -454,6 +468,11 @@ int R_GetEntityRenderMode( cl_entity_t *ent ); @@ -454,6 +468,11 @@ int R_GetEntityRenderMode( cl_entity_t *ent );
void R_DrawStudioModel( cl_entity_t *e );
player_info_t *pfnPlayerInfo( int index );
void R_GatherPlayerLight( void );
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc );
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
void CL_InitStudioAPI( void );
void Mod_StudioLoadTextures( model_t *mod, void *data );
void Mod_StudioUnloadTextures( void *data );
//
// gl_alias.c
@ -497,13 +516,15 @@ int VGUI_GenerateTexture( void ); @@ -497,13 +516,15 @@ int VGUI_GenerateTexture( void );
//
qboolean R_Init( void );
void R_Shutdown( void );
void GL_InitExtensions( void );
void GL_ClearExtensions( void );
void VID_CheckChanges( void );
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
void GL_FreeImage( const char *name );
qboolean VID_ScreenShot( const char *filename, int shot_type );
qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot );
void R_BeginFrame( qboolean clearScene );
void R_RenderFrame( const struct ref_viewpass_s *vp );
int R_RenderFrame( const struct ref_viewpass_s *vp );
void R_EndFrame( void );
void R_ClearScene( void );
void R_GetTextureParms( int *w, int *h, int texnum );
@ -529,9 +550,12 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos @@ -529,9 +550,12 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
void R_RemoveEfrags( struct cl_entity_s *ent );
void R_AddEfrags( struct cl_entity_s *ent );
void R_DecalRemoveAll( int texture );
int R_CreateDecalList( decallist_t *pList );
void R_ClearAllDecals( void );
byte *Mod_GetCurrentVis( void );
void Mod_SetOrthoBounds( float *mins, float *maxs );
void Mod_SetOrthoBounds( const float *mins, const float *maxs );
void R_NewMap( void );
void CL_AddCustomBeam( cl_entity_t *pEnvBeam );
//
// gl_opengl.c
@ -547,14 +571,20 @@ void GL_SetExtension( int r_ext, int enable ); @@ -547,14 +571,20 @@ void GL_SetExtension( int r_ext, int enable );
//
// gl_triapi.c
//
void TriRenderMode( int mode );
void TriBegin( int mode );
void TriEnd( void );
void TriTexCoord2f( float u, float v );
void TriVertex3fv( const float *v );
void TriVertex3f( float x, float y, float z );
void _TriColor4f( float r, float g, float b, float a );
void TriColor4ub( byte r, byte g, byte b, byte a );
int TriWorldToScreen( float *world, float *screen );
int TriSpriteTexture( model_t *pSpriteModel, int frame );
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn );
void TriGetMatrix( const int pname, float *matrix );
void TriFogParams( float flDensity, int iFogSkybox );
void TriCullFace( TRICULLSTYLE mode );
/*
=======================================================================

127
ref_gl/gl_rmain.c

@ -39,7 +39,7 @@ static int R_RankForRenderMode( int rendermode ) @@ -39,7 +39,7 @@ static int R_RankForRenderMode( int rendermode )
return 0;
}
void R_AllowFog( int allowed )
void R_AllowFog( qboolean allowed )
{
static int isFogEnabled;
@ -1086,10 +1086,10 @@ void R_SetupRefParams( const ref_viewpass_t *rvp ) @@ -1086,10 +1086,10 @@ void R_SetupRefParams( const ref_viewpass_t *rvp )
R_RenderFrame
===============
*/
void R_RenderFrame( const ref_viewpass_t *rvp )
int R_RenderFrame( const ref_viewpass_t *rvp )
{
if( r_norefresh->value )
return;
return 1;
// setup the initial render params
R_SetupRefParams( rvp );
@ -1115,7 +1115,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) @@ -1115,7 +1115,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
R_GatherPlayerLight();
tr.realframecount++;
tr.fResetVis = true;
return;
return 1;
}
}
@ -1125,6 +1125,8 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) @@ -1125,6 +1125,8 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
tr.realframecount++; // right called after viewmodel events
R_RenderScene();
return 1;
}
/*
@ -1170,120 +1172,3 @@ void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size ) @@ -1170,120 +1172,3 @@ void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size )
RI.viewleaf = NULL; // force markleafs next frame
}
static int GL_RenderGetParm( int parm, int arg )
{
gl_texture_t *glt;
switch( parm )
{
case PARM_TEX_WIDTH:
glt = R_GetTexture( arg );
return glt->width;
case PARM_TEX_HEIGHT:
glt = R_GetTexture( arg );
return glt->height;
case PARM_TEX_SRC_WIDTH:
glt = R_GetTexture( arg );
return glt->srcWidth;
case PARM_TEX_SRC_HEIGHT:
glt = R_GetTexture( arg );
return glt->srcHeight;
case PARM_TEX_GLFORMAT:
glt = R_GetTexture( arg );
return glt->format;
case PARM_TEX_ENCODE:
glt = R_GetTexture( arg );
return glt->encode;
case PARM_TEX_MIPCOUNT:
glt = R_GetTexture( arg );
return glt->numMips;
case PARM_TEX_DEPTH:
glt = R_GetTexture( arg );
return glt->depth;
case PARM_TEX_SKYBOX:
Assert( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
case PARM_TEX_SKYTEXNUM:
return tr.skytexturenum;
case PARM_TEX_LIGHTMAP:
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
return tr.lightmapTextures[arg];
case PARM_WIDESCREEN:
return gpGlobals->wideScreen;
case PARM_FULLSCREEN:
return gpGlobals->fullScreen;
case PARM_SCREEN_WIDTH:
return gpGlobals->width;
case PARM_SCREEN_HEIGHT:
return gpGlobals->height;
case PARM_TEX_TARGET:
glt = R_GetTexture( arg );
return glt->target;
case PARM_TEX_TEXNUM:
glt = R_GetTexture( arg );
return glt->texnum;
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_ACTIVE_TMU:
return glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
return tr.lightstylevalue[arg];
case PARM_MAX_IMAGE_UNITS:
return GL_MaxTextureUnits();
case PARM_REBUILD_GAMMA:
return glConfig.softwareGammaUpdate;
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < WORLDMODEL->numsurfaces )
return gEngfuncs.Mod_SampleSizeForFace( &WORLDMODEL->surfaces[arg] );
return LM_SAMPLE_SIZE;
case PARM_GL_CONTEXT_TYPE:
return glConfig.context;
case PARM_GLES_WRAPPER:
return glConfig.wrapper;
case PARM_STENCIL_ACTIVE:
return glState.stencilEnabled;
case PARM_SKY_SPHERE:
return gEngfuncs.CL_GetRenderParm( parm, arg ) && !tr.fCustomSkybox;
default:
return gEngfuncs.CL_GetRenderParm( parm, arg );
}
return 0;
}
static void R_GetDetailScaleForTexture( int texture, float *xScale, float *yScale )
{
gl_texture_t *glt = R_GetTexture( texture );
if( xScale ) *xScale = glt->xscale;
if( yScale ) *yScale = glt->yscale;
}
static void R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
{
gl_texture_t *glt = R_GetTexture( texture );
if( red ) *red = glt->fogParams[0];
if( green ) *green = glt->fogParams[1];
if( blue ) *blue = glt->fogParams[2];
if( density ) *density = glt->fogParams[3];
}
static void R_SetCurrentEntity( cl_entity_t *ent )
{
RI.currententity = ent;
// set model also
if( RI.currententity != NULL )
{
RI.currentmodel = RI.currententity->model;
}
}
static void R_SetCurrentModel( model_t *mod )
{
RI.currentmodel = mod;
}

2
ref_gl/gl_rsurf.c

@ -50,7 +50,7 @@ byte *Mod_GetCurrentVis( void ) @@ -50,7 +50,7 @@ byte *Mod_GetCurrentVis( void )
return RI.visbytes;
}
void Mod_SetOrthoBounds( float *mins, float *maxs )
void Mod_SetOrthoBounds( const float *mins, const float *maxs )
{
if( gEngfuncs.drawFuncs.GL_OrthoBounds )
{

Loading…
Cancel
Save