ref: fix all undefined references

This commit is contained in:
Alibek Omarov 2019-03-11 17:37:58 +03:00
parent d0d5fd1a3f
commit 234507b7f1
27 changed files with 249 additions and 175 deletions

View File

@ -2119,14 +2119,17 @@ void CL_FreeDeadBeams()
void CL_DrawEFX( float time, qboolean fTrans )
{
CL_FreeDeadBeams();
ref.dllFuncs.CL_DrawBeams( fTrans, cl_active_beams );
if( CVAR_TO_BOOL( cl_draw_beams ))
ref.dllFuncs.CL_DrawBeams( fTrans, cl_active_beams );
if( fTrans )
{
R_FreeDeadParticles( &cl_active_particles );
ref.dllFuncs.CL_DrawParticles( time, cl_active_particles );
if( CVAR_TO_BOOL( cl_draw_particles ))
ref.dllFuncs.CL_DrawParticles( time, cl_active_particles, PART_SIZE );
R_FreeDeadParticles( &cl_active_tracers );
ref.dllFuncs.CL_DrawTracers( time, cl_active_tracers );
if( CVAR_TO_BOOL( cl_draw_tracers ))
ref.dllFuncs.CL_DrawTracers( time, cl_active_tracers );
}
}

View File

@ -3242,14 +3242,6 @@ void TriColor4fRendermode( float r, float g, float b, float a, int rendermode )
else ref.dllFuncs.Color4f( r * a, g * a, b * a, 1.0f );
}
int TriSpriteTexture( model_t *pSpriteModel, int frame )
{
if( ref.dllFuncs.SpriteTexture( pSpriteModel, frame ))
return 1;
return 0;
}
/*
=================
DemoApi implementation

View File

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "entity_types.h"
#include "vgui_draw.h"
#include "sound.h"
#include "platform/platform.h" // GL_UpdateSwapInterval
/*
===============
@ -294,6 +295,8 @@ qboolean V_PreRender( void )
ref.dllFuncs.R_BeginFrame( !cl.paused );
GL_UpdateSwapInterval( );
return true;
}

View File

@ -105,7 +105,7 @@ static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src
dst->Vertex3fv = src->Vertex3fv;
dst->Brightness = TriBrightness;
dst->CullFace = TriCullFace;
dst->SpriteTexture = TriSpriteTexture;
dst->SpriteTexture = src->SpriteTexture;
dst->WorldToScreen = TriWorldToScreen;
dst->Fog = src->Fog;
dst->ScreenToWorld = src->ScreenToWorld;

View File

@ -1161,6 +1161,19 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
return true;
}
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline )
{
char *b;
if( !s ) return NULL;
if( !mempool ) mempool = host.mempool;
b = _Mem_Alloc( mempool, Q_strlen( s ) + 1, false, filename, fileline );
Q_strcpy( b, s );
return b;
}
/*
======================

View File

@ -772,6 +772,10 @@ void Con_Printf( const char *szFmt, ... ) _format( 1 );
int pfnNumberOfEntities( void );
int pfnIsInGame( void );
float pfnTime( void );
#define copystring( s ) _copystring( host.mempool, s, __FILE__, __LINE__ )
#define SV_CopyString( s ) _copystring( svgame.stringspool, s, __FILE__, __LINE__ )
#define freestring( s ) if( s != NULL ) { Mem_Free( s ); s = NULL; }
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline );
// CS:CS engfuncs (stubs)
void *pfnSequenceGet( const char *fileName, const char *entryName );

View File

@ -178,19 +178,6 @@ size_t Q_strncpy( char *dst, const char *src, size_t size )
return ( s - src - 1 ); // count does not include NULL
}
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline )
{
char *b;
if( !s ) return NULL;
if( !mempool ) mempool = host.mempool;
b = _Mem_Alloc( mempool, Q_strlen( s ) + 1, false, filename, fileline );
Q_strcpy( b, s );
return b;
}
int Q_atoi( const char *str )
{
int val = 0;

View File

@ -48,10 +48,6 @@ char Q_tolower( const char in );
size_t Q_strncat( char *dst, const char *src, size_t siz );
#define Q_strcpy( dst, src ) Q_strncpy( dst, src, 99999 )
size_t Q_strncpy( char *dst, const char *src, size_t siz );
#define copystring( s ) _copystring( host.mempool, s, __FILE__, __LINE__ )
#define SV_CopyString( s ) _copystring( svgame.stringspool, s, __FILE__, __LINE__ )
#define freestring( s ) if( s != NULL ) { Mem_Free( s ); s = NULL; }
char *_copystring( byte *mempool, const char *s, const char *filename, int fileline );
uint Q_hashkey( const char *string, uint hashSize, qboolean caseinsensitive );
qboolean Q_isdigit( const char *str );
int Q_atoi( const char *str );

View File

@ -137,7 +137,7 @@ Transfer buffer pointer before Image_LoadMDL
======================
*/
static void *g_mdltexdata;
void Image_SetMDLPointer(byte *p)
void Image_SetMDLPointer( byte *p )
{
g_mdltexdata = p;
}

View File

@ -1048,65 +1048,68 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
phdr = R_StudioLoadHeader( mod, buffer );
if( !phdr ) return; // bad model
#ifndef XASH_DEDICATED
if( phdr->numtextures == 0 )
if( Host_IsDedicated() )
{
studiohdr_t *thdr;
byte *in, *out;
void *buffer2 = NULL;
size_t size1, size2;
buffer2 = FS_LoadFile( Mod_StudioTexName( mod->name ), NULL, false );
thdr = R_StudioLoadHeader( mod, buffer2 );
if( !thdr )
if( phdr->numtextures == 0 )
{
Con_Printf( S_WARN "Mod_LoadStudioModel: %s missing textures file\n", mod->name );
if( buffer2 ) Mem_Free( buffer2 );
studiohdr_t *thdr;
byte *in, *out;
void *buffer2 = NULL;
size_t size1, size2;
buffer2 = FS_LoadFile( Mod_StudioTexName( mod->name ), NULL, false );
thdr = R_StudioLoadHeader( mod, buffer2 );
if( !thdr )
{
Con_Printf( S_WARN "Mod_LoadStudioModel: %s missing textures file\n", mod->name );
if( buffer2 ) Mem_Free( buffer2 );
}
else
{
ref.dllFuncs.Mod_StudioLoadTextures( mod, thdr );
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
mod->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length + size1 + size2 );
memcpy( loadmodel->cache.data, buffer, phdr->length ); // copy main mdl buffer
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
phdr->numskinfamilies = thdr->numskinfamilies;
phdr->numtextures = thdr->numtextures;
phdr->numskinref = thdr->numskinref;
phdr->textureindex = phdr->length;
phdr->skinindex = phdr->textureindex + size1;
in = (byte *)thdr + thdr->textureindex;
out = (byte *)phdr + phdr->textureindex;
memcpy( out, in, size1 + size2 ); // copy textures + skinrefs
phdr->length += size1 + size2;
Mem_Free( buffer2 ); // release T.mdl
}
}
else
{
ref.dllFuncs.Mod_StudioLoadTextures( mod, thdr );
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short );
mod->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length + size1 + size2 );
memcpy( loadmodel->cache.data, buffer, phdr->length ); // copy main mdl buffer
// NOTE: don't modify source buffer because it's used for CRC computing
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
phdr->numskinfamilies = thdr->numskinfamilies;
phdr->numtextures = thdr->numtextures;
phdr->numskinref = thdr->numskinref;
phdr->textureindex = phdr->length;
phdr->skinindex = phdr->textureindex + size1;
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
in = (byte *)thdr + thdr->textureindex;
out = (byte *)phdr + phdr->textureindex;
memcpy( out, in, size1 + size2 ); // copy textures + skinrefs
phdr->length += size1 + size2;
Mem_Free( buffer2 ); // release T.mdl
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size
}
}
else
{
// NOTE: don't modify source buffer because it's used for CRC computing
// just copy model into memory
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
phdr->length = phdr->texturedataindex; // update model size
phdr = loadmodel->cache.data;
}
#else
// just copy model into memory
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length );
phdr = loadmodel->cache.data;
#endif
// setup bounding box
if( !VectorCompare( vec3_origin, phdr->bbmin ))
@ -1148,9 +1151,9 @@ void Mod_UnloadStudioModel( model_t *mod )
if( mod->type != mod_studio )
return; // not a studio
#ifndef XASH_DEDICATED
ref.dllFuncs.Mod_StudioUnloadTextures( mod->cache.data );
#endif
if( Host_IsDedicated() )
ref.dllFuncs.Mod_StudioUnloadTextures( mod->cache.data );
Mem_FreePool( &mod->mempool );
memset( mod, 0, sizeof( *mod ));
}

View File

@ -89,6 +89,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen );
int R_MaxVideoModes();
vidmode_t*R_GetVideoMode( int num );
void* GL_GetProcAddress( const char *name ); // RenderAPI requirement
void GL_UpdateSwapInterval( void );
/*
==============================================================================

View File

@ -27,6 +27,7 @@ GNU General Public License for more details.
#include "studio.h"
#include "r_efx.h"
#include "cvar.h"
#include "com_image.h"
#define REF_API_VERSION 1
@ -137,6 +138,12 @@ typedef enum ref_connstate_e
ref_ca_cinematic, // playing a cinematic, not connected to a server
} ref_connstate_t;
enum ref_defaultsprite_e
{
REF_DOT_SPRITE, // cl_sprite_dot
REF_CHROME_SPRITE // cl_sprite_shell
};
struct con_nprint_s;
struct remap_info_s;
@ -150,7 +157,10 @@ typedef struct ref_api_s
ref_connstate_t (*CL_GetConnState)( void ); // cls.state == ca_connected
int (*IsDemoPlaying)( void ); // cls.demoplayback
int (*GetWaterLevel)( void ); // cl.local.waterlevel
int (*CL_GetRenderParm)( int parm, int arg ); // generic
int (*CL_GetRenderParm)( int parm, int arg ); // generic int (*GetMaxClients)( void );
int (*GetMaxClients)( void ); // cl.maxclients
int (*GetLocalHealth)( void ); // cl.local.health
qboolean (*Host_IsLocalGame)( void );
// cvar handlers
convar_t *(*Cvar_Get)( const char *szName, const char *szValue, int flags, const char *description );
@ -158,6 +168,8 @@ typedef struct ref_api_s
float (*pfnGetCvarFloat)( const char *szName );
const char *(*pfnGetCvarString)( const char *szName );
void (*Cvar_SetValue)( const char *name, float value );
void (*Cvar_RegisterVariable)( convar_t *var );
void (*Cvar_FullSet)( const char *var_name, const char *value, int flags );
// command handlers
int (*Cmd_AddCommand)( const char *cmd_name, void (*function)(void), const char *description );
@ -199,12 +211,14 @@ typedef struct ref_api_s
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
struct world_static_s *(*GetWorld)( void ); // returns &world
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
void (*Mod_CreatePolygonsForHull)( int hullnum );
// studio models
void (*R_StudioSlerpBones)( int numbones, vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
void (*R_StudioCalcBoneQuaternion)( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, vec4_t q );
void (*R_StudioCalcBonePosition)( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, vec3_t adj, vec3_t pos );
void *(*R_StudioGetAnim)( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
void (*pfnStudioEvent)( const struct mstudioevent_s *event, const cl_entity_t *entity );
// efx
void (*CL_DrawEFX)( float time, qboolean fTrans );
@ -214,6 +228,8 @@ typedef struct ref_api_s
efrag_t* (*GetEfragsFreeList)( void ); // clgame.free_efrags
void (*SetEfragsFreeList)( efrag_t* ); // clgame.free_efrags
color24 *(*GetTracerColors)( int num );
struct dlight_s *(*CL_AllocElight)( int key );
struct model_s *(*GetDefaultSprite)( enum ref_defaultsprite_e spr );
// model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
@ -247,6 +263,10 @@ typedef struct ref_api_s
// studio interface
player_info_t *(*pfnPlayerInfo)( int index );
entity_state_t *(*pfnGetPlayerState)( int index );
void *(*Mod_CacheCheck)( struct cache_user_s *c );
void (*Mod_LoadCacheFile)( const char *path, struct cache_user_s *cu );
void *(*Mod_Calloc)( int number, size_t size );
int (*pfnGetStudioModelInterface)( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
// memory
byte *(*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
@ -315,17 +335,22 @@ typedef struct ref_api_s
// imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
void (*Image_SetForceFlags)( uint flags );
void (*Image_ClearForceFlags)( void );
qboolean (*Image_CustomPalette)( void );
qboolean (*Image_Process)( rgbdata_t **pix, int width, int height, uint flags, float bumpscale );
rgbdata_t *(*FS_LoadImage)( const char *filename, const byte *buffer, size_t size );
qboolean (*FS_SaveImage)( const char *filename, rgbdata_t *pix );
rgbdata_t *(*FS_CopyImage)( rgbdata_t *in );
void (*FS_FreeImage)( rgbdata_t *pack );
void (*Image_SetMDLPointer)( byte *p );
byte *(*Image_GetPool)( void );
struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
// client exports
void (*pfnDrawNormalTriangles)( void );
void (*pfnDrawTransparentTriangles)( void );
int (*pfnGetRenderInterface)( int version, render_api_t *renderfuncs, render_interface_t *callback );
render_interface_t drawFuncs;
} ref_api_t;
struct mip_s;
@ -427,7 +452,7 @@ typedef struct ref_interface_s
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 );
void (*CL_DrawParticles)( double frametime, particle_t *particles, float partsize );
void (*CL_DrawTracers)( double frametime, particle_t *tracers );
void (*CL_DrawBeams)( int fTrans , BEAM *beams );
qboolean (*R_BeamCull)( const vec3_t start, const vec3_t end, qboolean pvsOnly );

View File

@ -1450,7 +1450,7 @@ void R_DrawAliasModel( cl_entity_t *e )
anim = (int)(g_alias.time * 10) & 3;
skin = bound( 0, RI.currententity->curstate.skin, m_pAliasHeader->numskins - 1 );
if( m_fDoRemap ) pinfo = CL_GetRemapInfoForEntity( e );
if( m_fDoRemap ) pinfo = gEngfuncs.CL_GetRemapInfoForEntity( e );
if( r_lightmap->value && !r_fullbright->value )
GL_Bind( XASH_TEXTURE0, tr.whiteTexture );

View File

@ -28,9 +28,9 @@ R_SpeedsMessage
*/
qboolean R_SpeedsMessage( char *out, size_t size )
{
if( gRenderIface.R_SpeedsMessage != NULL )
if( gEngfuncs.drawFuncs.R_SpeedsMessage != NULL )
{
if( gRenderIface.R_SpeedsMessage( out, size ))
if( gEngfuncs.drawFuncs.R_SpeedsMessage( out, size ))
return true;
// otherwise pass to default handler
}
@ -465,7 +465,7 @@ qboolean VID_ScreenShot( const char *filename, int shot_type )
r_shot->height = (gpGlobals->height + 3) & ~3;
r_shot->flags = IMAGE_HAS_COLOR;
r_shot->type = PF_RGB_24;
r_shot->size = r_shot->width * r_shot->height * PFDesc[r_shot->type].bpp;
r_shot->size = r_shot->width * r_shot->height * gEngfuncs.Image_GetPFDesc( r_shot->type )->bpp;
r_shot->palette = NULL;
r_shot->buffer = Mem_Malloc( r_temppool, r_shot->size );

View File

@ -1259,13 +1259,9 @@ draw beam loop
*/
void CL_DrawBeams( int fTrans, BEAM *active_beams )
{
BEAM *pBeam, *pNext;
BEAM *pPrev = NULL;
BEAM *pBeam;
int i, flags;
if( !CVAR_TO_BOOL( cl_draw_beams ))
return;
pglShadeModel( GL_SMOOTH );
pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );

View File

@ -25,6 +25,7 @@ GNU General Public License for more details.
&pos->member != (head); \
pos = list_entry( pos->member.next, winding_t, member ))
// REFTODO: rewrite in triapi
void R_DrawWorldHull( void )
{
hull_model_t *hull = &WORLD->hull_models[0];
@ -34,7 +35,7 @@ void R_DrawWorldHull( void )
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
{
int val = bound( 0, (int)r_showhull->value, 3 );
if( val ) Mod_CreatePolygonsForHull( val );
if( val ) gEngfuncs.Mod_CreatePolygonsForHull( val );
ClearBits( r_showhull->flags, FCVAR_CHANGED );
}

View File

@ -767,7 +767,7 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
if( entityIndex > 0 )
{
ent = CL_GetEntityByIndex( entityIndex );
ent = gEngfuncs.GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
@ -1196,9 +1196,9 @@ int R_CreateDecalList( decallist_t *pList )
total = DecalListAdd( pList, total );
}
if( gRenderIface.R_CreateStudioDecalList )
if( gEngfuncs.drawFuncs.R_CreateStudioDecalList )
{
total += gRenderIface.R_CreateStudioDecalList( pList, total );
total += gEngfuncs.drawFuncs.R_CreateStudioDecalList( pList, total );
}
}
@ -1280,8 +1280,8 @@ void R_ClearAllDecals( void )
R_DecalUnlink( pdecal );
}
if( gRenderIface.R_ClearStudioDecals )
if( gEngfuncs.drawFuncs.R_ClearStudioDecals )
{
gRenderIface.R_ClearStudioDecals();
gEngfuncs.drawFuncs.R_ClearStudioDecals();
}
}

View File

@ -985,7 +985,7 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
{
GLuint cubeTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
qboolean subImage = FBitSet( tex->flags, TF_IMG_UPLOADED );
GLenum inFormat = PFDesc[type].glFormat;
GLenum inFormat = gEngfuncs.Image_GetPFDesc(type)->glFormat;
GLint dataType = GL_UNSIGNED_BYTE;
Assert( tex != NULL );
@ -1446,7 +1446,7 @@ int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags )
SetBits( picFlags, IL_KEEP_8BIT );
// set some image flags
Image_SetForceFlags( picFlags );
gEngfuncs.Image_SetForceFlags( picFlags );
pic = gEngfuncs.FS_LoadImage( name, buf, size );
if( !pic ) return 0; // couldn't loading image
@ -1554,11 +1554,11 @@ int GL_LoadTextureArray( const char **names, int flags )
else
{
// create new image
pic = Mem_Malloc( host.imagepool, sizeof( rgbdata_t ));
pic = Mem_Malloc( gEngfuncs.Image_GetPool(), sizeof( rgbdata_t ));
memcpy( pic, src, sizeof( rgbdata_t ));
// expand pic buffer for all layers
pic->buffer = Mem_Malloc( host.imagepool, pic->size * numLayers );
pic->buffer = Mem_Malloc( gEngfuncs.Image_GetPool(), pic->size * numLayers );
pic->depth = 0;
}

View File

@ -47,7 +47,6 @@ GNU General Public License for more details.
#define WORLD (gEngfuncs.GetWorld())
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
extern render_interface_t gRenderIface;
// make mod_ref.h?
#define LM_SAMPLE_SIZE 16
@ -540,7 +539,6 @@ void R_NewMap( void );
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
const char *GL_ErrorString( int err );
void GL_UpdateSwapInterval( void );
qboolean GL_Support( int r_ext );
int GL_MaxTextureUnits( void );
void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext );
@ -733,10 +731,6 @@ extern convar_t *vid_gamma;
//
// engine shared convars
//
extern convar_t *v_dark;
extern convar_t *cl_draw_beams;
extern convar_t *cl_draw_particles;
extern convar_t *cl_draw_tracers;
extern convar_t *gl_showtextures;
extern convar_t *tracerred;
extern convar_t *tracergreen;

View File

@ -42,10 +42,11 @@ convar_t *gl_round_down;
convar_t *r_vbo;
convar_t *r_vbo_dlightmode;
convar_t *gl_showtextures;
convar_t *gl_wgl_msaa_samples;
convar_t *cl_lightstyle_lerping;
convar_t *vid_brightness;
convar_t *vid_gamma;
convar_t *cl_draw_particles;
convar_t *tracerred;
convar_t *tracergreen;
convar_t *tracerblue;
@ -720,8 +721,8 @@ void GL_InitExtensions( void )
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size );
Cvar_Get( "gl_max_size", va( "%i", glConfig.max_2d_texture_size ), 0, "opengl texture max dims" );
Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )));
gEngfuncs.Cvar_Get( "gl_max_size", va( "%i", glConfig.max_2d_texture_size ), 0, "opengl texture max dims" );
gEngfuncs.Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )));
if( GL_Support( GL_TEXTURE_COMPRESSION_EXT ))
gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE );
@ -805,6 +806,8 @@ void GL_InitCommands( void )
tracerblue = gEngfuncs.pfnGetCvarPointer( "tracerblue" );
traceralpha = gEngfuncs.pfnGetCvarPointer( "traceralpha" );
cl_lightstyle_lerping = gEngfuncs.pfnGetCvarPointer( "cl_lightstyle_lerping" );
gEngfuncs.Cmd_AddCommand( "r_info", R_RenderInfo_f, "display renderer info" );
gEngfuncs.Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );

View File

@ -1045,9 +1045,6 @@ void R_BeginFrame( qboolean clearScene )
if( FBitSet( gl_texture_nearest->flags|gl_lightmap_nearest->flags|gl_texture_anisotropy->flags|gl_texture_lodbias->flags, FCVAR_CHANGED ))
R_SetTextureParameters();
// swapinterval stuff
GL_UpdateSwapInterval();
gEngfuncs.CL_ExtraUpdate ();
}
@ -1109,11 +1106,11 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
}
// completely override rendering
if( gRenderIface.GL_RenderFrame != NULL )
if( gEngfuncs.drawFuncs.GL_RenderFrame != NULL )
{
tr.fCustomRendering = true;
if( gRenderIface.GL_RenderFrame( rvp ))
if( gEngfuncs.drawFuncs.GL_RenderFrame( rvp ))
{
R_GatherPlayerLight();
tr.realframecount++;

View File

@ -122,7 +122,7 @@ void R_NewMap( void )
R_ParseDetailTextures( filepath );
}
if( CVAR_TO_BOOL( v_dark ))
if( gEngfuncs.pfnGetCvarFloat( "v_dark" ))
{
screenfade_t *sf = gEngfuncs.GetScreenFade();
float fadetime = 5.0f;

View File

@ -22,7 +22,6 @@ GNU General Public License for more details.
#include "cl_tent.h"
#include "studio.h"
#define PART_SIZE Q_max( 0.5f, cl_draw_particles->value )
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
/*
@ -32,7 +31,7 @@ CL_DrawParticles
update particle color, position, free expired and draw it
================
*/
void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float partsize )
{
particle_t *p;
vec3_t right, up;
@ -40,9 +39,6 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
int alpha;
float size;
if( !cl_draw_particles->value )
return;
if( !cl_active_particles )
return; // nothing to draw?
@ -60,15 +56,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
{
if(( p->type != pt_blob ) || ( p->packedColor == 255 ))
{
size = PART_SIZE; // get initial size of particle
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
if( size < 20.0f ) size = PART_SIZE;
else size = PART_SIZE + size * 0.002f;
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
@ -154,9 +150,6 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
vec3_t start, end, delta;
particle_t *p;
if( !cl_draw_tracers->value )
return;
// update tracer color if this is changed
if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED ))
{
@ -173,7 +166,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
if( !cl_active_tracers )
return; // nothing to draw?
if( !TriSpriteTexture( cl_sprite_dot, 0 ))
if( !TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_DOT_SPRITE ), 0 ))
return;
pglEnable( GL_BLEND );

View File

@ -45,16 +45,16 @@ static void R_DrawVBO( qboolean drawlightmaps, qboolean drawtextures );
byte *Mod_GetCurrentVis( void )
{
if( gRenderIface.Mod_GetCurrentVis && tr.fCustomRendering )
return gRenderIface.Mod_GetCurrentVis();
if( gEngfuncs.drawFuncs.Mod_GetCurrentVis && tr.fCustomRendering )
return gEngfuncs.drawFuncs.Mod_GetCurrentVis();
return RI.visbytes;
}
void Mod_SetOrthoBounds( float *mins, float *maxs )
{
if( gRenderIface.GL_OrthoBounds )
if( gEngfuncs.drawFuncs.GL_OrthoBounds )
{
gRenderIface.GL_OrthoBounds( mins, maxs );
gEngfuncs.drawFuncs.GL_OrthoBounds( mins, maxs );
}
Vector2Average( maxs, mins, world_orthocenter );
@ -1788,7 +1788,7 @@ void R_GenerateVBO()
// we do not want to write vbo code that does not use multitexture
if( !GL_Support( GL_ARB_VERTEX_BUFFER_OBJECT_EXT ) || !GL_Support( GL_ARB_MULTITEXTURE ) || glConfig.max_texture_units < 2 )
{
Cvar_FullSet( "r_vbo", "0", FCVAR_READ_ONLY );
gEngfuncs.Cvar_FullSet( "r_vbo", "0", FCVAR_READ_ONLY );
return;
}
@ -3419,8 +3419,8 @@ void R_MarkLeaves( void )
if( r_novis->value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
Mod_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, gpGlobals->visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) Mod_FatPVS( test, REFPVS_RADIUS, RI.visbytes, gpGlobals->visbytes, true, novis );
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) gEngfuncs.R_FatPVS( test, REFPVS_RADIUS, RI.visbytes, true, novis );
for( i = 0; i < WORLDMODEL->numleafs; i++ )
{
@ -3528,10 +3528,10 @@ void GL_RebuildLightmaps( void )
}
LM_UploadBlock( false );
if( gRenderIface.GL_BuildLightmaps )
if( gEngfuncs.drawFuncs.GL_BuildLightmaps )
{
// build lightmaps on the client-side
gRenderIface.GL_BuildLightmaps( );
gEngfuncs.drawFuncs.GL_BuildLightmaps( );
}
}
@ -3611,10 +3611,10 @@ void GL_BuildLightmaps( void )
LM_UploadBlock( false );
if( gRenderIface.GL_BuildLightmaps )
if( gEngfuncs.drawFuncs.GL_BuildLightmaps )
{
// build lightmaps on the client-side
gRenderIface.GL_BuildLightmaps( );
gEngfuncs.drawFuncs.GL_BuildLightmaps( );
}
// now gamma and brightness are valid

View File

@ -244,9 +244,9 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
if( loaded ) *loaded = false;
Q_snprintf( texname, sizeof( texname ), "#%s", mod->name );
Image_SetForceFlags( IL_OVERVIEW );
gEngfuncs.Image_SetForceFlags( IL_OVERVIEW );
pix = gEngfuncs.FS_LoadImage( texname, buffer, size );
Image_ClearForceFlags();
gEngfuncs.Image_ClearForceFlags();
if( !pix ) return; // bad image or something else
mod->type = mod_sprite;
@ -294,7 +294,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
temp.height = h;
temp.type = pix->type;
temp.flags = pix->flags;
temp.size = w * h * PFDesc[temp.type].bpp;
temp.size = w * h * gEngfuncs.Image_GetPFDesc(temp.type)->bpp;
temp.buffer = Mem_Malloc( r_temppool, temp.size );
temp.palette = NULL;

View File

@ -144,10 +144,10 @@ void R_StudioInit( void )
r_drawviewmodel = gEngfuncs.Cvar_Get( "r_drawviewmodel", "1", 0, "draw firstperson weapon model" );
Matrix3x4_LoadIdentity( g_studio.rotationmatrix );
Cvar_RegisterVariable( &r_glowshellfreq );
gEngfuncs.Cvar_RegisterVariable( &r_glowshellfreq );
// g-cont. cvar disabled by Valve
// Cvar_RegisterVariable( &r_shadows );
// gEngfuncs.Cvar_RegisterVariable( &r_shadows );
g_studio.interpolate = true;
g_studio.framecount = 0;
@ -454,7 +454,7 @@ R_GetChromeSprite
*/
static model_t *R_GetChromeSprite( void )
{
return cl_sprite_shell;
return gEngfuncs.GetDefaultSprite( REF_CHROME_SPRITE );
}
/*
@ -1826,7 +1826,7 @@ mstudiotexture_t *R_StudioGetTexture( cl_entity_t *e )
thdr = m_pStudioHeader;
if( !thdr ) return NULL;
if( m_fDoRemap ) ptexture = CL_GetRemapInfoForEntity( e )->ptexture;
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( e )->ptexture;
else ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex);
return ptexture;
@ -2425,7 +2425,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
#endif
// g-cont: force for "dev-mode", non-local games and menu preview
if(( host_developer.value || !Host_IsLocalGame( ) || !RI.drawWorld ) && info->model[0] )
if(( gpGlobals->developer || !gEngfuncs.Host_IsLocalGame( ) || !RI.drawWorld ) && info->model[0] )
{
if( Q_strcmp( state->name, info->model ))
{
@ -2530,7 +2530,7 @@ static void R_StudioClientEvents( void )
if( FBitSet( e->curstate.effects, EF_MUZZLEFLASH ))
{
dlight_t *el = CL_AllocElight( 0 );
dlight_t *el = gEngfuncs.CL_AllocElight( 0 );
ClearBits( e->curstate.effects, EF_MUZZLEFLASH );
VectorCopy( e->attachment[0], el->origin );
@ -2550,7 +2550,7 @@ static void R_StudioClientEvents( void )
return;
end = R_StudioEstimateFrame( e, pseqdesc );
start = end - e->curstate.framerate * host.frametime * pseqdesc->fps;
start = end - e->curstate.framerate * gpGlobals->frametime * pseqdesc->fps;
pevent = (mstudioevent_t *)((byte *)m_pStudioHeader + pseqdesc->eventindex);
if( e->latched.sequencetime == e->curstate.animtime )
@ -2566,7 +2566,7 @@ static void R_StudioClientEvents( void )
continue;
if( (float)pevent[i].frame > start && pevent[i].frame <= end )
clgame.dllFuncs.pfnStudioEvent( &pevent[i], e );
gEngfuncs.pfnStudioEvent( &pevent[i], e );
}
}
@ -3075,7 +3075,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
m_nPlayerIndex = pplayer->number - 1;
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= cl.maxclients )
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients() )
return 0;
RI.currentmodel = R_StudioSetupPlayerModel( m_nPlayerIndex );
@ -3144,7 +3144,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
// copy attachments into global entity array
if( RI.currententity->index > 0 )
{
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
}
}
@ -3157,7 +3157,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
RI.currententity->curstate.body = 255;
}
if( !( !host_developer.value && cl.maxclients == 1 ) && ( RI.currentmodel == RI.currententity->model ))
if( !( !gpGlobals->developer && gEngfuncs.GetMaxClients() == 1 ) && ( RI.currentmodel == RI.currententity->model ))
RI.currententity->curstate.body = 1; // force helmet
lighting.plightvec = dir;
@ -3219,7 +3219,7 @@ static int R_StudioDrawModel( int flags )
entity_state_t deadplayer;
int result;
if( RI.currententity->curstate.renderamt <= 0 || RI.currententity->curstate.renderamt > cl.maxclients )
if( RI.currententity->curstate.renderamt <= 0 || RI.currententity->curstate.renderamt > gEngfuncs.GetMaxClients() )
return 0;
// get copy of player
@ -3272,7 +3272,7 @@ static int R_StudioDrawModel( int flags )
// copy attachments into global entity array
if( RI.currententity->index > 0 )
{
cl_entity_t *ent = CL_GetEntityByIndex( RI.currententity->index );
cl_entity_t *ent = gEngfuncs.GetEntityByIndex( RI.currententity->index );
memcpy( ent->attachment, RI.currententity->attachment, sizeof( vec3_t ) * 4 );
}
}
@ -3341,7 +3341,7 @@ void R_DrawStudioModel( cl_entity_t *e )
{
if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
{
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );
cl_entity_t *parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model && parent->model->type == mod_studio )
{
@ -3370,11 +3370,11 @@ void R_RunViewmodelEvents( void )
if( r_drawviewmodel->value == 0 )
return;
if( CL_IsThirdPerson( ))
if( gEngfuncs.CL_IsThirdPersonMode( ))
return;
// ignore in thirdperson, camera view or client is died
if( !RP_NORMALPASS() || cl.local.health <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || gEngfuncs.GetLocalHealth() <= 0 || !CL_IsViewEntityLocalPlayer())
return;
RI.currententity = gEngfuncs.GetViewModel();
@ -3422,11 +3422,11 @@ void R_DrawViewModel( void )
if( r_drawviewmodel->value == 0 )
return;
if( CL_IsThirdPerson( ))
if( gEngfuncs.CL_IsThirdPersonMode( ))
return;
// ignore in thirdperson, camera view or client is died
if( !RP_NORMALPASS() || cl.local.health <= 0 || !CL_IsViewEntityLocalPlayer())
if( !RP_NORMALPASS() || gEngfuncs.GetLocalHealth() <= 0 || !CL_IsViewEntityLocalPlayer())
return;
tr.blend = gEngfuncs.CL_FxBlend( view ) / 255.0f;
@ -3544,7 +3544,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
// NOTE: replace index with pointer to start of imagebuffer, ImageLib expected it
//ptexture->index = (int)((byte *)phdr) + ptexture->index;
Image_SetMDLPointer((byte *)phdr + ptexture->index);
gEngfuncs.Image_SetMDLPointer((byte *)phdr + ptexture->index);
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
@ -3576,7 +3576,7 @@ void Mod_StudioLoadTextures( model_t *mod, void *data )
mstudiotexture_t *ptexture;
int i;
if( !phdr || host.type == HOST_DEDICATED )
if( !phdr )
return;
ptexture = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
@ -3598,7 +3598,7 @@ void Mod_StudioUnloadTextures( void *data )
mstudiotexture_t *ptexture;
int i;
if( !phdr || host.type == HOST_DEDICATED )
if( !phdr )
return;
ptexture = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
@ -3617,16 +3617,36 @@ static model_t *pfnModelHandle( int modelindex )
return gEngfuncs.pfnGetModelByIndex( modelindex );
}
static void *pfnMod_StudioExtradata( mode_t *mod )
static void *pfnMod_CacheCheck( struct cache_user_s *c )
{
return gEngfuncs.Mod_CacheCheck( c );
}
static void *pfnMod_StudioExtradata( model_t *mod )
{
return gEngfuncs.Mod_Extradata( mod_studio, mod );
}
static void pfnMod_LoadCacheFile( const char *path, struct cache_user_s *cu )
{
gEngfuncs.Mod_LoadCacheFile( path, cu );
}
static cvar_t *pfnGetCvarPointer( const char *name )
{
return (cvar_t*)gEngfuncs.pfnGetCvarPointer( name );
}
static void *pfnMod_Calloc( int number, size_t size )
{
return gEngfuncs.Mod_Calloc( number, size );
}
static engine_studio_api_t gStudioAPI =
{
Mod_Calloc,
Mod_CacheCheck,
Mod_LoadCacheFile,
pfnMod_Calloc,
pfnMod_CacheCheck,
pfnMod_LoadCacheFile,
pfnMod_ForName,
pfnMod_StudioExtradata,
pfnModelHandle,
@ -3635,7 +3655,7 @@ static engine_studio_api_t gStudioAPI =
R_StudioGetPlayerState,
pfnGetViewEntity,
pfnGetEngineTimes,
pfnCVarGetPointer,
pfnGetCvarPointer,
pfnGetViewInfo,
R_GetChromeSprite,
pfnGetModelCounters,
@ -3691,16 +3711,13 @@ void CL_InitStudioAPI( void )
pStudioDraw = &gStudioDraw;
// trying to grab them from client.dll
cl_righthand = Cvar_FindVar( "cl_righthand" );
cl_righthand = gEngfuncs.pfnGetCvarPointer( "cl_righthand" );
if( cl_righthand == NULL )
cl_righthand = gEngfuncs.Cvar_Get( "cl_righthand", "0", FCVAR_ARCHIVE, "flip viewmodel (left to right)" );
// Xash will be used internal StudioModelRenderer
if( !clgame.dllFuncs.pfnGetStudioModelInterface )
return;
if( clgame.dllFuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI ))
if( gEngfuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI ))
return;
// NOTE: we always return true even if game interface was not correct

View File

@ -17,6 +17,12 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "const.h"
static struct
{
int renderMode; // override kRenderMode from TriAPI
vec4_t triRGBA;
} ds;
/*
===============================================================
@ -33,6 +39,7 @@ set rendermode
*/
void TriRenderMode( int mode )
{
ds.renderMode = mode;
switch( mode )
{
case kRenderNormal:
@ -115,11 +122,11 @@ void TriEnd( void )
/*
=============
TriColor4f
_TriColor4f
=============
*/
void TriColor4f( float r, float g, float b, float a )
void _TriColor4f( float r, float g, float b, float a )
{
pglColor4f( r, g, b, a );
}
@ -132,7 +139,29 @@ TriColor4ub
*/
void TriColor4ub( byte r, byte g, byte b, byte a )
{
pglColor4ub( r, g, b, a );
ds.triRGBA[0] = r * (1.0f / 255.0f);
ds.triRGBA[1] = g * (1.0f / 255.0f);
ds.triRGBA[2] = b * (1.0f / 255.0f);
ds.triRGBA[3] = a * (1.0f / 255.0f);
_TriColor4f( ds.triRGBA[0], ds.triRGBA[1], ds.triRGBA[2], 1.0f );
}
/*
=================
TriColor4f
=================
*/
void TriColor4f( float r, float g, float b, float a )
{
if( ds.renderMode == kRenderTransAlpha )
TriColor4ub( r * 255.9f, g * 255.9f, b * 255.9f, a * 255.0f );
else _TriColor4f( r * a, g * a, b * a, 1.0 );
ds.triRGBA[0] = r;
ds.triRGBA[1] = g;
ds.triRGBA[2] = b;
ds.triRGBA[3] = a;
}
/*
@ -208,7 +237,7 @@ int TriSpriteTexture( model_t *pSpriteModel, int frame )
GL_Bind( XASH_TEXTURE0, gl_texturenum );
return gl_texturenum; // INCOMPATIBILITY
return 1;
}
/*
@ -299,3 +328,20 @@ void TriCullFace( TRICULLSTYLE mode )
GL_Cull( mode );
}
/*
=============
TriBrightness
=============
*/
void TriBrightness( float brightness )
{
float r, g, b;
r = ds.triRGBA[0] * ds.triRGBA[3] * brightness;
g = ds.triRGBA[1] * ds.triRGBA[3] * brightness;
b = ds.triRGBA[2] * ds.triRGBA[3] * brightness;
_TriColor4f( r, g, b, 1.0f );
}