mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 19:45:05 +08:00
Compare commits
37 Commits
continuous
...
continuous
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74869c8f5d | ||
|
|
dd712a0df9 | ||
|
|
bfdb62d31e | ||
|
|
ae7b9eb28d | ||
|
|
c63e13c8f4 | ||
|
|
d3e1407675 | ||
|
|
e2e4728c7c | ||
|
|
dd3583d11a | ||
|
|
e6924844da | ||
|
|
a49db03561 | ||
|
|
84b7b5803b | ||
|
|
c224d39ba7 | ||
|
|
9b24b08df1 | ||
|
|
a37b0e58f1 | ||
|
|
afca422e35 | ||
|
|
3440ddf443 | ||
|
|
6730ed9555 | ||
|
|
fdd3a44fa0 | ||
|
|
241c926076 | ||
|
|
148a9a5a8c | ||
|
|
513984d7fd | ||
|
|
1009795d5c | ||
|
|
e3d2da74db | ||
|
|
ff3a57ae8a | ||
|
|
271a6e2210 | ||
|
|
0d40357b93 | ||
|
|
a9dcdd034c | ||
|
|
7324ff43fc | ||
|
|
d85e7fc2b1 | ||
|
|
d91ecfa3df | ||
|
|
b7a3a02aad | ||
|
|
5aca78951c | ||
|
|
81abae65b5 | ||
|
|
f5f6d9bbe4 | ||
|
|
ef73b55413 | ||
|
|
8334695522 | ||
|
|
d7f416d659 |
@@ -444,13 +444,16 @@ qboolean AVI_Think( movie_state_t *Avi )
|
|||||||
|
|
||||||
if( Avi->texture == 0 )
|
if( Avi->texture == 0 )
|
||||||
{
|
{
|
||||||
|
int cinTexture = SCR_GetCinematicTexture();
|
||||||
int w = Avi->w >= 0 ? Avi->w : refState.width;
|
int w = Avi->w >= 0 ? Avi->w : refState.width;
|
||||||
int h = Avi->h >= 0 ? Avi->h : refState.height;
|
int h = Avi->h >= 0 ? Avi->h : refState.height;
|
||||||
|
|
||||||
ref.dllFuncs.R_DrawStretchRaw( Avi->x, Avi->y, w, h, Avi->xres, Avi->yres, Avi->dst, redraw );
|
if( redraw )
|
||||||
|
ref.dllFuncs.GL_UpdateTexture( cinTexture, Avi->xres, Avi->yres, Avi->xres, Avi->yres, Avi->dst, PF_BGRA_32 );
|
||||||
|
ref.dllFuncs.R_DrawStretchPic( Avi->x, Avi->y, w, h, 0, 0, 1, 1, cinTexture );
|
||||||
}
|
}
|
||||||
else if( redraw && Avi->texture > 0 )
|
else if( redraw && Avi->texture > 0 )
|
||||||
ref.dllFuncs.AVI_UploadRawFrame( Avi->texture, Avi->xres, Avi->yres, Avi->w, Avi->h, Avi->dst );
|
ref.dllFuncs.GL_UpdateTexture( Avi->texture, Avi->xres, Avi->yres, Avi->w, Avi->h, Avi->dst, PF_BGRA_32 );
|
||||||
|
|
||||||
if( flushing && !decoded )
|
if( flushing && !decoded )
|
||||||
return false; // probably hit an EOF
|
return false; // probably hit an EOF
|
||||||
|
|||||||
@@ -849,6 +849,31 @@ BEAM * GAME_EXPORT R_BeamEnts( int startEnt, int endEnt, int modelIndex, float l
|
|||||||
return pbeam;
|
return pbeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static qboolean R_BeamVisible( const vec3_t start, const vec3_t end )
|
||||||
|
{
|
||||||
|
vec3_t mins, maxs;
|
||||||
|
|
||||||
|
for( int i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
|
if( start[i] < end[i] )
|
||||||
|
{
|
||||||
|
mins[i] = start[i];
|
||||||
|
maxs[i] = end[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mins[i] = end[i];
|
||||||
|
maxs[i] = start[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't let it be zero sized
|
||||||
|
if( mins[i] == maxs[i] )
|
||||||
|
maxs[i] += 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Mod_BoxVisible( mins, maxs, ref.dllFuncs.Mod_GetCurrentVis( ));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
R_BeamPoints
|
R_BeamPoints
|
||||||
@@ -861,7 +886,7 @@ BEAM * GAME_EXPORT R_BeamPoints( vec3_t start, vec3_t end, int modelIndex, float
|
|||||||
{
|
{
|
||||||
BEAM *pbeam;
|
BEAM *pbeam;
|
||||||
|
|
||||||
if( life != 0 && ref.dllFuncs.R_BeamCull( start, end, true ))
|
if( life != 0 && !R_BeamVisible( start, end ))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pbeam = R_BeamAlloc();
|
pbeam = R_BeamAlloc();
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ GNU General Public License for more details.
|
|||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "triangleapi.h"
|
#include "triangleapi.h"
|
||||||
|
#include "r_studioint.h"
|
||||||
|
#include "mod_local.h"
|
||||||
#include "r_efx.h"
|
#include "r_efx.h"
|
||||||
#include "demo_api.h"
|
#include "demo_api.h"
|
||||||
#include "ivoicetweak.h"
|
#include "ivoicetweak.h"
|
||||||
@@ -2173,7 +2175,7 @@ pfnGetViewModel
|
|||||||
|
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
static cl_entity_t* GAME_EXPORT CL_GetViewModel( void )
|
static cl_entity_t *GAME_EXPORT CL_GetViewModel( void )
|
||||||
{
|
{
|
||||||
return &clgame.viewent;
|
return &clgame.viewent;
|
||||||
}
|
}
|
||||||
@@ -3929,6 +3931,69 @@ void CL_UnloadProgs( void )
|
|||||||
memset( &clgame, 0, sizeof( clgame ));
|
memset( &clgame, 0, sizeof( clgame ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static model_t *pfnStudio_Mod_ForName( const char *name, int crash )
|
||||||
|
{
|
||||||
|
return Mod_ForName( name, crash, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *pfnStudio_Mod_Extradata( model_t *mod )
|
||||||
|
{
|
||||||
|
return Mod_StudioExtradata( mod );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pfnStudio_GetAliasScale( float *x, float *y )
|
||||||
|
{
|
||||||
|
if( x ) *x = 1.0f;
|
||||||
|
if( y ) *y = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ***pfnStudio_GetAliasTransform( void )
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static model_t *pfnStudio_GetChromeSprite( void )
|
||||||
|
{
|
||||||
|
return cl_sprite_shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int pfnStudio_IsHardware( void )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static engine_studio_api_t gStudioAPI =
|
||||||
|
{
|
||||||
|
.Mem_Calloc = Mod_Calloc,
|
||||||
|
.Cache_Check = Mod_CacheCheck,
|
||||||
|
.LoadCacheFile = Mod_LoadCacheFile,
|
||||||
|
.Mod_ForName = pfnStudio_Mod_ForName,
|
||||||
|
.Mod_Extradata = pfnStudio_Mod_Extradata,
|
||||||
|
.GetModelByIndex = CL_ModelHandle,
|
||||||
|
.GetCvar = pfnCVarGetPointer,
|
||||||
|
.GetChromeSprite = pfnStudio_GetChromeSprite,
|
||||||
|
.GetAliasScale = pfnStudio_GetAliasScale,
|
||||||
|
.StudioGetAliasTransform = pfnStudio_GetAliasTransform,
|
||||||
|
.GetViewEntity = CL_GetViewModel,
|
||||||
|
.IsHardware = pfnStudio_IsHardware,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void CL_InitStudioAPI( void )
|
||||||
|
{
|
||||||
|
static r_studio_interface_t gDefaultStudioDraw;
|
||||||
|
r_studio_interface_t *pStudioDraw;
|
||||||
|
|
||||||
|
if( !ref.dllFuncs.R_StudioFillAPI( &gStudioAPI, &gDefaultStudioDraw ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
pStudioDraw = &gDefaultStudioDraw;
|
||||||
|
|
||||||
|
if( clgame.dllFuncs.pfnGetStudioModelInterface )
|
||||||
|
clgame.dllFuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI );
|
||||||
|
|
||||||
|
ref.dllFuncs.R_StudioSetDrawInterface( pStudioDraw );
|
||||||
|
}
|
||||||
|
|
||||||
qboolean CL_LoadProgs( const char *name )
|
qboolean CL_LoadProgs( const char *name )
|
||||||
{
|
{
|
||||||
static playermove_t gpMove;
|
static playermove_t gpMove;
|
||||||
@@ -4066,7 +4131,7 @@ qboolean CL_LoadProgs( const char *name )
|
|||||||
// initialize game
|
// initialize game
|
||||||
clgame.dllFuncs.pfnInit();
|
clgame.dllFuncs.pfnInit();
|
||||||
|
|
||||||
ref.dllFuncs.CL_InitStudioAPI();
|
CL_InitStudioAPI();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "mod_local.h"
|
||||||
#include "net_encode.h"
|
#include "net_encode.h"
|
||||||
#include "cl_tent.h"
|
#include "cl_tent.h"
|
||||||
#include "shake.h"
|
#include "shake.h"
|
||||||
@@ -1738,6 +1739,8 @@ void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto )
|
|||||||
// tell rendering system we have a new set of models.
|
// tell rendering system we have a new set of models.
|
||||||
ref.dllFuncs.R_NewMap ();
|
ref.dllFuncs.R_NewMap ();
|
||||||
|
|
||||||
|
Mod_LoadDetailTextures( cl.worldmodel );
|
||||||
|
|
||||||
// check if this map must start from dark screen
|
// check if this map must start from dark screen
|
||||||
CL_StartDark ();
|
CL_StartDark ();
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,11 @@ static void pfnAVI_StreamSound( movie_state_t *avi, int entnum, float fvol, floa
|
|||||||
return; // stub, use AVI_SetParm and AVI_Think to stream AVI sound
|
return; // stub, use AVI_SetParm and AVI_Think to stream AVI sound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pfnAVI_UploadRawFrame( int texture, int cols, int rows, int width, int height, const byte *data )
|
||||||
|
{
|
||||||
|
ref.dllFuncs.GL_UpdateTexture( texture, cols, rows, width, height, data, PF_BGRA_32 );
|
||||||
|
}
|
||||||
|
|
||||||
static render_api_t gRenderAPI =
|
static render_api_t gRenderAPI =
|
||||||
{
|
{
|
||||||
pfnRenderGetParm, // GL_RenderGetParm,
|
pfnRenderGetParm, // GL_RenderGetParm,
|
||||||
@@ -243,7 +248,7 @@ static render_api_t gRenderAPI =
|
|||||||
AVI_GetVideoInfo,
|
AVI_GetVideoInfo,
|
||||||
AVI_GetVideoFrameNumber,
|
AVI_GetVideoFrameNumber,
|
||||||
AVI_GetVideoFrame,
|
AVI_GetVideoFrame,
|
||||||
NULL, // R_UploadStretchRaw,
|
pfnAVI_UploadRawFrame, // AVI_UploadRawFrame
|
||||||
AVI_FreeVideo,
|
AVI_FreeVideo,
|
||||||
AVI_IsActive,
|
AVI_IsActive,
|
||||||
pfnAVI_StreamSound,
|
pfnAVI_StreamSound,
|
||||||
@@ -283,40 +288,6 @@ static render_api_t gRenderAPI =
|
|||||||
COM_SetRandomSeed,
|
COM_SetRandomSeed,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void R_FillRenderAPIFromRef( render_api_t *to, const ref_interface_t *from )
|
|
||||||
{
|
|
||||||
to->GetDetailScaleForTexture = from->GetDetailScaleForTexture;
|
|
||||||
to->GetExtraParmsForTexture = from->GetExtraParmsForTexture;
|
|
||||||
to->GetFrameTime = from->GetFrameTime;
|
|
||||||
to->R_SetCurrentEntity = from->R_SetCurrentEntity;
|
|
||||||
to->R_SetCurrentModel = from->R_SetCurrentModel;
|
|
||||||
to->GL_FindTexture = from->GL_FindTexture;
|
|
||||||
to->GL_TextureName = from->GL_TextureName;
|
|
||||||
to->GL_TextureData = from->GL_TextureData;
|
|
||||||
to->GL_LoadTexture = from->GL_LoadTexture;
|
|
||||||
to->GL_CreateTexture = from->GL_CreateTexture;
|
|
||||||
to->GL_LoadTextureArray = from->GL_LoadTextureArray;
|
|
||||||
to->GL_CreateTextureArray = from->GL_CreateTextureArray;
|
|
||||||
to->GL_FreeTexture = from->GL_FreeTexture;
|
|
||||||
to->DrawSingleDecal = from->DrawSingleDecal;
|
|
||||||
to->R_DecalSetupVerts = from->R_DecalSetupVerts;
|
|
||||||
to->R_EntityRemoveDecals = from->R_EntityRemoveDecals;
|
|
||||||
to->AVI_UploadRawFrame = from->AVI_UploadRawFrame;
|
|
||||||
to->GL_Bind = from->GL_Bind;
|
|
||||||
to->GL_SelectTexture = from->GL_SelectTexture;
|
|
||||||
to->GL_LoadTextureMatrix = from->GL_LoadTextureMatrix;
|
|
||||||
to->GL_TexMatrixIdentity = from->GL_TexMatrixIdentity;
|
|
||||||
to->GL_CleanUpTextureUnits = from->GL_CleanUpTextureUnits;
|
|
||||||
to->GL_TexGen = from->GL_TexGen;
|
|
||||||
to->GL_TextureTarget = from->GL_TextureTarget;
|
|
||||||
to->GL_TexCoordArrayMode = from->GL_TexCoordArrayMode;
|
|
||||||
to->GL_UpdateTexSize = from->GL_UpdateTexSize;
|
|
||||||
to->GL_DrawParticles = from->GL_DrawParticles;
|
|
||||||
to->LightVec = from->LightVec;
|
|
||||||
to->StudioGetTexture = from->StudioGetTexture;
|
|
||||||
to->GL_GetProcAddress = from->R_GetProcAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_InitRenderAPI
|
R_InitRenderAPI
|
||||||
@@ -329,8 +300,15 @@ qboolean R_InitRenderAPI( void )
|
|||||||
// make sure what render functions is cleared
|
// make sure what render functions is cleared
|
||||||
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
|
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
|
||||||
|
|
||||||
// fill missing functions from renderer
|
gRenderAPI.GetDetailScaleForTexture = ref.dllFuncs.R_GetDetailScaleForTexture;
|
||||||
R_FillRenderAPIFromRef( &gRenderAPI, &ref.dllFuncs );
|
gRenderAPI.GL_FindTexture = ref.dllFuncs.GL_FindTexture;
|
||||||
|
gRenderAPI.GL_TextureName = ref.dllFuncs.GL_TextureName;
|
||||||
|
gRenderAPI.GL_TextureData = ref.dllFuncs.GL_TextureData;
|
||||||
|
gRenderAPI.GL_LoadTexture = ref.dllFuncs.GL_LoadTexture;
|
||||||
|
gRenderAPI.GL_FreeTexture = ref.dllFuncs.GL_FreeTexture;
|
||||||
|
gRenderAPI.GL_Bind = ref.dllFuncs.GL_Bind;
|
||||||
|
|
||||||
|
ref.dllFuncs.R_FillRenderAPI( &gRenderAPI );
|
||||||
|
|
||||||
if( clgame.dllFuncs.pfnGetRenderInterface )
|
if( clgame.dllFuncs.pfnGetRenderInterface )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ AVI PLAYING
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static movie_state_t *cin_state;
|
static movie_state_t *cin_state;
|
||||||
|
static int cin_texture;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
@@ -281,6 +282,12 @@ void SCR_InitCinematic( void )
|
|||||||
{
|
{
|
||||||
AVI_Initailize ();
|
AVI_Initailize ();
|
||||||
cin_state = AVI_GetState( CIN_MAIN );
|
cin_state = AVI_GetState( CIN_MAIN );
|
||||||
|
cin_texture = ref.dllFuncs.GL_CreateTexture( "*cintexture", 64, 64, NULL, TF_NOMIPMAP|TF_CLAMP );
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCR_GetCinematicTexture( void )
|
||||||
|
{
|
||||||
|
return cin_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -360,6 +360,29 @@ qboolean V_PreRender( void )
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
====================
|
||||||
|
V_ApplyRefUnderwater
|
||||||
|
|
||||||
|
apply underwater fov effect
|
||||||
|
====================
|
||||||
|
*/
|
||||||
|
static void V_ApplyRefUnderwater( ref_viewpass_t *rvp )
|
||||||
|
{
|
||||||
|
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP|RF_DRAW_OVERVIEW ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( cl.local.waterlevel < 3 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
rvp->fov_x = atan( tan( DEG2RAD( rvp->fov_x ) / 2 ) * ( 0.97f + sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
|
||||||
|
rvp->fov_y = atan( tan( DEG2RAD( rvp->fov_y ) / 2 ) * ( 1.03f - sin( cl.time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
V_RenderView
|
V_RenderView
|
||||||
@@ -389,6 +412,7 @@ void V_RenderView( void )
|
|||||||
clgame.dllFuncs.pfnCalcRefdef( &rp );
|
clgame.dllFuncs.pfnCalcRefdef( &rp );
|
||||||
V_GetRefParams( &rp, &rvp );
|
V_GetRefParams( &rp, &rvp );
|
||||||
V_RefApplyOverview( &rvp );
|
V_RefApplyOverview( &rvp );
|
||||||
|
V_ApplyRefUnderwater( &rvp );
|
||||||
|
|
||||||
if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW ))
|
if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -874,7 +874,6 @@ struct msurface_s *pfnTraceSurface( int ground, float *vstart, float *vend );
|
|||||||
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
|
void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int height );
|
||||||
void CL_DisableScissor( scissor_state_t *scissor );
|
void CL_DisableScissor( scissor_state_t *scissor );
|
||||||
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
|
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
|
||||||
|
|
||||||
static inline cl_entity_t *CL_EDICT_NUM( int index )
|
static inline cl_entity_t *CL_EDICT_NUM( int index )
|
||||||
{
|
{
|
||||||
if( unlikely( !clgame.entities )) // not in game yet
|
if( unlikely( !clgame.entities )) // not in game yet
|
||||||
@@ -1216,6 +1215,7 @@ void SteamBroker_TerminateGameConnection( void );
|
|||||||
// cl_video.c
|
// cl_video.c
|
||||||
//
|
//
|
||||||
void SCR_InitCinematic( void );
|
void SCR_InitCinematic( void );
|
||||||
|
int SCR_GetCinematicTexture( void );
|
||||||
void SCR_FreeCinematic( void );
|
void SCR_FreeCinematic( void );
|
||||||
qboolean SCR_PlayCinematic( const char *name );
|
qboolean SCR_PlayCinematic( const char *name );
|
||||||
qboolean SCR_DrawCinematic( void );
|
qboolean SCR_DrawCinematic( void );
|
||||||
|
|||||||
@@ -287,13 +287,6 @@ static entity_state_t *R_StudioGetPlayerState( int index )
|
|||||||
return &cl.frames[cl.parsecountmod].playerstate[index];
|
return &cl.frames[cl.parsecountmod].playerstate[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pfnGetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
|
|
||||||
{
|
|
||||||
return clgame.dllFuncs.pfnGetStudioModelInterface ?
|
|
||||||
clgame.dllFuncs.pfnGetStudioModelInterface( version, ppinterface, pstudio ) :
|
|
||||||
0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
|
||||||
{
|
{
|
||||||
return &PFDesc[idx];
|
return &PFDesc[idx];
|
||||||
@@ -329,11 +322,6 @@ static qboolean R_Init_Video_( ref_graphic_apis_t type )
|
|||||||
return R_Init_Video( type );
|
return R_Init_Video( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
static mleaf_t *pfnMod_PointInLeaf( const vec3_t p, mnode_t *node )
|
|
||||||
{
|
|
||||||
// FIXME: get rid of this on next RefAPI update
|
|
||||||
return Mod_PointInLeaf( p, node, cl.models[1] );
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ref_api_t gEngfuncs =
|
static const ref_api_t gEngfuncs =
|
||||||
{
|
{
|
||||||
@@ -375,7 +363,7 @@ static const ref_api_t gEngfuncs =
|
|||||||
|
|
||||||
Mod_SampleSizeForFace,
|
Mod_SampleSizeForFace,
|
||||||
Mod_BoxVisible,
|
Mod_BoxVisible,
|
||||||
pfnMod_PointInLeaf,
|
Mod_PointInLeaf,
|
||||||
R_DrawWorldHull,
|
R_DrawWorldHull,
|
||||||
R_DrawModelHull,
|
R_DrawModelHull,
|
||||||
|
|
||||||
@@ -411,7 +399,6 @@ static const ref_api_t gEngfuncs =
|
|||||||
Mod_CacheCheck,
|
Mod_CacheCheck,
|
||||||
Mod_LoadCacheFile,
|
Mod_LoadCacheFile,
|
||||||
Mod_Calloc,
|
Mod_Calloc,
|
||||||
pfnGetStudioModelInterface,
|
|
||||||
|
|
||||||
_Mem_AllocPool,
|
_Mem_AllocPool,
|
||||||
_Mem_FreePool,
|
_Mem_FreePool,
|
||||||
@@ -488,28 +475,82 @@ static void R_UnloadProgs( void )
|
|||||||
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
|
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
|
static void CL_FillTriAPI( triangleapi_t *dst )
|
||||||
{
|
{
|
||||||
dst->version = TRI_API_VERSION;
|
dst->version = TRI_API_VERSION;
|
||||||
dst->Begin = src->Begin;
|
|
||||||
dst->RenderMode = TriRenderMode;
|
dst->RenderMode = TriRenderMode;
|
||||||
dst->End = src->End;
|
|
||||||
dst->Color4f = TriColor4f;
|
dst->Color4f = TriColor4f;
|
||||||
dst->Color4ub = TriColor4ub;
|
dst->Color4ub = TriColor4ub;
|
||||||
dst->TexCoord2f = src->TexCoord2f;
|
|
||||||
dst->Vertex3f = src->Vertex3f;
|
|
||||||
dst->Vertex3fv = src->Vertex3fv;
|
|
||||||
dst->Brightness = TriBrightness;
|
dst->Brightness = TriBrightness;
|
||||||
dst->CullFace = TriCullFace;
|
dst->CullFace = TriCullFace;
|
||||||
dst->SpriteTexture = TriSpriteTexture;
|
dst->SpriteTexture = TriSpriteTexture;
|
||||||
dst->WorldToScreen = TriWorldToScreen;
|
dst->WorldToScreen = TriWorldToScreen;
|
||||||
dst->Fog = src->Fog;
|
|
||||||
dst->ScreenToWorld = src->ScreenToWorld;
|
|
||||||
dst->GetMatrix = src->GetMatrix;
|
|
||||||
dst->BoxInPVS = TriBoxInPVS;
|
dst->BoxInPVS = TriBoxInPVS;
|
||||||
dst->LightAtPoint = TriLightAtPoint;
|
dst->LightAtPoint = TriLightAtPoint;
|
||||||
dst->Color4fRendermode = TriColor4fRendermode;
|
dst->Color4fRendermode = TriColor4fRendermode;
|
||||||
dst->FogParams = src->FogParams;
|
dst->Begin = ref.dllFuncs.Begin;
|
||||||
|
dst->End = ref.dllFuncs.End;
|
||||||
|
dst->Vertex3f = ref.dllFuncs.Vertex3f;
|
||||||
|
dst->Vertex3fv = ref.dllFuncs.Vertex3fv;
|
||||||
|
|
||||||
|
ref.dllFuncs.R_FillTriAPI( dst );
|
||||||
|
}
|
||||||
|
|
||||||
|
static const byte dottexture[8][8] =
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0, 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 1, 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 1, 0, 0, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static void R_CreateBuiltinTextures( void )
|
||||||
|
{
|
||||||
|
uint data4x4[16];
|
||||||
|
uint data16x16[256];
|
||||||
|
byte particle[8 * 8 * 4];
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
// default checkerboard
|
||||||
|
for( y = 0; y < 16; y++ )
|
||||||
|
{
|
||||||
|
for( x = 0; x < 16; x++ )
|
||||||
|
{
|
||||||
|
if(( y < 8 ) ^ ( x < 8 ))
|
||||||
|
data16x16[y * 16 + x] = 0xFFFF00FF;
|
||||||
|
else
|
||||||
|
data16x16[y * 16 + x] = 0xFF000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ref.dllFuncs.GL_CreateTexture( REF_DEFAULT_TEXTURE, 16, 16, data16x16, TF_COLORMAP );
|
||||||
|
|
||||||
|
// particle texture
|
||||||
|
memset( particle, 0, sizeof( particle ));
|
||||||
|
for( x = 0; x < 8; x++ )
|
||||||
|
{
|
||||||
|
for( y = 0; y < 8; y++ )
|
||||||
|
{
|
||||||
|
if( dottexture[x][y] )
|
||||||
|
particle[( y * 8 + x ) * 4 + 3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ref.dllFuncs.GL_CreateTexture( REF_PARTICLE_TEXTURE, 8, 8, particle, TF_CLAMP );
|
||||||
|
|
||||||
|
// solid colors
|
||||||
|
memset( data4x4, 0xFF, sizeof( data4x4 ));
|
||||||
|
ref.dllFuncs.GL_CreateTexture( REF_WHITE_TEXTURE, 4, 4, data4x4, TF_COLORMAP );
|
||||||
|
|
||||||
|
for( x = 0; x < 16; x++ )
|
||||||
|
data4x4[x] = 0xFF7F7F7F;
|
||||||
|
ref.dllFuncs.GL_CreateTexture( REF_GRAY_TEXTURE, 4, 4, data4x4, TF_COLORMAP );
|
||||||
|
|
||||||
|
for( x = 0; x < 16; x++ )
|
||||||
|
data4x4[x] = 0xFF000000;
|
||||||
|
ref.dllFuncs.GL_CreateTexture( REF_BLACK_TEXTURE, 4, 4, data4x4, TF_COLORMAP );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qboolean R_LoadProgs( const char *name )
|
static qboolean R_LoadProgs( const char *name )
|
||||||
@@ -555,8 +596,8 @@ static qboolean R_LoadProgs( const char *name )
|
|||||||
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
|
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
|
||||||
ref.initialized = true;
|
ref.initialized = true;
|
||||||
|
|
||||||
// initialize TriAPI callbacks
|
R_CreateBuiltinTextures();
|
||||||
CL_FillTriAPIFromRef( &gTriApi, &ref.dllFuncs );
|
CL_FillTriAPI( &gTriApi );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2989,6 +2989,105 @@ static void Mod_LoadTextures( model_t *mod, dbspmodel_t *bmod )
|
|||||||
Mod_SequenceAllAnimatedTextures( mod );
|
Mod_SequenceAllAnimatedTextures( mod );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !XASH_DEDICATED
|
||||||
|
static void Mod_ParseDetailTextures( model_t *mod )
|
||||||
|
{
|
||||||
|
byte *afile;
|
||||||
|
char *pfile;
|
||||||
|
string token, texname;
|
||||||
|
string detail_texname;
|
||||||
|
string detail_path;
|
||||||
|
float xScale, yScale;
|
||||||
|
texture_t *tex;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
string filepath;
|
||||||
|
|
||||||
|
Q_strncpy( filepath, mod->name, sizeof( filepath ));
|
||||||
|
COM_StripExtension( filepath );
|
||||||
|
Q_strncat( filepath, "_detail.txt", sizeof( filepath ));
|
||||||
|
|
||||||
|
afile = FS_LoadFile( filepath, NULL, false );
|
||||||
|
if( !afile )
|
||||||
|
return;
|
||||||
|
|
||||||
|
pfile = (char *)afile;
|
||||||
|
|
||||||
|
// format: 'texturename' 'detailtexture' 'xScale' 'yScale'
|
||||||
|
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||||||
|
{
|
||||||
|
texname[0] = '\0';
|
||||||
|
detail_texname[0] = '\0';
|
||||||
|
|
||||||
|
// read texname
|
||||||
|
if( token[0] == '{' )
|
||||||
|
{
|
||||||
|
// NOTE: COM_ParseFile handled some symbols seperately
|
||||||
|
// this code will be fix it
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
|
Q_snprintf( texname, sizeof( texname ), "{%s", token );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Q_strncpy( texname, token, sizeof( texname ));
|
||||||
|
|
||||||
|
// read detailtexture name
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
|
Q_strncpy( detail_texname, token, sizeof( detail_texname ));
|
||||||
|
|
||||||
|
// trying the scales or '{'
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
|
|
||||||
|
// read second part of detailtexture name
|
||||||
|
if( token[0] == '{' )
|
||||||
|
{
|
||||||
|
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token )); // read scales
|
||||||
|
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token )); // parse scales
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_snprintf( detail_path, sizeof( detail_path ), "gfx/%s", detail_texname );
|
||||||
|
|
||||||
|
// read scales
|
||||||
|
xScale = Q_atof( token );
|
||||||
|
|
||||||
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||||||
|
yScale = Q_atof( token );
|
||||||
|
|
||||||
|
if( xScale <= 0.0f || yScale <= 0.0f )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// search for existing texture and uploading detail texture
|
||||||
|
for( i = 0; i < mod->numtextures; i++ )
|
||||||
|
{
|
||||||
|
tex = mod->textures[i];
|
||||||
|
|
||||||
|
if( Q_stricmp( tex->name, texname ))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tex->dt_texturenum = ref.dllFuncs.GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR|TF_NOFLIP_TGA );
|
||||||
|
|
||||||
|
if( tex->dt_texturenum )
|
||||||
|
ref.dllFuncs.R_SetDetailScaleForTexture( tex->gl_texturenum, xScale, yScale );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Mem_Free( afile );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mod_LoadDetailTextures( model_t *mod )
|
||||||
|
{
|
||||||
|
convar_t *r_detailtextures = Cvar_FindVar( "r_detailtextures" );
|
||||||
|
|
||||||
|
if( !r_detailtextures || !r_detailtextures->value )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Mod_ParseDetailTextures( mod );
|
||||||
|
}
|
||||||
|
#endif // !XASH_DEDICATED
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Mod_LoadTexInfo
|
Mod_LoadTexInfo
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC );
|
|||||||
qboolean Mod_ValidateCRC( const char *name, uint32_t crc );
|
qboolean Mod_ValidateCRC( const char *name, uint32_t crc );
|
||||||
void Mod_NeedCRC( const char *name, qboolean needCRC );
|
void Mod_NeedCRC( const char *name, qboolean needCRC );
|
||||||
void Mod_FreeUnused( void );
|
void Mod_FreeUnused( void );
|
||||||
|
void Mod_LoadDetailTextures( model_t *mod );
|
||||||
|
|
||||||
//
|
//
|
||||||
// mod_alias.c
|
// mod_alias.c
|
||||||
|
|||||||
@@ -64,7 +64,15 @@ GNU General Public License for more details.
|
|||||||
// 13. Removed ignore_flags argument from GetCvarPointer
|
// 13. Removed ignore_flags argument from GetCvarPointer
|
||||||
// 14. Removed reserved functions, they are leftover from RenderAPI
|
// 14. Removed reserved functions, they are leftover from RenderAPI
|
||||||
// Removed CL_AddCustomBeam, it's now handled through R_AddEntity
|
// Removed CL_AddCustomBeam, it's now handled through R_AddEntity
|
||||||
#define REF_API_VERSION 14
|
// 15. Replaced CL_InitStudioAPI with R_StudioFillAPI + R_StudioSetDrawInterface
|
||||||
|
// Engine now builds engine_studio_api_t and handles client DLL negotiation
|
||||||
|
// Replaced R_DrawStretchRaw and AVI_UploadRawFrame with GL_UpdateTexture
|
||||||
|
// Added GL_CreateTexture, R_GetDetailScaleForTexture, R_SetDetailScaleForTexture
|
||||||
|
// Removed R_Flush, VGUI_UploadTextureBlock, R_BeamCull, pfnGetStudioModelInterface
|
||||||
|
// Moved RenderAPI and TriAPI filling to renderer via R_FillRenderAPI and R_FillTriAPI
|
||||||
|
// Moved detail textures parsing and cinematic texture management to engine
|
||||||
|
// Moved creation of default textures to the engine
|
||||||
|
#define REF_API_VERSION 15
|
||||||
|
|
||||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
|
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
|
||||||
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
|
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
|
||||||
@@ -223,7 +231,7 @@ enum ref_defaultsprite_e
|
|||||||
};
|
};
|
||||||
|
|
||||||
// the order of first three is important!
|
// the order of first three is important!
|
||||||
// so you can use this value in IEngineStudio.StudioIsHardware
|
// so you can use this value in IEngineStudio.StudioIsHardware (but shouldn't)
|
||||||
typedef enum ref_graphic_apis_e
|
typedef enum ref_graphic_apis_e
|
||||||
{
|
{
|
||||||
REF_SOFTWARE, // hypothetical: just make a surface to draw on, in software
|
REF_SOFTWARE, // hypothetical: just make a surface to draw on, in software
|
||||||
@@ -389,7 +397,7 @@ typedef struct ref_api_s
|
|||||||
// brushes
|
// brushes
|
||||||
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
||||||
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||||
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
|
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node, struct model_s *mod );
|
||||||
void (*R_DrawWorldHull)( void );
|
void (*R_DrawWorldHull)( void );
|
||||||
void (*R_DrawModelHull)( model_t *mod );
|
void (*R_DrawModelHull)( model_t *mod );
|
||||||
|
|
||||||
@@ -431,7 +439,6 @@ typedef struct ref_api_s
|
|||||||
void *(*Mod_CacheCheck)( struct cache_user_s *c );
|
void *(*Mod_CacheCheck)( struct cache_user_s *c );
|
||||||
void (*Mod_LoadCacheFile)( const char *path, struct cache_user_s *cu );
|
void (*Mod_LoadCacheFile)( const char *path, struct cache_user_s *cu );
|
||||||
void *(*Mod_Calloc)( int number, size_t size );
|
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
|
// memory
|
||||||
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline )
|
poolhandle_t (*_Mem_AllocPool)( const char *name, const char *filename, int fileline )
|
||||||
@@ -539,8 +546,6 @@ typedef struct ref_interface_s
|
|||||||
|
|
||||||
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
qboolean (*R_AddEntity)( struct cl_entity_s *clent, int type );
|
||||||
void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
|
void (*R_ProcessEntData)( qboolean allocate, cl_entity_t *entities, unsigned int max_entities );
|
||||||
void (*R_Flush)( unsigned int flush_flags );
|
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
void (*R_ShowTextures)( void );
|
void (*R_ShowTextures)( void );
|
||||||
|
|
||||||
@@ -552,7 +557,6 @@ typedef struct ref_interface_s
|
|||||||
|
|
||||||
// 2D
|
// 2D
|
||||||
void (*R_Set2DMode)( qboolean enable );
|
void (*R_Set2DMode)( qboolean enable );
|
||||||
void (*R_DrawStretchRaw)( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
|
|
||||||
void (*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
void (*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
||||||
void (*FillRGBA)( int rendermode, float x, float y, float w, float h, byte r, byte g, byte b, byte a ); // in screen space
|
void (*FillRGBA)( int rendermode, float x, float y, float w, float h, byte r, byte g, byte b, byte a ); // in screen space
|
||||||
int (*WorldToScreen)( const vec3_t world, vec3_t screen ); // Returns 1 if it's z clipped
|
int (*WorldToScreen)( const vec3_t world, vec3_t screen ); // Returns 1 if it's z clipped
|
||||||
@@ -574,7 +578,8 @@ typedef struct ref_interface_s
|
|||||||
// studio interface
|
// studio interface
|
||||||
float (*R_StudioEstimateFrame)( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
float (*R_StudioEstimateFrame)( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
||||||
void (*R_StudioLerpMovement)( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
void (*R_StudioLerpMovement)( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
||||||
void (*CL_InitStudioAPI)( void );
|
qboolean (*R_StudioFillAPI)( struct engine_studio_api_s *api, struct r_studio_interface_s *pDefaultDraw );
|
||||||
|
void (*R_StudioSetDrawInterface)( struct r_studio_interface_s *pDraw );
|
||||||
|
|
||||||
// bmodel
|
// bmodel
|
||||||
void (*R_SetSkyCloudsTextures)( int solidskyTexture, int alphaskyTexture );
|
void (*R_SetSkyCloudsTextures)( int solidskyTexture, int alphaskyTexture );
|
||||||
@@ -591,53 +596,27 @@ typedef struct ref_interface_s
|
|||||||
void (*CL_DrawParticles)( double frametime, particle_t *particles, float partsize );
|
void (*CL_DrawParticles)( double frametime, particle_t *particles, float partsize );
|
||||||
void (*CL_DrawTracers)( double frametime, particle_t *tracers );
|
void (*CL_DrawTracers)( double frametime, particle_t *tracers );
|
||||||
void (*CL_DrawBeams)( int fTrans , BEAM *beams );
|
void (*CL_DrawBeams)( int fTrans , BEAM *beams );
|
||||||
qboolean (*R_BeamCull)( const vec3_t start, const vec3_t end, qboolean pvsOnly );
|
|
||||||
|
|
||||||
// Xash3D Render Interface
|
// Xash3D Render Interface
|
||||||
// Get renderer info (doesn't changes engine state at all)
|
|
||||||
int (*RefGetParm)( int parm, int arg ); // generic
|
int (*RefGetParm)( 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)
|
// detail texture scale
|
||||||
void (*R_SetCurrentEntity)( struct cl_entity_s *ent ); // tell engine about both currententity and currentmodel
|
void (*R_GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
|
||||||
void (*R_SetCurrentModel)( struct model_s *mod ); // change currentmodel but leave currententity unchanged
|
void (*R_SetDetailScaleForTexture)( int texture, float xScale, float yScale );
|
||||||
|
|
||||||
// Texture tools
|
// Texture tools (used by engine directly)
|
||||||
|
int (*GL_CreateTexture)( const char *name, int width, int height, const void *buffer, texFlags_t flags );
|
||||||
int (*GL_FindTexture)( const char *name );
|
int (*GL_FindTexture)( const char *name );
|
||||||
const char* (*GL_TextureName)( unsigned int texnum );
|
const char* (*GL_TextureName)( unsigned int texnum );
|
||||||
const byte* (*GL_TextureData)( unsigned int texnum ); // may be NULL
|
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_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 );
|
void (*GL_FreeTexture)( unsigned int texnum );
|
||||||
void (*R_OverrideTextureSourceSize)( unsigned int texnum, unsigned int srcWidth, unsigned int srcHeight ); // used to override decal size for texture replacement
|
void (*R_OverrideTextureSourceSize)( unsigned int texnum, unsigned int srcWidth, unsigned int srcHeight ); // used to override decal size for texture replacement
|
||||||
|
|
||||||
// Decals manipulating (draw & remove)
|
void (*GL_UpdateTexture)( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt );
|
||||||
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
|
// glState related calls (used by engine directly)
|
||||||
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_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
|
|
||||||
|
|
||||||
// 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)
|
// passed through R_RenderFrame (0 - use engine renderer, 1 - use custom client renderer)
|
||||||
void (*GL_RenderFrame)( const struct ref_viewpass_s *rvp );
|
void (*GL_RenderFrame)( const struct ref_viewpass_s *rvp );
|
||||||
@@ -651,28 +630,23 @@ typedef struct ref_interface_s
|
|||||||
void (*R_NewMap)( void );
|
void (*R_NewMap)( void );
|
||||||
// clear the render entities before each frame
|
// clear the render entities before each frame
|
||||||
void (*R_ClearScene)( void );
|
void (*R_ClearScene)( void );
|
||||||
// GL_GetProcAddress for client renderer
|
|
||||||
void* (*R_GetProcAddress)( const char *name );
|
|
||||||
|
|
||||||
// TriAPI Interface
|
// TriAPI Interface (functions used by engine wrappers)
|
||||||
// NOTE: implementation isn't required to be compatible
|
|
||||||
void (*TriRenderMode)( int mode );
|
void (*TriRenderMode)( int mode );
|
||||||
void (*Begin)( int primitiveCode );
|
void (*Begin)( int primitiveCode );
|
||||||
void (*End)( void );
|
void (*End)( void );
|
||||||
void (*Color4f)( float r, float g, float b, float a ); // real glColor4f
|
void (*Color4f)( float r, float g, float b, float a ); // real glColor4f
|
||||||
void (*Color4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); // real glColor4ub
|
void (*Color4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); // real glColor4ub
|
||||||
void (*TexCoord2f)( float u, float v );
|
|
||||||
void (*Vertex3fv)( const float *worldPnt );
|
void (*Vertex3fv)( const float *worldPnt );
|
||||||
void (*Vertex3f)( float x, float y, float z );
|
void (*Vertex3f)( float x, float y, float z );
|
||||||
void (*Fog)( float flFogColor[3], float flStart, float flEnd, int bOn ); //Works just like GL_FOG, flFogColor is r/g/b.
|
|
||||||
void (*ScreenToWorld)( const float *screen, float *world );
|
|
||||||
void (*GetMatrix)( const int pname, float *matrix );
|
|
||||||
void (*FogParams)( float flDensity, int iFogSkybox );
|
|
||||||
void (*CullFace)( TRICULLSTYLE mode );
|
void (*CullFace)( TRICULLSTYLE mode );
|
||||||
|
|
||||||
|
// fill render_api_t and triangleapi_t with renderer-specific functions
|
||||||
|
void (*R_FillRenderAPI)( struct render_api_s *api );
|
||||||
|
void (*R_FillTriAPI)( struct triangleapi_s *api );
|
||||||
|
|
||||||
// vgui drawing implementation
|
// vgui drawing implementation
|
||||||
void (*VGUI_SetupDrawing)( qboolean rect );
|
void (*VGUI_SetupDrawing)( qboolean rect );
|
||||||
void (*VGUI_UploadTextureBlock)( int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight );
|
|
||||||
} ref_interface_t;
|
} ref_interface_t;
|
||||||
|
|
||||||
typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* engfuncs, ref_globals_t *pGlobals );
|
typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* engfuncs, ref_globals_t *pGlobals );
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ void R_PushDlightsForBmodel( model_t *model, int framecount, const matrix4x4 obj
|
|||||||
int R_PushDlights( model_t *model, int framecount );
|
int R_PushDlights( model_t *model, int framecount );
|
||||||
colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t lvec );
|
colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t lvec );
|
||||||
colorVec R_LightPoint( const vec3_t p0 );
|
colorVec R_LightPoint( const vec3_t p0 );
|
||||||
|
void R_GatherPlayerLight( cl_entity_t *view );
|
||||||
void R_UpdateSurfaceCachedLight( msurface_t *surf );
|
void R_UpdateSurfaceCachedLight( msurface_t *surf );
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -475,6 +475,20 @@ colorVec R_LightPoint( const vec3_t p0 )
|
|||||||
return R_LightVec( p0, p1, NULL, NULL );
|
return R_LightVec( p0, p1, NULL, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
R_GatherPlayerLight
|
||||||
|
|
||||||
|
get light level of an entity and set it as player's light level
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void R_GatherPlayerLight( cl_entity_t *view )
|
||||||
|
{
|
||||||
|
colorVec c = R_LightPoint( view->origin );
|
||||||
|
|
||||||
|
gEngfuncs.SetLocalLightLevel(( c.r + c.g + c.b ) / 3 );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
R_SetCacheState
|
R_SetCacheState
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ static void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
|
|||||||
if( !plight || !ent )
|
if( !plight || !ent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
||||||
{
|
{
|
||||||
plight->shadelight = 0;
|
plight->shadelight = 0;
|
||||||
plight->ambientlight = 192;
|
plight->ambientlight = 192;
|
||||||
@@ -1126,7 +1126,7 @@ init current time for a given model
|
|||||||
*/
|
*/
|
||||||
static void R_AliasSetupTimings( void )
|
static void R_AliasSetupTimings( void )
|
||||||
{
|
{
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
// synchronize with server time
|
// synchronize with server time
|
||||||
g_alias.time = gp_cl->time;
|
g_alias.time = gp_cl->time;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void GL_BackendEndFrame( void )
|
|||||||
{
|
{
|
||||||
mleaf_t *curleaf;
|
mleaf_t *curleaf;
|
||||||
|
|
||||||
if( r_speeds->value <= 0 || !RI.drawWorld )
|
if( r_speeds->value <= 0 || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !RI.viewleaf )
|
if( !RI.viewleaf )
|
||||||
@@ -616,7 +616,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
|
|||||||
string basename;
|
string basename;
|
||||||
int i = 1, flags, result;
|
int i = 1, flags, result;
|
||||||
|
|
||||||
if( !RI.drawWorld || !WORLDMODEL )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || !WORLDMODEL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// make sure the specified size is valid
|
// make sure the specified size is valid
|
||||||
@@ -633,7 +633,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
|
|||||||
r_side = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
|
r_side = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
|
||||||
|
|
||||||
// use client vieworg
|
// use client vieworg
|
||||||
if( !vieworg ) vieworg = RI.vieworg;
|
if( !vieworg ) vieworg = RI.rvp.vieworigin;
|
||||||
|
|
||||||
for( i = 0; i < 6; i++ )
|
for( i = 0; i < 6; i++ )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ static void R_BeamComputeNormal( const vec3_t vStartPos, const vec3_t vNextPos,
|
|||||||
VectorSubtract( vStartPos, vNextPos, vTangentY );
|
VectorSubtract( vStartPos, vNextPos, vTangentY );
|
||||||
|
|
||||||
// vDirToBeam = vector from viewer origin to beam
|
// vDirToBeam = vector from viewer origin to beam
|
||||||
VectorSubtract( vStartPos, RI.vieworg, vDirToBeam );
|
VectorSubtract( vStartPos, RI.rvp.vieworigin, vDirToBeam );
|
||||||
|
|
||||||
// get a vector that is perpendicular to us and perpendicular to the beam.
|
// get a vector that is perpendicular to us and perpendicular to the beam.
|
||||||
// this is used to fatten the beam.
|
// this is used to fatten the beam.
|
||||||
@@ -114,7 +114,7 @@ R_BeamCull
|
|||||||
Cull the beam by bbox
|
Cull the beam by bbox
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
static qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
||||||
{
|
{
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
int i;
|
int i;
|
||||||
@@ -1006,7 +1006,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||||||
float flDistance;
|
float flDistance;
|
||||||
|
|
||||||
// fade the beam if the player's not looking at the source
|
// fade the beam if the player's not looking at the source
|
||||||
VectorSubtract( RI.vieworg, pbeam->source, localDir );
|
VectorSubtract( RI.rvp.vieworigin, pbeam->source, localDir );
|
||||||
flDot = DotProduct( delta, localDir );
|
flDot = DotProduct( delta, localDir );
|
||||||
VectorScale( delta, flDot, vecProjection );
|
VectorScale( delta, flDot, vecProjection );
|
||||||
VectorSubtract( localDir, vecProjection, tmp );
|
VectorSubtract( localDir, vecProjection, tmp );
|
||||||
|
|||||||
@@ -244,6 +244,14 @@ static void R_GetDetailScaleForTexture( int texture, float *xScale, float *yScal
|
|||||||
if( yScale ) *yScale = glt->yscale;
|
if( yScale ) *yScale = glt->yscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_SetDetailScaleForTexture( int texture, float xScale, float yScale )
|
||||||
|
{
|
||||||
|
gl_texture_t *glt = R_GetTexture( texture );
|
||||||
|
|
||||||
|
glt->xscale = xScale;
|
||||||
|
glt->yscale = yScale;
|
||||||
|
}
|
||||||
|
|
||||||
static void R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
|
static void R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
|
||||||
{
|
{
|
||||||
gl_texture_t *glt = R_GetTexture( texture );
|
gl_texture_t *glt = R_GetTexture( texture );
|
||||||
@@ -311,11 +319,6 @@ static void R_ProcessEntData( qboolean allocate, cl_entity_t *entities, unsigned
|
|||||||
gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
|
gEngfuncs.drawFuncs->R_ProcessEntData( allocate );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
|
||||||
{
|
|
||||||
// stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_SetSkyCloudsTextures
|
R_SetSkyCloudsTextures
|
||||||
@@ -369,11 +372,6 @@ static qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT VGUI_UploadTextureBlock( int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
|
|
||||||
{
|
|
||||||
pglTexSubImage2D( GL_TEXTURE_2D, 0, drawX, drawY, blockWidth, blockHeight, GL_RGBA, GL_UNSIGNED_BYTE, rgba );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GAME_EXPORT VGUI_SetupDrawing( qboolean rect )
|
static void GAME_EXPORT VGUI_SetupDrawing( qboolean rect )
|
||||||
{
|
{
|
||||||
pglEnable( GL_BLEND );
|
pglEnable( GL_BLEND );
|
||||||
@@ -413,6 +411,85 @@ static const char *R_GetConfigName( void )
|
|||||||
return "opengl";
|
return "opengl";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_NewMap( void )
|
||||||
|
{
|
||||||
|
texture_t *tx;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
tr.worldmodel = gp_cl->models[1];
|
||||||
|
|
||||||
|
R_ClearDecals(); // clear all level decals
|
||||||
|
|
||||||
|
R_StudioResetPlayerModels();
|
||||||
|
|
||||||
|
// clear out efrags in case the level hasn't been reloaded
|
||||||
|
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
||||||
|
WORLDMODEL->leafs[i+1].efrags = NULL;
|
||||||
|
|
||||||
|
glState.isFogEnabled = false;
|
||||||
|
tr.skytexturenum = -1;
|
||||||
|
pglDisable( GL_FOG );
|
||||||
|
|
||||||
|
// clearing texture chains
|
||||||
|
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
||||||
|
{
|
||||||
|
if( !WORLDMODEL->textures[i] )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tx = WORLDMODEL->textures[i];
|
||||||
|
|
||||||
|
if( !Q_strncmp( tx->name, "sky", 3 ) && tx->width == ( tx->height * 2 ))
|
||||||
|
tr.skytexturenum = i;
|
||||||
|
|
||||||
|
tx->texturechain = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL_BuildLightmaps ();
|
||||||
|
|
||||||
|
R_ClearVBO();
|
||||||
|
if( R_HasEnabledVBO( ))
|
||||||
|
R_GenerateVBO();
|
||||||
|
R_ResetRipples();
|
||||||
|
|
||||||
|
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
||||||
|
gEngfuncs.drawFuncs->R_NewMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FillRenderAPI( render_api_t *api )
|
||||||
|
{
|
||||||
|
api->GetExtraParmsForTexture = R_GetExtraParmsForTexture;
|
||||||
|
api->GetFrameTime = R_GetFrameTime;
|
||||||
|
api->R_SetCurrentEntity = R_SetCurrentEntity;
|
||||||
|
api->R_SetCurrentModel = R_SetCurrentModel;
|
||||||
|
api->GL_CreateTexture = GL_CreateTexture;
|
||||||
|
api->GL_LoadTextureArray = GL_LoadTextureArray;
|
||||||
|
api->GL_CreateTextureArray = GL_CreateTextureArray;
|
||||||
|
api->DrawSingleDecal = DrawSingleDecal;
|
||||||
|
api->R_DecalSetupVerts = R_DecalSetupVerts;
|
||||||
|
api->R_EntityRemoveDecals = R_EntityRemoveDecals;
|
||||||
|
api->GL_SelectTexture = GL_SelectTexture;
|
||||||
|
api->GL_LoadTextureMatrix = GL_LoadTexMatrixExt;
|
||||||
|
api->GL_TexMatrixIdentity = GL_LoadIdentityTexMatrix;
|
||||||
|
api->GL_CleanUpTextureUnits = GL_CleanUpTextureUnits;
|
||||||
|
api->GL_TexGen = GL_TexGen;
|
||||||
|
api->GL_TextureTarget = GL_TextureTarget;
|
||||||
|
api->GL_TexCoordArrayMode = GL_SetTexCoordArrayMode;
|
||||||
|
api->GL_UpdateTexSize = GL_UpdateTexSize;
|
||||||
|
api->GL_DrawParticles = CL_DrawParticlesExternal;
|
||||||
|
api->LightVec = R_LightVec;
|
||||||
|
api->StudioGetTexture = R_StudioGetTexture;
|
||||||
|
api->GL_GetProcAddress = R_GetProcAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FillTriAPI( triangleapi_t *api )
|
||||||
|
{
|
||||||
|
api->TexCoord2f = TriTexCoord2f;
|
||||||
|
api->Fog = TriFog;
|
||||||
|
api->ScreenToWorld = R_ScreenToWorld;
|
||||||
|
api->GetMatrix = TriGetMatrix;
|
||||||
|
api->FogParams = TriFogParams;
|
||||||
|
}
|
||||||
|
|
||||||
const ref_interface_t gReffuncs =
|
const ref_interface_t gReffuncs =
|
||||||
{
|
{
|
||||||
R_Init,
|
R_Init,
|
||||||
@@ -439,7 +516,6 @@ const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
R_AddEntity,
|
R_AddEntity,
|
||||||
R_ProcessEntData,
|
R_ProcessEntData,
|
||||||
R_Flush,
|
|
||||||
|
|
||||||
R_ShowTextures,
|
R_ShowTextures,
|
||||||
|
|
||||||
@@ -449,7 +525,6 @@ const ref_interface_t gReffuncs =
|
|||||||
R_SetupSky,
|
R_SetupSky,
|
||||||
|
|
||||||
R_Set2DMode,
|
R_Set2DMode,
|
||||||
R_DrawStretchRaw,
|
|
||||||
R_DrawStretchPic,
|
R_DrawStretchPic,
|
||||||
CL_FillRGBA,
|
CL_FillRGBA,
|
||||||
R_WorldToScreen,
|
R_WorldToScreen,
|
||||||
@@ -466,7 +541,8 @@ const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
R_StudioEstimateFrame,
|
R_StudioEstimateFrame,
|
||||||
R_StudioLerpMovement,
|
R_StudioLerpMovement,
|
||||||
CL_InitStudioAPI,
|
R_StudioFillAPI,
|
||||||
|
R_StudioSetDrawInterface,
|
||||||
|
|
||||||
R_SetSkyCloudsTextures,
|
R_SetSkyCloudsTextures,
|
||||||
GL_SubdivideSurface,
|
GL_SubdivideSurface,
|
||||||
@@ -479,45 +555,23 @@ const ref_interface_t gReffuncs =
|
|||||||
CL_DrawParticles,
|
CL_DrawParticles,
|
||||||
CL_DrawTracers,
|
CL_DrawTracers,
|
||||||
CL_DrawBeams,
|
CL_DrawBeams,
|
||||||
R_BeamCull,
|
|
||||||
|
|
||||||
GL_RefGetParm,
|
GL_RefGetParm,
|
||||||
|
|
||||||
R_GetDetailScaleForTexture,
|
R_GetDetailScaleForTexture,
|
||||||
R_GetExtraParmsForTexture,
|
R_SetDetailScaleForTexture,
|
||||||
R_GetFrameTime,
|
|
||||||
|
|
||||||
R_SetCurrentEntity,
|
|
||||||
R_SetCurrentModel,
|
|
||||||
|
|
||||||
|
GL_CreateTexture,
|
||||||
GL_FindTexture,
|
GL_FindTexture,
|
||||||
GL_TextureName,
|
GL_TextureName,
|
||||||
GL_TextureData,
|
GL_TextureData,
|
||||||
GL_LoadTexture,
|
GL_LoadTexture,
|
||||||
GL_CreateTexture,
|
|
||||||
GL_LoadTextureArray,
|
|
||||||
GL_CreateTextureArray,
|
|
||||||
GL_FreeTexture,
|
GL_FreeTexture,
|
||||||
R_OverrideTextureSourceSize,
|
R_OverrideTextureSourceSize,
|
||||||
|
|
||||||
DrawSingleDecal,
|
GL_UpdateTexture,
|
||||||
R_DecalSetupVerts,
|
|
||||||
R_EntityRemoveDecals,
|
|
||||||
|
|
||||||
R_UploadStretchRaw,
|
|
||||||
|
|
||||||
GL_Bind,
|
GL_Bind,
|
||||||
GL_SelectTexture,
|
|
||||||
GL_LoadTexMatrixExt,
|
|
||||||
GL_LoadIdentityTexMatrix,
|
|
||||||
GL_CleanUpTextureUnits,
|
|
||||||
GL_TexGen,
|
|
||||||
GL_TextureTarget,
|
|
||||||
GL_SetTexCoordArrayMode,
|
|
||||||
GL_UpdateTexSize,
|
|
||||||
|
|
||||||
CL_DrawParticlesExternal,
|
|
||||||
R_LightVec,
|
|
||||||
R_StudioGetTexture,
|
|
||||||
|
|
||||||
R_RenderFrame,
|
R_RenderFrame,
|
||||||
Mod_SetOrthoBounds,
|
Mod_SetOrthoBounds,
|
||||||
@@ -525,23 +579,19 @@ const ref_interface_t gReffuncs =
|
|||||||
Mod_GetCurrentVis,
|
Mod_GetCurrentVis,
|
||||||
R_NewMap,
|
R_NewMap,
|
||||||
R_ClearScene,
|
R_ClearScene,
|
||||||
R_GetProcAddress,
|
|
||||||
|
|
||||||
TriRenderMode,
|
TriRenderMode,
|
||||||
TriBegin,
|
TriBegin,
|
||||||
TriEnd,
|
TriEnd,
|
||||||
_TriColor4f,
|
_TriColor4f,
|
||||||
_TriColor4ub,
|
_TriColor4ub,
|
||||||
TriTexCoord2f,
|
|
||||||
TriVertex3fv,
|
TriVertex3fv,
|
||||||
TriVertex3f,
|
TriVertex3f,
|
||||||
TriFog,
|
|
||||||
R_ScreenToWorld,
|
|
||||||
TriGetMatrix,
|
|
||||||
TriFogParams,
|
|
||||||
TriCullFace,
|
TriCullFace,
|
||||||
|
|
||||||
|
R_FillRenderAPI,
|
||||||
|
R_FillTriAPI,
|
||||||
|
|
||||||
VGUI_SetupDrawing,
|
VGUI_SetupDrawing,
|
||||||
VGUI_UploadTextureBlock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ qboolean R_CullModel( const cl_entity_t *e, const vec3_t absmin, const vec3_t ab
|
|||||||
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
|
if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if( RP_NORMALPASS() && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -85,7 +85,7 @@ int R_CullSurface( const msurface_t *surf, const gl_frustum_t *frustum, uint cli
|
|||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
// can use normal.z for world (optimisation)
|
// can use normal.z for world (optimisation)
|
||||||
if( RI.drawOrtho )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
|
||||||
{
|
{
|
||||||
vec3_t orthonormal;
|
vec3_t orthonormal;
|
||||||
|
|
||||||
|
|||||||
123
ref/gl/gl_draw.c
123
ref/gl/gl_draw.c
@@ -55,120 +55,69 @@ void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, f
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_DrawStretchRaw
|
GL_UpdateTexture
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
|
void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt )
|
||||||
{
|
{
|
||||||
byte *raw = NULL;
|
byte *raw = NULL;
|
||||||
gl_texture_t *tex;
|
gl_texture_t *tex;
|
||||||
|
GLenum gl_format;
|
||||||
|
|
||||||
|
switch( fmt )
|
||||||
|
{
|
||||||
|
case PF_RGBA_32:
|
||||||
|
gl_format = GL_RGBA;
|
||||||
|
break;
|
||||||
|
case PF_BGRA_32:
|
||||||
|
gl_format = GL_BGRA;
|
||||||
|
break;
|
||||||
|
case PF_RGB_24:
|
||||||
|
gl_format = GL_RGB;
|
||||||
|
break;
|
||||||
|
case PF_BGR_24:
|
||||||
|
gl_format = GL_BGR;
|
||||||
|
break;
|
||||||
|
case PF_LUMINANCE:
|
||||||
|
gl_format = GL_LUMINANCE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gEngfuncs.Con_DPrintf( S_ERROR "%s: unsupported pixel format %i\n", __func__, fmt );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
|
if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
|
||||||
{
|
{
|
||||||
int width = 1, height = 1;
|
|
||||||
|
|
||||||
// check the dimensions
|
|
||||||
width = NearestPOW( cols, true );
|
|
||||||
height = NearestPOW( rows, false );
|
|
||||||
|
|
||||||
if( cols != width || rows != height )
|
|
||||||
{
|
|
||||||
raw = GL_ResampleTexture( data, cols, rows, width, height, false );
|
|
||||||
cols = width;
|
|
||||||
rows = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
raw = (byte *)data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cols > glConfig.max_2d_texture_size )
|
|
||||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, cols );
|
|
||||||
if( rows > glConfig.max_2d_texture_size )
|
|
||||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, rows );
|
|
||||||
|
|
||||||
pglDisable( GL_BLEND );
|
|
||||||
pglDisable( GL_ALPHA_TEST );
|
|
||||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
|
||||||
|
|
||||||
tex = R_GetTexture( tr.cinTexture );
|
|
||||||
GL_Bind( XASH_TEXTURE0, tr.cinTexture );
|
|
||||||
|
|
||||||
if( cols == tex->width && rows == tex->height )
|
|
||||||
{
|
|
||||||
if( dirty )
|
|
||||||
{
|
|
||||||
pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_BGRA, GL_UNSIGNED_BYTE, raw );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tex->size = cols * rows * 4;
|
|
||||||
tex->width = cols;
|
|
||||||
tex->height = rows;
|
|
||||||
if( dirty )
|
|
||||||
{
|
|
||||||
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pglBegin( GL_QUADS );
|
|
||||||
pglTexCoord2f( 0, 0 );
|
|
||||||
pglVertex2f( x, y );
|
|
||||||
pglTexCoord2f( 1, 0 );
|
|
||||||
pglVertex2f( x + w, y );
|
|
||||||
pglTexCoord2f( 1, 1 );
|
|
||||||
pglVertex2f( x + w, y + h );
|
|
||||||
pglTexCoord2f( 0, 1 );
|
|
||||||
pglVertex2f( x, y + h );
|
|
||||||
pglEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
R_UploadStretchRaw
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data )
|
|
||||||
{
|
|
||||||
byte *raw = NULL;
|
|
||||||
gl_texture_t *tex;
|
|
||||||
|
|
||||||
if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT ))
|
|
||||||
{
|
|
||||||
// check the dimensions
|
|
||||||
width = NearestPOW( width, true );
|
width = NearestPOW( width, true );
|
||||||
height = NearestPOW( height, false );
|
height = NearestPOW( height, false );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
width = bound( 128, width, glConfig.max_2d_texture_size );
|
|
||||||
height = bound( 128, height, glConfig.max_2d_texture_size );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cols != width || rows != height )
|
if( cols != width || rows != height )
|
||||||
{
|
{
|
||||||
raw = GL_ResampleTexture( data, cols, rows, width, height, false );
|
raw = GL_ResampleTexture( buffer, cols, rows, width, height, false );
|
||||||
cols = width;
|
cols = width;
|
||||||
rows = height;
|
rows = height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
raw = (byte *)buffer;
|
||||||
raw = (byte *)data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cols > glConfig.max_2d_texture_size )
|
if( cols > glConfig.max_2d_texture_size )
|
||||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, cols );
|
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, cols );
|
||||||
if( rows > glConfig.max_2d_texture_size )
|
if( rows > glConfig.max_2d_texture_size )
|
||||||
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, rows );
|
gEngfuncs.Host_Error( "%s: size %i exceeds hardware limits\n", __func__, rows );
|
||||||
|
|
||||||
tex = R_GetTexture( texture );
|
tex = R_GetTexture( texnum );
|
||||||
GL_Bind( GL_KEEP_UNIT, texture );
|
GL_Bind( GL_KEEP_UNIT, texnum );
|
||||||
|
|
||||||
|
if( cols == tex->width && rows == tex->height )
|
||||||
|
pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, gl_format, GL_UNSIGNED_BYTE, raw );
|
||||||
|
else
|
||||||
|
{
|
||||||
tex->width = cols;
|
tex->width = cols;
|
||||||
tex->height = rows;
|
tex->height = rows;
|
||||||
|
pglTexImage2D( GL_TEXTURE_2D, 0, tex->format, cols, rows, 0, gl_format, GL_UNSIGNED_BYTE, raw );
|
||||||
|
}
|
||||||
|
|
||||||
pglTexImage2D( GL_TEXTURE_2D, 0, tex->format, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw );
|
|
||||||
GL_ApplyTextureParams( tex );
|
GL_ApplyTextureParams( tex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,19 +23,6 @@ static gl_texture_t gl_textures[MAX_TEXTURES];
|
|||||||
static gl_texture_t* gl_texturesHashTable[TEXTURES_HASH_SIZE];
|
static gl_texture_t* gl_texturesHashTable[TEXTURES_HASH_SIZE];
|
||||||
static uint gl_numTextures;
|
static uint gl_numTextures;
|
||||||
|
|
||||||
static byte dottexture[8][8] =
|
|
||||||
{
|
|
||||||
{0,1,1,0,0,0,0,0},
|
|
||||||
{1,1,1,1,0,0,0,0},
|
|
||||||
{1,1,1,1,0,0,0,0},
|
|
||||||
{0,1,1,0,0,0,0,0},
|
|
||||||
{0,0,0,0,0,0,0,0},
|
|
||||||
{0,0,0,0,0,0,0,0},
|
|
||||||
{0,0,0,0,0,0,0,0},
|
|
||||||
{0,0,0,0,0,0,0,0},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define IsLightMap( tex ) ( FBitSet(( tex )->flags, TF_ATLAS_PAGE ))
|
#define IsLightMap( tex ) ( FBitSet(( tex )->flags, TF_ATLAS_PAGE ))
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
@@ -1699,7 +1686,20 @@ int GL_CreateTexture( const char *name, int width, int height, const void *buffe
|
|||||||
r_empty.size *= 6;
|
r_empty.size *= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GL_LoadTextureFromBuffer( name, &r_empty, flags, update );
|
int texnum = GL_LoadTextureFromBuffer( name, &r_empty, flags, update );
|
||||||
|
|
||||||
|
if( !Q_strcmp( name, REF_DEFAULT_TEXTURE ))
|
||||||
|
tr.defaultTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_PARTICLE_TEXTURE ))
|
||||||
|
tr.particleTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_WHITE_TEXTURE ))
|
||||||
|
tr.whiteTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_GRAY_TEXTURE ))
|
||||||
|
tr.grayTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_BLACK_TEXTURE ))
|
||||||
|
tr.blackTexture = texnum;
|
||||||
|
|
||||||
|
return texnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1912,70 +1912,6 @@ void R_InitDlightTexture( void )
|
|||||||
tr.dlightTexture = GL_LoadTextureFromBuffer( "*dlight", &r_image, TF_NOMIPMAP|TF_CLAMP|TF_ATLAS_PAGE, update );
|
tr.dlightTexture = GL_LoadTextureFromBuffer( "*dlight", &r_image, TF_NOMIPMAP|TF_CLAMP|TF_ATLAS_PAGE, update );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
GL_CreateInternalTextures
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
static void GL_CreateInternalTextures( void )
|
|
||||||
{
|
|
||||||
int dx2, dy, d;
|
|
||||||
int x, y;
|
|
||||||
rgbdata_t *pic;
|
|
||||||
|
|
||||||
// emo-texture from quake1
|
|
||||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR );
|
|
||||||
|
|
||||||
for( y = 0; y < 16; y++ )
|
|
||||||
{
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
{
|
|
||||||
if(( y < 8 ) ^ ( x < 8 ))
|
|
||||||
((uint *)pic->buffer)[y*16+x] = 0xFFFF00FF;
|
|
||||||
else ((uint *)pic->buffer)[y*16+x] = 0xFF000000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// particle texture from quake1
|
|
||||||
pic = GL_FakeImage( 8, 8, 1, IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA );
|
|
||||||
|
|
||||||
for( x = 0; x < 8; x++ )
|
|
||||||
{
|
|
||||||
for( y = 0; y < 8; y++ )
|
|
||||||
{
|
|
||||||
if( dottexture[x][y] )
|
|
||||||
pic->buffer[( y * 8 + x ) * 4 + 3] = 255;
|
|
||||||
else pic->buffer[( y * 8 + x ) * 4 + 3] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.particleTexture = GL_LoadTextureInternal( REF_PARTICLE_TEXTURE, pic, TF_CLAMP );
|
|
||||||
|
|
||||||
// white texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer)[x] = 0xFFFFFFFF;
|
|
||||||
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// gray texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer)[x] = 0xFF7F7F7F;
|
|
||||||
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// black texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer)[x] = 0xFF000000;
|
|
||||||
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// cinematic dummy
|
|
||||||
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );
|
|
||||||
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP|TF_CLAMP );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_TextureList_f
|
R_TextureList_f
|
||||||
@@ -2208,7 +2144,6 @@ void R_InitImages( void )
|
|||||||
|
|
||||||
// validate cvars
|
// validate cvars
|
||||||
R_SetTextureParameters();
|
R_SetTextureParameters();
|
||||||
GL_CreateInternalTextures();
|
|
||||||
|
|
||||||
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
|
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,17 +70,9 @@ void VGL_ShimEndFrame( void );
|
|||||||
#define SHADE_LAMBERT 1.4953241
|
#define SHADE_LAMBERT 1.4953241
|
||||||
#define DEFAULT_ALPHATEST 0.0f
|
#define DEFAULT_ALPHATEST 0.0f
|
||||||
|
|
||||||
// refparams
|
|
||||||
#define RP_NONE 0
|
|
||||||
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
|
|
||||||
#define RP_OLDVIEWLEAF BIT( 1 )
|
|
||||||
#define RP_CLIPPLANE BIT( 2 )
|
|
||||||
|
|
||||||
#define RP_NONVIEWERREF (RP_ENVVIEW)
|
|
||||||
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
|
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
|
||||||
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
|
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
|
||||||
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
|
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
|
||||||
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
|
|
||||||
|
|
||||||
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
|
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
|
||||||
|
|
||||||
@@ -127,27 +119,16 @@ typedef struct gltexture_s
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int params; // rendering parameters
|
ref_viewpass_t rvp;
|
||||||
|
|
||||||
qboolean drawWorld; // ignore world for drawing PlayerModel
|
|
||||||
qboolean isSkyVisible; // sky is visible
|
|
||||||
qboolean onlyClientDraw; // disabled by client request
|
|
||||||
qboolean drawOrtho; // draw world as orthogonal projection
|
|
||||||
|
|
||||||
float fov_x, fov_y; // current view fov
|
|
||||||
|
|
||||||
cl_entity_t *currententity;
|
cl_entity_t *currententity;
|
||||||
model_t *currentmodel;
|
model_t *currentmodel;
|
||||||
cl_entity_t *currentbeam; // same as above but for beams
|
cl_entity_t *currentbeam; // same as above but for beams
|
||||||
|
|
||||||
int viewport[4];
|
|
||||||
gl_frustum_t frustum;
|
gl_frustum_t frustum;
|
||||||
|
|
||||||
mleaf_t *viewleaf;
|
mleaf_t *viewleaf;
|
||||||
mleaf_t *oldviewleaf;
|
mleaf_t *oldviewleaf;
|
||||||
vec3_t pvsorigin;
|
|
||||||
vec3_t vieworg; // locked vieworigin
|
|
||||||
vec3_t viewangles;
|
|
||||||
vec3_t vforward;
|
vec3_t vforward;
|
||||||
vec3_t vright;
|
vec3_t vright;
|
||||||
vec3_t vup;
|
vec3_t vup;
|
||||||
@@ -206,8 +187,6 @@ typedef struct
|
|||||||
int lightmapTextures[MAX_LIGHTMAPS];
|
int lightmapTextures[MAX_LIGHTMAPS];
|
||||||
int dlightTexture; // custom dlight texture
|
int dlightTexture; // custom dlight texture
|
||||||
int skyboxTextures[SKYBOX_MAX_SIDES]; // skybox sides
|
int skyboxTextures[SKYBOX_MAX_SIDES]; // skybox sides
|
||||||
int cinTexture; // cinematic texture
|
|
||||||
|
|
||||||
int skytexturenum; // this not a gl_texturenum!
|
int skytexturenum; // this not a gl_texturenum!
|
||||||
int skyboxbasenum; // start with 5800
|
int skyboxbasenum; // start with 5800
|
||||||
|
|
||||||
@@ -315,7 +294,6 @@ void SCR_TimeRefresh_f( void );
|
|||||||
// gl_beams.c
|
// gl_beams.c
|
||||||
//
|
//
|
||||||
void CL_DrawBeams( int fTrans, BEAM *active_beams );
|
void CL_DrawBeams( int fTrans, BEAM *active_beams );
|
||||||
qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_cull.c
|
// gl_cull.c
|
||||||
@@ -338,7 +316,7 @@ void R_ClearDecals( void );
|
|||||||
// gl_draw.c
|
// gl_draw.c
|
||||||
//
|
//
|
||||||
void R_Set2DMode( qboolean enable );
|
void R_Set2DMode( qboolean enable );
|
||||||
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data );
|
void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt );
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_image.c
|
// gl_image.c
|
||||||
@@ -388,10 +366,6 @@ void R_DrawFog( void );
|
|||||||
int CL_FxBlend( cl_entity_t *e );
|
int CL_FxBlend( cl_entity_t *e );
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_rmisc.c
|
|
||||||
//
|
|
||||||
void R_NewMap( void );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_rsurf.c
|
// gl_rsurf.c
|
||||||
//
|
//
|
||||||
@@ -435,11 +409,11 @@ struct mstudiotex_s *R_StudioGetTexture( cl_entity_t *e );
|
|||||||
int R_GetEntityRenderMode( cl_entity_t *ent );
|
int R_GetEntityRenderMode( cl_entity_t *ent );
|
||||||
void R_DrawStudioModel( cl_entity_t *e );
|
void R_DrawStudioModel( cl_entity_t *e );
|
||||||
player_info_t *pfnPlayerInfo( int index );
|
player_info_t *pfnPlayerInfo( int index );
|
||||||
void R_GatherPlayerLight( void );
|
|
||||||
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
||||||
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
||||||
void R_StudioResetPlayerModels( void );
|
void R_StudioResetPlayerModels( void );
|
||||||
void CL_InitStudioAPI( void );
|
qboolean R_StudioFillAPI( struct engine_studio_api_s *api, struct r_studio_interface_s *pDefaultDraw );
|
||||||
|
void R_StudioSetDrawInterface( struct r_studio_interface_s *pDraw );
|
||||||
void Mod_StudioLoadTextures( model_t *mod, void *data );
|
void Mod_StudioLoadTextures( model_t *mod, void *data );
|
||||||
void Mod_StudioUnloadTextures( void *data );
|
void Mod_StudioUnloadTextures( void *data );
|
||||||
|
|
||||||
@@ -482,7 +456,6 @@ void R_RenderFrame( const struct ref_viewpass_s *vp );
|
|||||||
void R_EndFrame( void );
|
void R_EndFrame( void );
|
||||||
void R_ClearScene( void );
|
void R_ClearScene( void );
|
||||||
void R_GetTextureParms( int *w, int *h, int texnum );
|
void R_GetTextureParms( int *w, int *h, int texnum );
|
||||||
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
|
|
||||||
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
||||||
qboolean R_SpeedsMessage( char *out, size_t size );
|
qboolean R_SpeedsMessage( char *out, size_t size );
|
||||||
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ static int R_TransEntityCompare( const void *a, const void *b )
|
|||||||
{
|
{
|
||||||
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
|
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
|
||||||
VectorAdd( ent1->origin, org, org );
|
VectorAdd( ent1->origin, org, org );
|
||||||
VectorSubtract( RI.vieworg, org, vecLen );
|
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
|
||||||
dist1 = DotProduct( vecLen, vecLen );
|
dist1 = DotProduct( vecLen, vecLen );
|
||||||
}
|
}
|
||||||
else dist1 = 1000000000;
|
else dist1 = 1000000000;
|
||||||
@@ -110,7 +110,7 @@ static int R_TransEntityCompare( const void *a, const void *b )
|
|||||||
{
|
{
|
||||||
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
|
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
|
||||||
VectorAdd( ent2->origin, org, org );
|
VectorAdd( ent2->origin, org, org );
|
||||||
VectorSubtract( RI.vieworg, org, vecLen );
|
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
|
||||||
dist2 = DotProduct( vecLen, vecLen );
|
dist2 = DotProduct( vecLen, vecLen );
|
||||||
}
|
}
|
||||||
else dist2 = 1000000000;
|
else dist2 = 1000000000;
|
||||||
@@ -317,7 +317,7 @@ static void R_Clear( int bitMask )
|
|||||||
pglClear( bits );
|
pglClear( bits );
|
||||||
|
|
||||||
// change ordering for overview
|
// change ordering for overview
|
||||||
if( RI.drawOrtho )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
|
||||||
{
|
{
|
||||||
gldepthmin = 1.0f;
|
gldepthmin = 1.0f;
|
||||||
gldepthmax = 0.0f;
|
gldepthmax = 0.0f;
|
||||||
@@ -340,7 +340,7 @@ R_GetFarClip
|
|||||||
*/
|
*/
|
||||||
static float R_GetFarClip( void )
|
static float R_GetFarClip( void )
|
||||||
{
|
{
|
||||||
if( WORLDMODEL && RI.drawWorld )
|
if( WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return tr.movevars->zmax * 1.73f;
|
return tr.movevars->zmax * 1.73f;
|
||||||
return 2048.0f;
|
return 2048.0f;
|
||||||
}
|
}
|
||||||
@@ -352,28 +352,26 @@ R_SetupFrustum
|
|||||||
*/
|
*/
|
||||||
void R_SetupFrustum( void )
|
void R_SetupFrustum( void )
|
||||||
{
|
{
|
||||||
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
|
||||||
|
|
||||||
if( RP_NORMALPASS() && FBitSet( gp_host->features, ENGINE_QUAKE_COMPATIBLE ) && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ))
|
|
||||||
{
|
|
||||||
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
|
|
||||||
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gp_cl->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// build the transformation matrix for the given view angles
|
// build the transformation matrix for the given view angles
|
||||||
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
|
AngleVectors( RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup );
|
||||||
|
|
||||||
if( !r_lockfrustum.value )
|
if( !r_lockfrustum.value )
|
||||||
{
|
{
|
||||||
VectorCopy( RI.vieworg, RI.cullorigin );
|
VectorCopy( RI.rvp.vieworigin, RI.cullorigin );
|
||||||
VectorCopy( RI.vforward, RI.cull_vforward );
|
VectorCopy( RI.vforward, RI.cull_vforward );
|
||||||
VectorCopy( RI.vright, RI.cull_vright );
|
VectorCopy( RI.vright, RI.cull_vright );
|
||||||
VectorCopy( RI.vup, RI.cull_vup );
|
VectorCopy( RI.vup, RI.cull_vup );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RI.drawOrtho )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
|
||||||
|
{
|
||||||
|
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
||||||
GL_FrustumInitOrtho( &RI.frustum, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
|
GL_FrustumInitOrtho( &RI.frustum, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
|
||||||
else GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.fov_x, RI.fov_y ); // NOTE: we ignore nearplane here (mirrors only)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.rvp.fov_x, RI.rvp.fov_y ); // NOTE: we ignore nearplane here (mirrors only)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -385,7 +383,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
|
|||||||
{
|
{
|
||||||
GLfloat xMin, xMax, yMin, yMax, zNear, zFar;
|
GLfloat xMin, xMax, yMin, yMax, zNear, zFar;
|
||||||
|
|
||||||
if( RI.drawOrtho )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
|
||||||
{
|
{
|
||||||
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
||||||
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
|
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
|
||||||
@@ -397,10 +395,10 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
|
|||||||
zNear = 4.0f;
|
zNear = 4.0f;
|
||||||
zFar = Q_max( 256.0f, RI.farClip );
|
zFar = Q_max( 256.0f, RI.farClip );
|
||||||
|
|
||||||
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
|
yMax = zNear * tan( RI.rvp.fov_y * M_PI_F / 360.0f );
|
||||||
yMin = -yMax;
|
yMin = -yMax;
|
||||||
|
|
||||||
xMax = zNear * tan( RI.fov_x * M_PI_F / 360.0f );
|
xMax = zNear * tan( RI.rvp.fov_x * M_PI_F / 360.0f );
|
||||||
xMin = -xMax;
|
xMin = -xMax;
|
||||||
|
|
||||||
if( tr.rotation & 1 )
|
if( tr.rotation & 1 )
|
||||||
@@ -423,17 +421,17 @@ static void R_SetupModelviewMatrix( matrix4x4 m )
|
|||||||
Matrix4x4_CreateModelview( m );
|
Matrix4x4_CreateModelview( m );
|
||||||
if( tr.rotation & 1 )
|
if( tr.rotation & 1 )
|
||||||
{
|
{
|
||||||
Matrix4x4_ConcatRotate( m, anglemod( -RI.viewangles[2] + 90 ), 1, 0, 0 );
|
Matrix4x4_ConcatRotate( m, anglemod( -RI.rvp.viewangles[2] + 90 ), 1, 0, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[2], 1, 0, 0 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[2], 1, 0, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
|
||||||
}
|
}
|
||||||
Matrix4x4_ConcatTranslate( m, -RI.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
|
Matrix4x4_ConcatTranslate( m, -RI.rvp.vieworigin[0], -RI.rvp.vieworigin[1], -RI.rvp.vieworigin[2] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -513,7 +511,7 @@ R_FindViewLeaf
|
|||||||
void R_FindViewLeaf( void )
|
void R_FindViewLeaf( void )
|
||||||
{
|
{
|
||||||
RI.oldviewleaf = RI.viewleaf;
|
RI.oldviewleaf = RI.viewleaf;
|
||||||
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
|
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes, WORLDMODEL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -524,7 +522,7 @@ R_SetupFrame
|
|||||||
static void R_SetupFrame( void )
|
static void R_SetupFrame( void )
|
||||||
{
|
{
|
||||||
// setup viewplane dist
|
// setup viewplane dist
|
||||||
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
|
RI.viewplanedist = DotProduct( RI.rvp.vieworigin, RI.vforward );
|
||||||
|
|
||||||
// NOTE: this request is the fps-killer on some NVidia drivers
|
// NOTE: this request is the fps-killer on some NVidia drivers
|
||||||
glState.isFogEnabled = pglIsEnabled( GL_FOG );
|
glState.isFogEnabled = pglIsEnabled( GL_FOG );
|
||||||
@@ -536,11 +534,8 @@ static void R_SetupFrame( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// current viewleaf
|
// current viewleaf
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
|
||||||
RI.isSkyVisible = false; // unknown at this moment
|
|
||||||
R_FindViewLeaf();
|
R_FindViewLeaf();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -557,15 +552,15 @@ void R_SetupGL( qboolean set_gl_state )
|
|||||||
|
|
||||||
if( !set_gl_state ) return;
|
if( !set_gl_state ) return;
|
||||||
|
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
int x, x2, y, y2;
|
int x, x2, y, y2;
|
||||||
|
|
||||||
// set up viewport (main, playersetup)
|
// set up viewport (main, playersetup)
|
||||||
x = floor( RI.viewport[0] * gpGlobals->width / gpGlobals->width );
|
x = floor( RI.rvp.viewport[0] * gpGlobals->width / gpGlobals->width );
|
||||||
x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * gpGlobals->width / gpGlobals->width );
|
x2 = ceil(( RI.rvp.viewport[0] + RI.rvp.viewport[2] ) * gpGlobals->width / gpGlobals->width );
|
||||||
y = floor( gpGlobals->height - RI.viewport[1] * gpGlobals->height / gpGlobals->height );
|
y = floor( gpGlobals->height - RI.rvp.viewport[1] * gpGlobals->height / gpGlobals->height );
|
||||||
y2 = ceil( gpGlobals->height - ( RI.viewport[1] + RI.viewport[3] ) * gpGlobals->height / gpGlobals->height );
|
y2 = ceil( gpGlobals->height - ( RI.rvp.viewport[1] + RI.rvp.viewport[3] ) * gpGlobals->height / gpGlobals->height );
|
||||||
|
|
||||||
if( tr.rotation & 1 )
|
if( tr.rotation & 1 )
|
||||||
pglViewport( y2, x, y - y2, x2 - x );
|
pglViewport( y2, x, y - y2, x2 - x );
|
||||||
@@ -574,7 +569,7 @@ void R_SetupGL( qboolean set_gl_state )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// envpass, mirrorpass
|
// envpass, mirrorpass
|
||||||
pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] );
|
pglViewport( RI.rvp.viewport[0], RI.rvp.viewport[1], RI.rvp.viewport[2], RI.rvp.viewport[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
pglMatrixMode( GL_PROJECTION );
|
pglMatrixMode( GL_PROJECTION );
|
||||||
@@ -583,20 +578,6 @@ void R_SetupGL( qboolean set_gl_state )
|
|||||||
pglMatrixMode( GL_MODELVIEW );
|
pglMatrixMode( GL_MODELVIEW );
|
||||||
GL_LoadMatrix( RI.worldviewMatrix );
|
GL_LoadMatrix( RI.worldviewMatrix );
|
||||||
|
|
||||||
if( FBitSet( RI.params, RP_CLIPPLANE ))
|
|
||||||
{
|
|
||||||
GLdouble clip[4];
|
|
||||||
mplane_t *p = &RI.clipPlane;
|
|
||||||
|
|
||||||
clip[0] = p->normal[0];
|
|
||||||
clip[1] = p->normal[1];
|
|
||||||
clip[2] = p->normal[2];
|
|
||||||
clip[3] = -p->dist;
|
|
||||||
|
|
||||||
pglClipPlane( GL_CLIP_PLANE0, clip );
|
|
||||||
pglEnable( GL_CLIP_PLANE0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
GL_Cull( GL_FRONT );
|
GL_Cull( GL_FRONT );
|
||||||
|
|
||||||
pglDisable( GL_BLEND );
|
pglDisable( GL_BLEND );
|
||||||
@@ -604,17 +585,6 @@ void R_SetupGL( qboolean set_gl_state )
|
|||||||
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
R_EndGL
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
static void R_EndGL( void )
|
|
||||||
{
|
|
||||||
if( RI.params & RP_CLIPPLANE )
|
|
||||||
pglDisable( GL_CLIP_PLANE0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_RecursiveFindWaterTexture
|
R_RecursiveFindWaterTexture
|
||||||
@@ -731,7 +701,7 @@ static void R_CheckFog( void )
|
|||||||
|
|
||||||
RI.fogEnabled = false;
|
RI.fogEnabled = false;
|
||||||
|
|
||||||
if( RI.onlyClientDraw || ENGINE_GET_PARM( PARM_WATER_LEVEL ) < 3 || !RI.drawWorld || !RI.viewleaf )
|
if( FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ) || ENGINE_GET_PARM( PARM_WATER_LEVEL ) < 3 || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || !RI.viewleaf )
|
||||||
{
|
{
|
||||||
if( RI.cached_waterlevel == 3 )
|
if( RI.cached_waterlevel == 3 )
|
||||||
{
|
{
|
||||||
@@ -747,7 +717,7 @@ static void R_CheckFog( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent = gEngfuncs.CL_GetWaterEntity( RI.vieworg );
|
ent = gEngfuncs.CL_GetWaterEntity( RI.rvp.vieworigin );
|
||||||
if( ent && ent->model && ent->model->type == mod_brush && ent->curstate.skin < 0 )
|
if( ent && ent->model && ent->model->type == mod_brush && ent->curstate.skin < 0 )
|
||||||
cnt = ent->curstate.skin;
|
cnt = ent->curstate.skin;
|
||||||
else cnt = RI.viewleaf->contents;
|
else cnt = RI.viewleaf->contents;
|
||||||
@@ -853,7 +823,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
// first draw solid entities
|
// first draw solid entities
|
||||||
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->solid_entities[i];
|
RI.currententity = tr.draw_list->solid_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -885,7 +855,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
// draw sprites seperately, because of alpha blending
|
// draw sprites seperately, because of alpha blending
|
||||||
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->solid_entities[i];
|
RI.currententity = tr.draw_list->solid_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -903,20 +873,20 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
{
|
{
|
||||||
gEngfuncs.CL_DrawEFX( tr.frametime, false );
|
gEngfuncs.CL_DrawEFX( tr.frametime, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
gEngfuncs.pfnDrawNormalTriangles();
|
gEngfuncs.pfnDrawNormalTriangles();
|
||||||
|
|
||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
// then draw translucent entities
|
// then draw translucent entities
|
||||||
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->trans_entities[i];
|
RI.currententity = tr.draw_list->trans_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -952,7 +922,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||||
gEngfuncs.pfnDrawTransparentTriangles ();
|
gEngfuncs.pfnDrawTransparentTriangles ();
|
||||||
@@ -960,7 +930,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
GL_CheckForErrors();
|
GL_CheckForErrors();
|
||||||
|
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
{
|
{
|
||||||
R_AllowFog( false );
|
R_AllowFog( false );
|
||||||
gEngfuncs.CL_DrawEFX( tr.frametime, true );
|
gEngfuncs.CL_DrawEFX( tr.frametime, true );
|
||||||
@@ -971,7 +941,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
pglDisable( GL_BLEND ); // Trinity Render issues
|
pglDisable( GL_BLEND ); // Trinity Render issues
|
||||||
|
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
R_DrawViewModel();
|
R_DrawViewModel();
|
||||||
gEngfuncs.CL_ExtraUpdate();
|
gEngfuncs.CL_ExtraUpdate();
|
||||||
|
|
||||||
@@ -987,11 +957,11 @@ R_SetupRefParams must be called right before
|
|||||||
*/
|
*/
|
||||||
void R_RenderScene( void )
|
void R_RenderScene( void )
|
||||||
{
|
{
|
||||||
if( !WORLDMODEL && RI.drawWorld )
|
if( !WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
|
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
|
||||||
|
|
||||||
// frametime is valid only for normal pass
|
// frametime is valid only for normal pass
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
tr.frametime = gp_cl->time - gp_cl->oldtime;
|
tr.frametime = gp_cl->time - gp_cl->oldtime;
|
||||||
else tr.frametime = 0.0;
|
else tr.frametime = 0.0;
|
||||||
|
|
||||||
@@ -1007,7 +977,7 @@ void R_RenderScene( void )
|
|||||||
|
|
||||||
R_MarkLeaves();
|
R_MarkLeaves();
|
||||||
R_DrawFog ();
|
R_DrawFog ();
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
R_AnimateRipples();
|
R_AnimateRipples();
|
||||||
|
|
||||||
R_CheckGLFog();
|
R_CheckGLFog();
|
||||||
@@ -1019,8 +989,6 @@ void R_RenderScene( void )
|
|||||||
R_DrawEntitiesOnList();
|
R_DrawEntitiesOnList();
|
||||||
|
|
||||||
R_DrawWaterSurfaces();
|
R_DrawWaterSurfaces();
|
||||||
|
|
||||||
R_EndGL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_GammaChanged( qboolean do_reset_gamma )
|
void R_GammaChanged( qboolean do_reset_gamma )
|
||||||
@@ -1109,28 +1077,9 @@ set initial params for renderer
|
|||||||
*/
|
*/
|
||||||
void R_SetupRefParams( const ref_viewpass_t *rvp )
|
void R_SetupRefParams( const ref_viewpass_t *rvp )
|
||||||
{
|
{
|
||||||
RI.params = RP_NONE;
|
RI.rvp = *rvp;
|
||||||
RI.drawWorld = FBitSet( rvp->flags, RF_DRAW_WORLD );
|
|
||||||
RI.onlyClientDraw = FBitSet( rvp->flags, RF_ONLY_CLIENTDRAW );
|
|
||||||
RI.farClip = 0;
|
RI.farClip = 0;
|
||||||
|
|
||||||
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
|
|
||||||
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
|
|
||||||
else RI.drawOrtho = false;
|
|
||||||
|
|
||||||
// setup viewport
|
|
||||||
RI.viewport[0] = rvp->viewport[0];
|
|
||||||
RI.viewport[1] = rvp->viewport[1];
|
|
||||||
RI.viewport[2] = rvp->viewport[2];
|
|
||||||
RI.viewport[3] = rvp->viewport[3];
|
|
||||||
|
|
||||||
// calc FOV
|
|
||||||
RI.fov_x = rvp->fov_x;
|
|
||||||
RI.fov_y = rvp->fov_y;
|
|
||||||
|
|
||||||
VectorCopy( rvp->vieworigin, RI.vieworg );
|
|
||||||
VectorCopy( rvp->viewangles, RI.viewangles );
|
|
||||||
VectorCopy( rvp->vieworigin, RI.pvsorigin );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1146,7 +1095,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
|
|||||||
// setup the initial render params
|
// setup the initial render params
|
||||||
R_SetupRefParams( rvp );
|
R_SetupRefParams( rvp );
|
||||||
|
|
||||||
if( gl_finish.value && RI.drawWorld )
|
if( gl_finish.value && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
pglFinish();
|
pglFinish();
|
||||||
|
|
||||||
// completely override rendering
|
// completely override rendering
|
||||||
@@ -1156,7 +1105,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
|
|||||||
|
|
||||||
if( gEngfuncs.drawFuncs->GL_RenderFrame( rvp ))
|
if( gEngfuncs.drawFuncs->GL_RenderFrame( rvp ))
|
||||||
{
|
{
|
||||||
R_GatherPlayerLight();
|
R_GatherPlayerLight( tr.viewent );
|
||||||
tr.realframecount++;
|
tr.realframecount++;
|
||||||
tr.fResetVis = true;
|
tr.fResetVis = true;
|
||||||
return;
|
return;
|
||||||
@@ -1164,7 +1113,7 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
|
|||||||
}
|
}
|
||||||
|
|
||||||
tr.fCustomRendering = false;
|
tr.fCustomRendering = false;
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
R_RunViewmodelEvents();
|
R_RunViewmodelEvents();
|
||||||
|
|
||||||
tr.realframecount++; // right called after viewmodel events
|
tr.realframecount++; // right called after viewmodel events
|
||||||
@@ -1246,7 +1195,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
|
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
|
||||||
break;
|
break;
|
||||||
case kRenderFxFadeSlow:
|
case kRenderFxFadeSlow:
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
if( e->curstate.renderamt > 0 )
|
if( e->curstate.renderamt > 0 )
|
||||||
e->curstate.renderamt -= 1;
|
e->curstate.renderamt -= 1;
|
||||||
@@ -1255,7 +1204,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxFadeFast:
|
case kRenderFxFadeFast:
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
if( e->curstate.renderamt > 3 )
|
if( e->curstate.renderamt > 3 )
|
||||||
e->curstate.renderamt -= 4;
|
e->curstate.renderamt -= 4;
|
||||||
@@ -1264,7 +1213,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxSolidSlow:
|
case kRenderFxSolidSlow:
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
if( e->curstate.renderamt < 255 )
|
if( e->curstate.renderamt < 255 )
|
||||||
e->curstate.renderamt += 1;
|
e->curstate.renderamt += 1;
|
||||||
@@ -1273,7 +1222,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxSolidFast:
|
case kRenderFxSolidFast:
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
if( e->curstate.renderamt < 252 )
|
if( e->curstate.renderamt < 252 )
|
||||||
e->curstate.renderamt += 4;
|
e->curstate.renderamt += 4;
|
||||||
@@ -1309,7 +1258,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
case kRenderFxHologram:
|
case kRenderFxHologram:
|
||||||
case kRenderFxDistort:
|
case kRenderFxDistort:
|
||||||
VectorCopy( e->origin, tmp );
|
VectorCopy( e->origin, tmp );
|
||||||
VectorSubtract( tmp, RI.vieworg, tmp );
|
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
|
||||||
dist = DotProduct( tmp, RI.vforward );
|
dist = DotProduct( tmp, RI.vforward );
|
||||||
|
|
||||||
// turn off distance fade
|
// turn off distance fade
|
||||||
|
|||||||
@@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
gl_rmisc.c - renderer misceallaneous
|
|
||||||
Copyright (C) 2010 Uncle Mike
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gl_local.h"
|
|
||||||
#include "shake.h"
|
|
||||||
#include "screenfade.h"
|
|
||||||
#include "cdll_int.h"
|
|
||||||
|
|
||||||
static void R_ParseDetailTextures( const char *filename )
|
|
||||||
{
|
|
||||||
byte *afile;
|
|
||||||
char *pfile;
|
|
||||||
string token, texname;
|
|
||||||
string detail_texname;
|
|
||||||
string detail_path;
|
|
||||||
float xScale, yScale;
|
|
||||||
texture_t *tex;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
afile = gEngfuncs.fsapi->LoadFile( filename, NULL, false );
|
|
||||||
if( !afile ) return;
|
|
||||||
|
|
||||||
pfile = (char *)afile;
|
|
||||||
|
|
||||||
// format: 'texturename' 'detailtexture' 'xScale' 'yScale'
|
|
||||||
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
|
||||||
{
|
|
||||||
texname[0] = '\0';
|
|
||||||
detail_texname[0] = '\0';
|
|
||||||
|
|
||||||
// read texname
|
|
||||||
if( token[0] == '{' )
|
|
||||||
{
|
|
||||||
// NOTE: COM_ParseFile handled some symbols seperately
|
|
||||||
// this code will be fix it
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
|
||||||
Q_snprintf( texname, sizeof( texname ), "{%s", token );
|
|
||||||
}
|
|
||||||
else Q_strncpy( texname, token, sizeof( texname ));
|
|
||||||
|
|
||||||
// read detailtexture name
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
|
||||||
Q_strncpy( detail_texname, token, sizeof( detail_texname ));
|
|
||||||
|
|
||||||
// trying the scales or '{'
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
|
||||||
|
|
||||||
// read second part of detailtexture name
|
|
||||||
if( token[0] == '{' )
|
|
||||||
{
|
|
||||||
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token )); // read scales
|
|
||||||
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token )); // parse scales
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_snprintf( detail_path, sizeof( detail_path ), "gfx/%s", detail_texname );
|
|
||||||
|
|
||||||
// read scales
|
|
||||||
xScale = Q_atof( token );
|
|
||||||
|
|
||||||
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
|
||||||
yScale = Q_atof( token );
|
|
||||||
|
|
||||||
if( xScale <= 0.0f || yScale <= 0.0f )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// search for existing texture and uploading detail texture
|
|
||||||
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
|
||||||
{
|
|
||||||
tex = WORLDMODEL->textures[i];
|
|
||||||
|
|
||||||
if( Q_stricmp( tex->name, texname ))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR|TF_NOFLIP_TGA );
|
|
||||||
|
|
||||||
// texture is loaded
|
|
||||||
if( tex->dt_texturenum )
|
|
||||||
{
|
|
||||||
gl_texture_t *glt;
|
|
||||||
|
|
||||||
glt = R_GetTexture( tex->gl_texturenum );
|
|
||||||
glt->xscale = xScale;
|
|
||||||
glt->yscale = yScale;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Mem_Free( afile );
|
|
||||||
}
|
|
||||||
|
|
||||||
void R_NewMap( void )
|
|
||||||
{
|
|
||||||
texture_t *tx;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
tr.worldmodel = gp_cl->models[1];
|
|
||||||
|
|
||||||
R_ClearDecals(); // clear all level decals
|
|
||||||
|
|
||||||
R_StudioResetPlayerModels();
|
|
||||||
|
|
||||||
// upload detailtextures
|
|
||||||
if( r_detailtextures.value )
|
|
||||||
{
|
|
||||||
string mapname, filepath;
|
|
||||||
|
|
||||||
Q_strncpy( mapname, WORLDMODEL->name, sizeof( mapname ));
|
|
||||||
COM_StripExtension( mapname );
|
|
||||||
Q_snprintf( filepath, sizeof( filepath ), "%s_detail.txt", mapname );
|
|
||||||
|
|
||||||
R_ParseDetailTextures( filepath );
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear out efrags in case the level hasn't been reloaded
|
|
||||||
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
|
||||||
WORLDMODEL->leafs[i+1].efrags = NULL;
|
|
||||||
|
|
||||||
glState.isFogEnabled = false;
|
|
||||||
tr.skytexturenum = -1;
|
|
||||||
pglDisable( GL_FOG );
|
|
||||||
|
|
||||||
// clearing texture chains
|
|
||||||
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
|
||||||
{
|
|
||||||
if( !WORLDMODEL->textures[i] )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
tx = WORLDMODEL->textures[i];
|
|
||||||
|
|
||||||
if( !Q_strncmp( tx->name, "sky", 3 ) && tx->width == ( tx->height * 2 ))
|
|
||||||
tr.skytexturenum = i;
|
|
||||||
|
|
||||||
tx->texturechain = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL_BuildLightmaps ();
|
|
||||||
|
|
||||||
R_ClearVBO();
|
|
||||||
if( R_HasEnabledVBO( ))
|
|
||||||
R_GenerateVBO();
|
|
||||||
R_ResetRipples();
|
|
||||||
|
|
||||||
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
|
||||||
gEngfuncs.drawFuncs->R_NewMap();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -73,9 +73,9 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float
|
|||||||
size = partsize; // get initial size of particle
|
size = partsize; // get initial size of particle
|
||||||
|
|
||||||
// scale up to keep particles from disappearing
|
// scale up to keep particles from disappearing
|
||||||
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
|
size += (p->org[0] - RI.rvp.vieworigin[0]) * RI.cull_vforward[0];
|
||||||
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
|
size += (p->org[1] - RI.rvp.vieworigin[1]) * RI.cull_vforward[1];
|
||||||
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
|
size += (p->org[2] - RI.rvp.vieworigin[2]) * RI.cull_vforward[2];
|
||||||
|
|
||||||
if( size < 20.0f ) size = partsize;
|
if( size < 20.0f ) size = partsize;
|
||||||
else size = partsize + size * 0.002f;
|
else size = partsize + size * 0.002f;
|
||||||
|
|||||||
@@ -956,7 +956,7 @@ static void EmitWaterPolys( msurface_t *warp, qboolean reverse, qboolean ripples
|
|||||||
if( !warp->polys ) return;
|
if( !warp->polys ) return;
|
||||||
|
|
||||||
// set the current waveheight
|
// set the current waveheight
|
||||||
if( warp->polys->verts[0][2] >= RI.vieworg[2] )
|
if( warp->polys->verts[0][2] >= RI.rvp.vieworigin[2] )
|
||||||
waveHeight = -RI.currententity->curstate.scale;
|
waveHeight = -RI.currententity->curstate.scale;
|
||||||
else waveHeight = RI.currententity->curstate.scale;
|
else waveHeight = RI.currententity->curstate.scale;
|
||||||
|
|
||||||
@@ -1610,7 +1610,7 @@ void R_DrawWaterSurfaces( void )
|
|||||||
msurface_t *s;
|
msurface_t *s;
|
||||||
texture_t *t;
|
texture_t *t;
|
||||||
|
|
||||||
if( !RI.drawWorld || RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// non-transparent water is already drawed
|
// non-transparent water is already drawed
|
||||||
@@ -1792,7 +1792,8 @@ void R_DrawBrushModel( cl_entity_t *e )
|
|||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
qboolean allow_vbo = R_HasEnabledVBO();
|
qboolean allow_vbo = R_HasEnabledVBO();
|
||||||
|
|
||||||
if( !RI.drawWorld ) return;
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
|
return;
|
||||||
|
|
||||||
model_t *clmodel = e->model;
|
model_t *clmodel = e->model;
|
||||||
|
|
||||||
@@ -3683,7 +3684,7 @@ void R_DrawWorld( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
if( !RI.drawWorld || RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VectorCopy( RI.cullorigin, tr.modelorg );
|
VectorCopy( RI.cullorigin, tr.modelorg );
|
||||||
@@ -3699,7 +3700,7 @@ void R_DrawWorld( void )
|
|||||||
R_ClearSkyBox ();
|
R_ClearSkyBox ();
|
||||||
|
|
||||||
start = gEngfuncs.pfnTime();
|
start = gEngfuncs.pfnTime();
|
||||||
if( RI.drawOrtho )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ))
|
||||||
R_DrawWorldTopView( WORLDMODEL->nodes, RI.frustum.clipFlags );
|
R_DrawWorldTopView( WORLDMODEL->nodes, RI.frustum.clipFlags );
|
||||||
else R_RecursiveWorldNode( WORLDMODEL->nodes, RI.frustum.clipFlags );
|
else R_RecursiveWorldNode( WORLDMODEL->nodes, RI.frustum.clipFlags );
|
||||||
end = gEngfuncs.pfnTime();
|
end = gEngfuncs.pfnTime();
|
||||||
@@ -3748,7 +3749,8 @@ void R_MarkLeaves( void )
|
|||||||
vec3_t test;
|
vec3_t test;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( !RI.drawWorld ) return;
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
|
return;
|
||||||
|
|
||||||
if( FBitSet( r_novis.flags, FCVAR_CHANGED ) || tr.fResetVis )
|
if( FBitSet( r_novis.flags, FCVAR_CHANGED ) || tr.fResetVis )
|
||||||
{
|
{
|
||||||
@@ -3758,17 +3760,17 @@ void R_MarkLeaves( void )
|
|||||||
RI.viewleaf = NULL;
|
RI.viewleaf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorCopy( RI.pvsorigin, test );
|
VectorCopy( RI.rvp.vieworigin, test );
|
||||||
|
|
||||||
if( RI.viewleaf != NULL )
|
if( RI.viewleaf != NULL )
|
||||||
{
|
{
|
||||||
// merge two leafs that can be a crossed-line contents
|
// merge two leafs that can be a crossed-line contents
|
||||||
if( RI.viewleaf->contents == CONTENTS_EMPTY )
|
if( RI.viewleaf->contents == CONTENTS_EMPTY )
|
||||||
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
|
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] - 16.0f );
|
||||||
else
|
else
|
||||||
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
|
VectorSet( test, RI.rvp.vieworigin[0], RI.rvp.vieworigin[1], RI.rvp.vieworigin[2] + 16.0f );
|
||||||
|
|
||||||
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
|
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes, WORLDMODEL );
|
||||||
|
|
||||||
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
|
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
|
||||||
force = true;
|
force = true;
|
||||||
@@ -3784,10 +3786,10 @@ void R_MarkLeaves( void )
|
|||||||
RI.oldviewleaf = RI.viewleaf;
|
RI.oldviewleaf = RI.viewleaf;
|
||||||
tr.visframecount++;
|
tr.visframecount++;
|
||||||
|
|
||||||
if( r_novis.value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
|
if( r_novis.value || FBitSet( RI.rvp.flags, RF_DRAW_OVERVIEW ) || !RI.viewleaf || !WORLDMODEL->visdata )
|
||||||
novis = true;
|
novis = true;
|
||||||
|
|
||||||
gEngfuncs.R_FatPVS( RI.pvsorigin, r_pvs_radius->value, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
|
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, novis );
|
||||||
if( force && !novis )
|
if( force && !novis )
|
||||||
gEngfuncs.R_FatPVS( test, r_pvs_radius->value, RI.visbytes, true, novis );
|
gEngfuncs.R_FatPVS( test, r_pvs_radius->value, RI.visbytes, true, novis );
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
|
|||||||
{
|
{
|
||||||
// e.g. doom-style sprite monsters
|
// e.g. doom-style sprite monsters
|
||||||
float yaw = ent->angles[YAW];
|
float yaw = ent->angles[YAW];
|
||||||
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
|
int angleframe = (int)(Q_rint(( RI.rvp.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
|
||||||
|
|
||||||
if( m_fDoInterp )
|
if( m_fDoInterp )
|
||||||
{
|
{
|
||||||
@@ -233,12 +233,12 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
|
|||||||
vec3_t glowDist;
|
vec3_t glowDist;
|
||||||
pmtrace_t *tr;
|
pmtrace_t *tr;
|
||||||
|
|
||||||
VectorSubtract( origin, RI.vieworg, glowDist );
|
VectorSubtract( origin, RI.rvp.vieworigin, glowDist );
|
||||||
dist = VectorLength( glowDist );
|
dist = VectorLength( glowDist );
|
||||||
|
|
||||||
if( RP_NORMALPASS( ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
{
|
{
|
||||||
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
|
tr = gEngfuncs.EV_VisTraceLine( RI.rvp.vieworigin, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
|
||||||
|
|
||||||
if(( 1.0f - tr->fraction ) * dist > 8.0f )
|
if(( 1.0f - tr->fraction ) * dist > 8.0f )
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@@ -270,9 +270,9 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
|
|||||||
|
|
||||||
TriWorldToScreen( origin, v );
|
TriWorldToScreen( origin, v );
|
||||||
|
|
||||||
if( v[0] < RI.viewport[0] || v[0] > RI.viewport[0] + RI.viewport[2] )
|
if( v[0] < RI.rvp.viewport[0] || v[0] > RI.rvp.viewport[0] + RI.rvp.viewport[2] )
|
||||||
return true; // do scissor
|
return true; // do scissor
|
||||||
if( v[1] < RI.viewport[1] || v[1] > RI.viewport[1] + RI.viewport[3] )
|
if( v[1] < RI.rvp.viewport[1] || v[1] > RI.rvp.viewport[1] + RI.rvp.viewport[3] )
|
||||||
return true; // do scissor
|
return true; // do scissor
|
||||||
|
|
||||||
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
|
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
|
||||||
@@ -386,7 +386,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||||||
vec3_t v_forward, v_right, v_up;
|
vec3_t v_forward, v_right, v_up;
|
||||||
vec3_t origin, color, color2 = { 0.0f };
|
vec3_t origin, color, color2 = { 0.0f };
|
||||||
|
|
||||||
if( RI.params & RP_ENVVIEW )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
model = e->model;
|
model = e->model;
|
||||||
@@ -495,7 +495,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||||||
VectorSubtract( origin, v_forward, origin );
|
VectorSubtract( origin, v_forward, origin );
|
||||||
break;
|
break;
|
||||||
case SPR_FACING_UPRIGHT:
|
case SPR_FACING_UPRIGHT:
|
||||||
VectorSet( v_right, origin[1] - RI.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
|
VectorSet( v_right, origin[1] - RI.rvp.vieworigin[1], -(origin[0] - RI.rvp.vieworigin[0]), 0.0f );
|
||||||
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
||||||
VectorNormalize( v_right );
|
VectorNormalize( v_right );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ init current time for a given model
|
|||||||
*/
|
*/
|
||||||
static void R_StudioSetupTimings( void )
|
static void R_StudioSetupTimings( void )
|
||||||
{
|
{
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
// synchronize with server time
|
// synchronize with server time
|
||||||
g_studio.time = gp_cl->time;
|
g_studio.time = gp_cl->time;
|
||||||
@@ -369,23 +369,12 @@ pfnPlayerInfo
|
|||||||
*/
|
*/
|
||||||
player_info_t *pfnPlayerInfo( int index )
|
player_info_t *pfnPlayerInfo( int index )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
index = -1;
|
index = -1;
|
||||||
|
|
||||||
return gEngfuncs.pfnPlayerInfo( index );
|
return gEngfuncs.pfnPlayerInfo( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnMod_ForName
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static model_t *pfnMod_ForName( const char *model, int crash )
|
|
||||||
{
|
|
||||||
return gEngfuncs.Mod_ForName( model, crash, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetPlayerState
|
pfnGetPlayerState
|
||||||
@@ -394,23 +383,12 @@ pfnGetPlayerState
|
|||||||
*/
|
*/
|
||||||
static entity_state_t *R_StudioGetPlayerState( int index )
|
static entity_state_t *R_StudioGetPlayerState( int index )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return &RI.currententity->curstate;
|
return &RI.currententity->curstate;
|
||||||
|
|
||||||
return gEngfuncs.pfnGetPlayerState( index );
|
return gEngfuncs.pfnGetPlayerState( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnGetViewEntity
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static cl_entity_t *pfnGetViewEntity( void )
|
|
||||||
{
|
|
||||||
return tr.viewent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetEngineTimes
|
pfnGetEngineTimes
|
||||||
@@ -432,23 +410,12 @@ pfnGetViewInfo
|
|||||||
*/
|
*/
|
||||||
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
|
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
|
||||||
{
|
{
|
||||||
if( origin ) VectorCopy( RI.vieworg, origin );
|
if( origin ) VectorCopy( RI.rvp.vieworigin, origin );
|
||||||
if( forwardv ) VectorCopy( RI.vforward, forwardv );
|
if( forwardv ) VectorCopy( RI.vforward, forwardv );
|
||||||
if( rightv ) VectorCopy( RI.vright, rightv );
|
if( rightv ) VectorCopy( RI.vright, rightv );
|
||||||
if( upv ) VectorCopy( RI.vup, upv );
|
if( upv ) VectorCopy( RI.vup, upv );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
R_GetChromeSprite
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static model_t *R_GetChromeSprite( void )
|
|
||||||
{
|
|
||||||
return gEngfuncs.GetDefaultSprite( REF_CHROME_SPRITE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetModelCounters
|
pfnGetModelCounters
|
||||||
@@ -461,18 +428,6 @@ static void pfnGetModelCounters( int **s, int **a )
|
|||||||
*a = &r_stats.c_studio_models_drawn;
|
*a = &r_stats.c_studio_models_drawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnGetAliasScale
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static void pfnGetAliasScale( float *x, float *y )
|
|
||||||
{
|
|
||||||
if( x ) *x = 1.0f;
|
|
||||||
if( y ) *y = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnStudioGetBoneTransform
|
pfnStudioGetBoneTransform
|
||||||
@@ -495,17 +450,6 @@ static float ****pfnStudioGetLightTransform( void )
|
|||||||
return (float ****)g_studio.lighttransform;
|
return (float ****)g_studio.lighttransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnStudioGetAliasTransform
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static float ***pfnStudioGetAliasTransform( void )
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnStudioGetRotationMatrix
|
pfnStudioGetRotationMatrix
|
||||||
@@ -1328,7 +1272,7 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
|
|||||||
if( !plight || !ent || !ent->model )
|
if( !plight || !ent || !ent->model )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
||||||
{
|
{
|
||||||
plight->shadelight = 0;
|
plight->shadelight = 0;
|
||||||
plight->ambientlight = 192;
|
plight->ambientlight = 192;
|
||||||
@@ -2662,7 +2606,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
|
|||||||
state = &g_studio.player_models[index];
|
state = &g_studio.player_models[index];
|
||||||
|
|
||||||
// g-cont: force for "dev-mode", non-local games and menu preview
|
// g-cont: force for "dev-mode", non-local games and menu preview
|
||||||
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !RI.drawWorld ) && info->model[0] )
|
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) ) && info->model[0] )
|
||||||
{
|
{
|
||||||
if( Q_strcmp( state->name, info->model ))
|
if( Q_strcmp( state->name, info->model ))
|
||||||
{
|
{
|
||||||
@@ -2914,19 +2858,7 @@ R_StudioSetChromeOrigin
|
|||||||
*/
|
*/
|
||||||
static void R_StudioSetChromeOrigin( void )
|
static void R_StudioSetChromeOrigin( void )
|
||||||
{
|
{
|
||||||
VectorCopy( RI.vieworg, g_studio.chrome_origin );
|
VectorCopy( RI.rvp.vieworigin, g_studio.chrome_origin );
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnIsHardware
|
|
||||||
|
|
||||||
Xash3D is always works in hardware mode
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static int pfnIsHardware( void )
|
|
||||||
{
|
|
||||||
return 1; // 0 is Software, 1 is OpenGL, 2 is Direct3D
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3165,7 +3097,7 @@ static void R_StudioRenderModel( void )
|
|||||||
R_StudioRenderFinal( );
|
R_StudioRenderFinal( );
|
||||||
|
|
||||||
R_StudioSetForceFaceFlags( STUDIO_NF_CHROME );
|
R_StudioSetForceFaceFlags( STUDIO_NF_CHROME );
|
||||||
TriSpriteTexture( R_GetChromeSprite(), 0 );
|
TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_CHROME_SPRITE ), 0 );
|
||||||
RI.currententity->curstate.renderfx = kRenderFxGlowShell;
|
RI.currententity->curstate.renderfx = kRenderFxGlowShell;
|
||||||
|
|
||||||
R_StudioRenderFinal( );
|
R_StudioRenderFinal( );
|
||||||
@@ -3398,7 +3330,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|||||||
if( flags & STUDIO_RENDER )
|
if( flags & STUDIO_RENDER )
|
||||||
{
|
{
|
||||||
// change body if it's a menu entity
|
// change body if it's a menu entity
|
||||||
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !RI.drawWorld ))
|
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )))
|
||||||
{
|
{
|
||||||
// show highest resolution multiplayer model
|
// show highest resolution multiplayer model
|
||||||
RI.currententity->curstate.body = 255;
|
RI.currententity->curstate.body = 255;
|
||||||
@@ -3554,7 +3486,7 @@ R_StudioDrawModelInternal
|
|||||||
*/
|
*/
|
||||||
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
|
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
if( e->player )
|
if( e->player )
|
||||||
R_StudioDrawPlayer( flags, &e->curstate );
|
R_StudioDrawPlayer( flags, &e->curstate );
|
||||||
@@ -3589,7 +3521,7 @@ R_DrawStudioModel
|
|||||||
*/
|
*/
|
||||||
void R_DrawStudioModel( cl_entity_t *e )
|
void R_DrawStudioModel( cl_entity_t *e )
|
||||||
{
|
{
|
||||||
if( FBitSet( RI.params, RP_ENVVIEW ))
|
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
R_StudioSetupTimings();
|
R_StudioSetupTimings();
|
||||||
@@ -3644,7 +3576,7 @@ void R_RunViewmodelEvents( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ignore in thirdperson, camera view or client is died
|
// ignore in thirdperson, camera view or client is died
|
||||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RI.currententity = tr.viewent;
|
RI.currententity = tr.viewent;
|
||||||
@@ -3662,20 +3594,6 @@ void R_RunViewmodelEvents( void )
|
|||||||
R_StudioDrawModelInternal( RI.currententity, STUDIO_EVENTS );
|
R_StudioDrawModelInternal( RI.currententity, STUDIO_EVENTS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
R_GatherPlayerLight
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void R_GatherPlayerLight( void )
|
|
||||||
{
|
|
||||||
cl_entity_t *view = tr.viewent;
|
|
||||||
colorVec c;
|
|
||||||
|
|
||||||
c = R_LightPoint( view->origin );
|
|
||||||
gEngfuncs.SetLocalLightLevel( ( c.r + c.g + c.b ) / 3 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
R_DrawViewModel
|
R_DrawViewModel
|
||||||
@@ -3685,7 +3603,7 @@ void R_DrawViewModel( void )
|
|||||||
{
|
{
|
||||||
cl_entity_t *view = tr.viewent;
|
cl_entity_t *view = tr.viewent;
|
||||||
|
|
||||||
R_GatherPlayerLight();
|
R_GatherPlayerLight( view );
|
||||||
|
|
||||||
if( r_drawviewmodel->value == 0 )
|
if( r_drawviewmodel->value == 0 )
|
||||||
return;
|
return;
|
||||||
@@ -3694,7 +3612,7 @@ void R_DrawViewModel( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ignore in thirdperson, camera view or client is died
|
// ignore in thirdperson, camera view or client is died
|
||||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
if( FBitSet( RI.rvp.flags, RF_DRAW_CUBEMAP ) || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tr.blend = CL_FxBlend( view ) / 255.0f;
|
tr.blend = CL_FxBlend( view ) / 255.0f;
|
||||||
@@ -3881,115 +3799,53 @@ void Mod_StudioUnloadTextures( void *data )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static model_t *pfnModelHandle( int modelindex )
|
qboolean R_StudioFillAPI( engine_studio_api_t *api, r_studio_interface_t *pDefaultDraw )
|
||||||
{
|
{
|
||||||
if( modelindex < 0 || modelindex >= MAX_MODELS )
|
|
||||||
return NULL;
|
|
||||||
return CL_ModelHandle( modelindex );
|
|
||||||
}
|
|
||||||
|
|
||||||
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 =
|
|
||||||
{
|
|
||||||
pfnMod_Calloc,
|
|
||||||
pfnMod_CacheCheck,
|
|
||||||
pfnMod_LoadCacheFile,
|
|
||||||
pfnMod_ForName,
|
|
||||||
pfnMod_StudioExtradata,
|
|
||||||
pfnModelHandle,
|
|
||||||
pfnGetCurrentEntity,
|
|
||||||
pfnPlayerInfo,
|
|
||||||
R_StudioGetPlayerState,
|
|
||||||
pfnGetViewEntity,
|
|
||||||
pfnGetEngineTimes,
|
|
||||||
pfnGetCvarPointer,
|
|
||||||
pfnGetViewInfo,
|
|
||||||
R_GetChromeSprite,
|
|
||||||
pfnGetModelCounters,
|
|
||||||
pfnGetAliasScale,
|
|
||||||
pfnStudioGetBoneTransform,
|
|
||||||
pfnStudioGetLightTransform,
|
|
||||||
pfnStudioGetAliasTransform,
|
|
||||||
pfnStudioGetRotationMatrix,
|
|
||||||
R_StudioSetupModel,
|
|
||||||
R_StudioCheckBBox,
|
|
||||||
R_StudioDynamicLight,
|
|
||||||
R_StudioEntityLight,
|
|
||||||
R_StudioSetupLighting,
|
|
||||||
R_StudioDrawPoints,
|
|
||||||
R_StudioDrawHulls,
|
|
||||||
R_StudioDrawAbsBBox,
|
|
||||||
R_StudioDrawBones,
|
|
||||||
(void*)R_StudioSetupSkin,
|
|
||||||
R_StudioSetRemapColors,
|
|
||||||
R_StudioSetupPlayerModel,
|
|
||||||
R_StudioClientEvents,
|
|
||||||
R_StudioGetForceFaceFlags,
|
|
||||||
R_StudioSetForceFaceFlags,
|
|
||||||
(void*)R_StudioSetHeader,
|
|
||||||
R_StudioSetRenderModel,
|
|
||||||
R_StudioSetupRenderer,
|
|
||||||
R_StudioRestoreRenderer,
|
|
||||||
R_StudioSetChromeOrigin,
|
|
||||||
pfnIsHardware,
|
|
||||||
GL_StudioDrawShadow,
|
|
||||||
GL_StudioSetRenderMode,
|
|
||||||
R_StudioSetRenderamt,
|
|
||||||
R_StudioSetCullState,
|
|
||||||
R_StudioRenderShadow,
|
|
||||||
};
|
|
||||||
|
|
||||||
static r_studio_interface_t gStudioDraw =
|
|
||||||
{
|
|
||||||
STUDIO_INTERFACE_VERSION,
|
|
||||||
R_StudioDrawModel,
|
|
||||||
R_StudioDrawPlayer,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
CL_InitStudioAPI
|
|
||||||
|
|
||||||
Initialize client studio
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void CL_InitStudioAPI( void )
|
|
||||||
{
|
|
||||||
pStudioDraw = &gStudioDraw;
|
|
||||||
|
|
||||||
// trying to grab them from client.dll
|
|
||||||
cl_righthand = gEngfuncs.pfnGetCvarPointer( "cl_righthand" );
|
cl_righthand = gEngfuncs.pfnGetCvarPointer( "cl_righthand" );
|
||||||
|
|
||||||
// Xash will be used internal StudioModelRenderer
|
api->GetCurrentEntity = pfnGetCurrentEntity;
|
||||||
if( gEngfuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI ))
|
api->PlayerInfo = pfnPlayerInfo;
|
||||||
return;
|
api->GetPlayerState = R_StudioGetPlayerState;
|
||||||
|
api->GetTimes = pfnGetEngineTimes;
|
||||||
|
api->GetViewInfo = pfnGetViewInfo;
|
||||||
|
api->GetModelCounters = pfnGetModelCounters;
|
||||||
|
api->StudioGetBoneTransform = pfnStudioGetBoneTransform;
|
||||||
|
api->StudioGetLightTransform = pfnStudioGetLightTransform;
|
||||||
|
api->StudioGetRotationMatrix = pfnStudioGetRotationMatrix;
|
||||||
|
api->StudioSetupModel = R_StudioSetupModel;
|
||||||
|
api->StudioCheckBBox = R_StudioCheckBBox;
|
||||||
|
api->StudioDynamicLight = R_StudioDynamicLight;
|
||||||
|
api->StudioEntityLight = R_StudioEntityLight;
|
||||||
|
api->StudioSetupLighting = R_StudioSetupLighting;
|
||||||
|
api->StudioDrawPoints = R_StudioDrawPoints;
|
||||||
|
api->StudioDrawHulls = R_StudioDrawHulls;
|
||||||
|
api->StudioDrawAbsBBox = R_StudioDrawAbsBBox;
|
||||||
|
api->StudioDrawBones = R_StudioDrawBones;
|
||||||
|
api->StudioSetupSkin = (void *)R_StudioSetupSkin;
|
||||||
|
api->StudioSetRemapColors = R_StudioSetRemapColors;
|
||||||
|
api->SetupPlayerModel = R_StudioSetupPlayerModel;
|
||||||
|
api->StudioClientEvents = R_StudioClientEvents;
|
||||||
|
api->GetForceFaceFlags = R_StudioGetForceFaceFlags;
|
||||||
|
api->SetForceFaceFlags = R_StudioSetForceFaceFlags;
|
||||||
|
api->StudioSetHeader = (void *)R_StudioSetHeader;
|
||||||
|
api->SetRenderModel = R_StudioSetRenderModel;
|
||||||
|
api->SetupRenderer = R_StudioSetupRenderer;
|
||||||
|
api->RestoreRenderer = R_StudioRestoreRenderer;
|
||||||
|
api->SetChromeOrigin = R_StudioSetChromeOrigin;
|
||||||
|
api->GL_StudioDrawShadow = GL_StudioDrawShadow;
|
||||||
|
api->GL_SetRenderMode = GL_StudioSetRenderMode;
|
||||||
|
api->StudioSetRenderamt = R_StudioSetRenderamt;
|
||||||
|
api->StudioSetCullState = R_StudioSetCullState;
|
||||||
|
api->StudioRenderShadow = R_StudioRenderShadow;
|
||||||
|
|
||||||
// NOTE: we always return true even if game interface was not correct
|
pDefaultDraw->version = STUDIO_INTERFACE_VERSION;
|
||||||
// because we need Draw our StudioModels
|
pDefaultDraw->StudioDrawModel = R_StudioDrawModel;
|
||||||
// just restore pointer to builtin function
|
pDefaultDraw->StudioDrawPlayer = R_StudioDrawPlayer;
|
||||||
pStudioDraw = &gStudioDraw;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_StudioSetDrawInterface( r_studio_interface_t *pDraw )
|
||||||
|
{
|
||||||
|
pStudioDraw = pDraw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,10 +226,10 @@ int TriWorldToScreen( const float *world, float *screen )
|
|||||||
|
|
||||||
retval = R_WorldToScreen( world, screen );
|
retval = R_WorldToScreen( world, screen );
|
||||||
|
|
||||||
screen[0] = 0.5f * screen[0] * (float)RI.viewport[2];
|
screen[0] = 0.5f * screen[0] * (float)RI.rvp.viewport[2];
|
||||||
screen[1] = -0.5f * screen[1] * (float)RI.viewport[3];
|
screen[1] = -0.5f * screen[1] * (float)RI.rvp.viewport[3];
|
||||||
screen[0] += 0.5f * (float)RI.viewport[2];
|
screen[0] += 0.5f * (float)RI.rvp.viewport[2];
|
||||||
screen[1] += 0.5f * (float)RI.viewport[3];
|
screen[1] += 0.5f * (float)RI.rvp.viewport[3];
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,10 +339,6 @@ R_DrawSkybox
|
|||||||
*/
|
*/
|
||||||
void R_DrawSkyBox( void )
|
void R_DrawSkyBox( void )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
RI.isSkyVisible = true;
|
|
||||||
|
|
||||||
// don't fogging skybox (this fix old Half-Life bug)
|
// don't fogging skybox (this fix old Half-Life bug)
|
||||||
if( !RI.fogSkybox ) R_AllowFog( false );
|
if( !RI.fogSkybox ) R_AllowFog( false );
|
||||||
|
|
||||||
@@ -353,7 +349,7 @@ void R_DrawSkyBox( void )
|
|||||||
pglDisable( GL_ALPHA_TEST );
|
pglDisable( GL_ALPHA_TEST );
|
||||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
|
||||||
|
|
||||||
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
for( int i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||||
{
|
{
|
||||||
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
|
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
|
||||||
continue;
|
continue;
|
||||||
@@ -421,7 +417,7 @@ static void R_CloudTexCoord( const vec3_t v, float speed, float *s, float *t )
|
|||||||
speedscale = gp_cl->time * speed;
|
speedscale = gp_cl->time * speed;
|
||||||
speedscale -= (int)speedscale & ~127;
|
speedscale -= (int)speedscale & ~127;
|
||||||
|
|
||||||
VectorSubtract( v, RI.vieworg, dir );
|
VectorSubtract( v, RI.rvp.vieworigin, dir );
|
||||||
dir[2] *= 3.0f; // flatten the sphere
|
dir[2] *= 3.0f; // flatten the sphere
|
||||||
|
|
||||||
length = VectorLength( dir );
|
length = VectorLength( dir );
|
||||||
@@ -533,16 +529,12 @@ Quake-style clouds
|
|||||||
*/
|
*/
|
||||||
void R_DrawClouds( void )
|
void R_DrawClouds( void )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
RI.isSkyVisible = true;
|
|
||||||
|
|
||||||
if( RI.fogEnabled )
|
if( RI.fogEnabled )
|
||||||
pglFogf( GL_FOG_DENSITY, RI.fogDensity * 0.25f );
|
pglFogf( GL_FOG_DENSITY, RI.fogDensity * 0.25f );
|
||||||
pglDepthFunc( GL_GEQUAL );
|
pglDepthFunc( GL_GEQUAL );
|
||||||
pglDepthMask( GL_FALSE );
|
pglDepthMask( GL_FALSE );
|
||||||
|
|
||||||
for( i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
for( int i = 0; i < SKYBOX_MAX_SIDES; i++ )
|
||||||
{
|
{
|
||||||
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
|
if( RI.skyMins[0][i] >= RI.skyMaxs[0][i] || RI.skyMins[1][i] >= RI.skyMaxs[1][i] )
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -49,6 +49,37 @@ static void R_SimpleStubBool( qboolean unused )
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static qboolean R_StudioFillAPI( struct engine_studio_api_s *api, struct r_studio_interface_s *pDefaultDraw )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_StudioSetDrawInterface( struct r_studio_interface_s *pDraw )
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_GetDetailScaleForTexture( int texture, float *xScale, float *yScale )
|
||||||
|
{
|
||||||
|
if( xScale ) *xScale = 1.0f;
|
||||||
|
if( yScale ) *yScale = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_SetDetailScaleForTexture( int texture, float xScale, float yScale )
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FillRenderAPI( render_api_t *api )
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FillTriAPI( triangleapi_t *api )
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
static qboolean R_Init( void )
|
static qboolean R_Init( void )
|
||||||
{
|
{
|
||||||
gEngfuncs.R_Init_Video( REF_SOFTWARE );
|
gEngfuncs.R_Init_Video( REF_SOFTWARE );
|
||||||
@@ -100,11 +131,6 @@ static void R_SetupSky( int *skytextures )
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum )
|
static void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum )
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
@@ -288,7 +314,7 @@ static void R_EntityRemoveDecals( struct model_s *mod )
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AVI_UploadRawFrame( int texture, int cols, int rows, int width, int height, const byte *data )
|
static void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt )
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -409,11 +435,6 @@ static void VGUI_SetupDrawing( qboolean rect )
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VGUI_UploadTextureBlock( int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const ref_interface_t gReffuncs =
|
static const ref_interface_t gReffuncs =
|
||||||
{
|
{
|
||||||
.R_Init = R_Init,
|
.R_Init = R_Init,
|
||||||
@@ -440,7 +461,6 @@ static const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
.R_AddEntity = R_AddEntity,
|
.R_AddEntity = R_AddEntity,
|
||||||
.R_ProcessEntData = R_ProcessEntData,
|
.R_ProcessEntData = R_ProcessEntData,
|
||||||
.R_Flush = R_SimpleStubUInt,
|
|
||||||
|
|
||||||
.R_ShowTextures = R_SimpleStub,
|
.R_ShowTextures = R_SimpleStub,
|
||||||
|
|
||||||
@@ -450,7 +470,6 @@ static const ref_interface_t gReffuncs =
|
|||||||
.R_SetupSky = R_SetupSky,
|
.R_SetupSky = R_SetupSky,
|
||||||
|
|
||||||
.R_Set2DMode = R_SimpleStubBool,
|
.R_Set2DMode = R_SimpleStubBool,
|
||||||
.R_DrawStretchRaw = R_DrawStretchRaw,
|
|
||||||
.R_DrawStretchPic = R_DrawStretchPic,
|
.R_DrawStretchPic = R_DrawStretchPic,
|
||||||
.FillRGBA = FillRGBA,
|
.FillRGBA = FillRGBA,
|
||||||
.WorldToScreen = WorldToScreen,
|
.WorldToScreen = WorldToScreen,
|
||||||
@@ -467,7 +486,8 @@ static const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
.R_StudioEstimateFrame = R_StudioEstimateFrame,
|
.R_StudioEstimateFrame = R_StudioEstimateFrame,
|
||||||
.R_StudioLerpMovement = R_StudioLerpMovement,
|
.R_StudioLerpMovement = R_StudioLerpMovement,
|
||||||
.CL_InitStudioAPI = R_SimpleStub,
|
.R_StudioFillAPI = R_StudioFillAPI,
|
||||||
|
.R_StudioSetDrawInterface = R_StudioSetDrawInterface,
|
||||||
|
|
||||||
.R_SetSkyCloudsTextures = R_SetSkyCloudsTextures,
|
.R_SetSkyCloudsTextures = R_SetSkyCloudsTextures,
|
||||||
.GL_SubdivideSurface = GL_SubdivideSurface,
|
.GL_SubdivideSurface = GL_SubdivideSurface,
|
||||||
@@ -480,45 +500,23 @@ static const ref_interface_t gReffuncs =
|
|||||||
.CL_DrawParticles = CL_DrawParticles,
|
.CL_DrawParticles = CL_DrawParticles,
|
||||||
.CL_DrawTracers = CL_DrawTracers,
|
.CL_DrawTracers = CL_DrawTracers,
|
||||||
.CL_DrawBeams = CL_DrawBeams,
|
.CL_DrawBeams = CL_DrawBeams,
|
||||||
.R_BeamCull = R_BeamCull,
|
|
||||||
|
|
||||||
.RefGetParm = RefGetParm,
|
.RefGetParm = RefGetParm,
|
||||||
.GetDetailScaleForTexture = GetDetailScaleForTexture,
|
|
||||||
.GetExtraParmsForTexture = GetExtraParmsForTexture,
|
|
||||||
.GetFrameTime = GetFrameTime,
|
|
||||||
|
|
||||||
.R_SetCurrentEntity = R_SetCurrentEntity,
|
.R_GetDetailScaleForTexture = R_GetDetailScaleForTexture,
|
||||||
.R_SetCurrentModel = R_SetCurrentModel,
|
.R_SetDetailScaleForTexture = R_SetDetailScaleForTexture,
|
||||||
|
|
||||||
|
.GL_CreateTexture = GL_CreateTexture,
|
||||||
.GL_FindTexture = GL_FindTexture,
|
.GL_FindTexture = GL_FindTexture,
|
||||||
.GL_TextureName = GL_TextureName,
|
.GL_TextureName = GL_TextureName,
|
||||||
.GL_TextureData = GL_TextureData,
|
.GL_TextureData = GL_TextureData,
|
||||||
.GL_LoadTexture = GL_LoadTexture,
|
.GL_LoadTexture = GL_LoadTexture,
|
||||||
.GL_CreateTexture = GL_CreateTexture,
|
|
||||||
.GL_LoadTextureArray = GL_LoadTextureArray,
|
|
||||||
.GL_CreateTextureArray = GL_CreateTextureArray,
|
|
||||||
.GL_FreeTexture = R_SimpleStubUInt,
|
.GL_FreeTexture = R_SimpleStubUInt,
|
||||||
.R_OverrideTextureSourceSize = R_OverrideTextureSourceSize,
|
.R_OverrideTextureSourceSize = R_OverrideTextureSourceSize,
|
||||||
|
|
||||||
.DrawSingleDecal = DrawSingleDecal,
|
.GL_UpdateTexture = GL_UpdateTexture,
|
||||||
.R_DecalSetupVerts = R_DecalSetupVerts,
|
|
||||||
.R_EntityRemoveDecals = R_EntityRemoveDecals,
|
|
||||||
|
|
||||||
.AVI_UploadRawFrame = AVI_UploadRawFrame,
|
|
||||||
|
|
||||||
.GL_Bind = GL_Bind,
|
.GL_Bind = GL_Bind,
|
||||||
.GL_SelectTexture = R_SimpleStubInt,
|
|
||||||
.GL_LoadTextureMatrix = GL_LoadTextureMatrix,
|
|
||||||
.GL_TexMatrixIdentity = R_SimpleStub,
|
|
||||||
.GL_CleanUpTextureUnits = R_SimpleStubInt,
|
|
||||||
.GL_TexGen = GL_TexGen,
|
|
||||||
.GL_TextureTarget = R_SimpleStubUInt,
|
|
||||||
.GL_TexCoordArrayMode = R_SimpleStubUInt,
|
|
||||||
.GL_UpdateTexSize = GL_UpdateTexSize,
|
|
||||||
|
|
||||||
.GL_DrawParticles = GL_DrawParticles,
|
|
||||||
.LightVec = LightVec,
|
|
||||||
.StudioGetTexture = StudioGetTexture,
|
|
||||||
|
|
||||||
.GL_RenderFrame = GL_RenderFrame,
|
.GL_RenderFrame = GL_RenderFrame,
|
||||||
.GL_OrthoBounds = GL_OrthoBounds,
|
.GL_OrthoBounds = GL_OrthoBounds,
|
||||||
@@ -526,24 +524,20 @@ static const ref_interface_t gReffuncs =
|
|||||||
.Mod_GetCurrentVis = Mod_GetCurrentVis,
|
.Mod_GetCurrentVis = Mod_GetCurrentVis,
|
||||||
.R_NewMap = R_SimpleStub,
|
.R_NewMap = R_SimpleStub,
|
||||||
.R_ClearScene = R_SimpleStub,
|
.R_ClearScene = R_SimpleStub,
|
||||||
.R_GetProcAddress = R_GetProcAddress,
|
|
||||||
|
|
||||||
.TriRenderMode = R_SimpleStubInt,
|
.TriRenderMode = R_SimpleStubInt,
|
||||||
.Begin = R_SimpleStubInt,
|
.Begin = R_SimpleStubInt,
|
||||||
.End = R_SimpleStub,
|
.End = R_SimpleStub,
|
||||||
.Color4f = Color4f,
|
.Color4f = Color4f,
|
||||||
.Color4ub = Color4ub,
|
.Color4ub = Color4ub,
|
||||||
.TexCoord2f = TexCoord2f,
|
|
||||||
.Vertex3fv = Vertex3fv,
|
.Vertex3fv = Vertex3fv,
|
||||||
.Vertex3f = Vertex3f,
|
.Vertex3f = Vertex3f,
|
||||||
.Fog = Fog,
|
|
||||||
.ScreenToWorld = ScreenToWorld,
|
|
||||||
.GetMatrix = GetMatrix,
|
|
||||||
.FogParams = FogParams,
|
|
||||||
.CullFace = CullFace,
|
.CullFace = CullFace,
|
||||||
|
|
||||||
|
.R_FillRenderAPI = R_FillRenderAPI,
|
||||||
|
.R_FillTriAPI = R_FillTriAPI,
|
||||||
|
|
||||||
.VGUI_SetupDrawing = VGUI_SetupDrawing,
|
.VGUI_SetupDrawing = VGUI_SetupDrawing,
|
||||||
.VGUI_UploadTextureBlock = VGUI_UploadTextureBlock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, ref_globals_t *globals );
|
int EXPORT GetRefAPI( int version, ref_interface_t *funcs, ref_api_t *engfuncs, ref_globals_t *globals );
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ static void R_BeamComputeNormal( const vec3_t vStartPos, const vec3_t vNextPos,
|
|||||||
VectorSubtract( vStartPos, vNextPos, vTangentY );
|
VectorSubtract( vStartPos, vNextPos, vTangentY );
|
||||||
|
|
||||||
// vDirToBeam = vector from viewer origin to beam
|
// vDirToBeam = vector from viewer origin to beam
|
||||||
VectorSubtract( vStartPos, RI.vieworg, vDirToBeam );
|
VectorSubtract( vStartPos, RI.rvp.vieworigin, vDirToBeam );
|
||||||
|
|
||||||
// get a vector that is perpendicular to us and perpendicular to the beam.
|
// get a vector that is perpendicular to us and perpendicular to the beam.
|
||||||
// this is used to fatten the beam.
|
// this is used to fatten the beam.
|
||||||
@@ -116,7 +116,7 @@ R_BeamCull
|
|||||||
Cull the beam by bbox
|
Cull the beam by bbox
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
qboolean GAME_EXPORT R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
static qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly )
|
||||||
{
|
{
|
||||||
// culling is undone in ref_soft
|
// culling is undone in ref_soft
|
||||||
return false;
|
return false;
|
||||||
@@ -1000,7 +1000,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
|
|||||||
float flDistance;
|
float flDistance;
|
||||||
|
|
||||||
// fade the beam if the player's not looking at the source
|
// fade the beam if the player's not looking at the source
|
||||||
VectorSubtract( RI.vieworg, pbeam->source, localDir );
|
VectorSubtract( RI.rvp.vieworigin, pbeam->source, localDir );
|
||||||
flDot = DotProduct( delta, localDir );
|
flDot = DotProduct( delta, localDir );
|
||||||
VectorScale( delta, flDot, vecProjection );
|
VectorScale( delta, flDot, vecProjection );
|
||||||
VectorSubtract( localDir, vecProjection, tmp );
|
VectorSubtract( localDir, vecProjection, tmp );
|
||||||
|
|||||||
@@ -643,14 +643,14 @@ R_RenderWorld
|
|||||||
*/
|
*/
|
||||||
void R_RenderWorld( void )
|
void R_RenderWorld( void )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// auto cycle the world frame for texture animation
|
// auto cycle the world frame for texture animation
|
||||||
RI.currententity = CL_GetEntityByIndex( 0 );
|
RI.currententity = CL_GetEntityByIndex( 0 );
|
||||||
// RI.currententity->frame = (int)(gp_cl->time*2);
|
// RI.currententity->frame = (int)(gp_cl->time*2);
|
||||||
|
|
||||||
VectorCopy( RI.vieworg, tr.modelorg );
|
VectorCopy( RI.rvp.vieworigin, tr.modelorg );
|
||||||
RI.currentmodel = WORLDMODEL;
|
RI.currentmodel = WORLDMODEL;
|
||||||
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
||||||
|
|
||||||
|
|||||||
@@ -198,8 +198,13 @@ static void GAME_EXPORT R_GetDetailScaleForTexture( int texture, float *xScale,
|
|||||||
{
|
{
|
||||||
// details are not implemented in ref_soft
|
// details are not implemented in ref_soft
|
||||||
|
|
||||||
if( xScale ) *xScale = 0.0f;
|
if( xScale ) *xScale = 1.0f;
|
||||||
if( yScale ) *yScale = 0.0f;
|
if( yScale ) *yScale = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GAME_EXPORT R_SetDetailScaleForTexture( int texture, float xScale, float yScale )
|
||||||
|
{
|
||||||
|
// details are not implemented in ref_soft
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
|
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
|
||||||
@@ -258,11 +263,6 @@ static void GAME_EXPORT R_ProcessEntData( qboolean allocate, cl_entity_t *entiti
|
|||||||
tr.max_entities = max_entities;
|
tr.max_entities = max_entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT R_Flush( unsigned int flags )
|
|
||||||
{
|
|
||||||
// stub
|
|
||||||
}
|
|
||||||
|
|
||||||
// stubs
|
// stubs
|
||||||
|
|
||||||
static void GAME_EXPORT GL_SetTexCoordArrayMode( uint mode )
|
static void GAME_EXPORT GL_SetTexCoordArrayMode( uint mode )
|
||||||
@@ -372,10 +372,6 @@ byte *GAME_EXPORT Mod_GetCurrentVis( void )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAME_EXPORT VGUI_UploadTextureBlock( int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GAME_EXPORT VGUI_SetupDrawing( qboolean rect )
|
static void GAME_EXPORT VGUI_SetupDrawing( qboolean rect )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -398,6 +394,41 @@ static void * GAME_EXPORT R_GetProcAddress( const char *name )
|
|||||||
return gEngfuncs.GL_GetProcAddress( name );
|
return gEngfuncs.GL_GetProcAddress( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_FillRenderAPI( render_api_t *api )
|
||||||
|
{
|
||||||
|
api->GetExtraParmsForTexture = R_GetExtraParmsForTexture;
|
||||||
|
api->GetFrameTime = R_GetFrameTime;
|
||||||
|
api->R_SetCurrentEntity = R_SetCurrentEntity;
|
||||||
|
api->R_SetCurrentModel = R_SetCurrentModel;
|
||||||
|
api->GL_CreateTexture = GL_CreateTexture;
|
||||||
|
api->GL_LoadTextureArray = GL_LoadTextureArray;
|
||||||
|
api->GL_CreateTextureArray = GL_CreateTextureArray;
|
||||||
|
api->DrawSingleDecal = DrawSingleDecal;
|
||||||
|
api->R_DecalSetupVerts = R_DecalSetupVerts;
|
||||||
|
api->R_EntityRemoveDecals = R_EntityRemoveDecals;
|
||||||
|
api->GL_SelectTexture = GL_SelectTexture;
|
||||||
|
api->GL_LoadTextureMatrix = GL_LoadTexMatrixExt;
|
||||||
|
api->GL_TexMatrixIdentity = GL_LoadIdentityTexMatrix;
|
||||||
|
api->GL_CleanUpTextureUnits = GL_CleanUpTextureUnits;
|
||||||
|
api->GL_TexGen = GL_TexGen;
|
||||||
|
api->GL_TextureTarget = GL_TextureTarget;
|
||||||
|
api->GL_TexCoordArrayMode = GL_SetTexCoordArrayMode;
|
||||||
|
api->GL_UpdateTexSize = GL_UpdateTexSize;
|
||||||
|
api->GL_DrawParticles = CL_DrawParticlesExternal;
|
||||||
|
api->LightVec = R_LightVec;
|
||||||
|
api->StudioGetTexture = R_StudioGetTexture;
|
||||||
|
api->GL_GetProcAddress = R_GetProcAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FillTriAPI( triangleapi_t *api )
|
||||||
|
{
|
||||||
|
api->TexCoord2f = TriTexCoord2f;
|
||||||
|
api->Fog = TriFog;
|
||||||
|
api->ScreenToWorld = R_ScreenToWorld;
|
||||||
|
api->GetMatrix = TriGetMatrix;
|
||||||
|
api->FogParams = TriFogParams;
|
||||||
|
}
|
||||||
|
|
||||||
const ref_interface_t gReffuncs =
|
const ref_interface_t gReffuncs =
|
||||||
{
|
{
|
||||||
R_Init,
|
R_Init,
|
||||||
@@ -424,7 +455,6 @@ const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
R_AddEntity,
|
R_AddEntity,
|
||||||
R_ProcessEntData,
|
R_ProcessEntData,
|
||||||
R_Flush,
|
|
||||||
|
|
||||||
R_ShowTextures,
|
R_ShowTextures,
|
||||||
|
|
||||||
@@ -434,7 +464,6 @@ const ref_interface_t gReffuncs =
|
|||||||
R_SetupSky,
|
R_SetupSky,
|
||||||
|
|
||||||
R_Set2DMode,
|
R_Set2DMode,
|
||||||
R_DrawStretchRaw,
|
|
||||||
R_DrawStretchPic,
|
R_DrawStretchPic,
|
||||||
CL_FillRGBA,
|
CL_FillRGBA,
|
||||||
R_WorldToScreen,
|
R_WorldToScreen,
|
||||||
@@ -451,7 +480,8 @@ const ref_interface_t gReffuncs =
|
|||||||
|
|
||||||
R_StudioEstimateFrame,
|
R_StudioEstimateFrame,
|
||||||
R_StudioLerpMovement,
|
R_StudioLerpMovement,
|
||||||
CL_InitStudioAPI,
|
R_StudioFillAPI,
|
||||||
|
R_StudioSetDrawInterface,
|
||||||
|
|
||||||
R_SetSkyCloudsTextures,
|
R_SetSkyCloudsTextures,
|
||||||
GL_SubdivideSurface,
|
GL_SubdivideSurface,
|
||||||
@@ -464,45 +494,23 @@ const ref_interface_t gReffuncs =
|
|||||||
CL_DrawParticles,
|
CL_DrawParticles,
|
||||||
CL_DrawTracers,
|
CL_DrawTracers,
|
||||||
CL_DrawBeams,
|
CL_DrawBeams,
|
||||||
R_BeamCull,
|
|
||||||
|
|
||||||
GL_RefGetParm,
|
GL_RefGetParm,
|
||||||
|
|
||||||
R_GetDetailScaleForTexture,
|
R_GetDetailScaleForTexture,
|
||||||
R_GetExtraParmsForTexture,
|
R_SetDetailScaleForTexture,
|
||||||
R_GetFrameTime,
|
|
||||||
|
|
||||||
R_SetCurrentEntity,
|
|
||||||
R_SetCurrentModel,
|
|
||||||
|
|
||||||
|
GL_CreateTexture,
|
||||||
GL_FindTexture,
|
GL_FindTexture,
|
||||||
GL_TextureName,
|
GL_TextureName,
|
||||||
GL_TextureData,
|
GL_TextureData,
|
||||||
GL_LoadTexture,
|
GL_LoadTexture,
|
||||||
GL_CreateTexture,
|
|
||||||
GL_LoadTextureArray,
|
|
||||||
GL_CreateTextureArray,
|
|
||||||
GL_FreeTexture,
|
GL_FreeTexture,
|
||||||
R_OverrideTextureSourceSize,
|
R_OverrideTextureSourceSize,
|
||||||
|
|
||||||
DrawSingleDecal,
|
GL_UpdateTexture,
|
||||||
R_DecalSetupVerts,
|
|
||||||
R_EntityRemoveDecals,
|
|
||||||
|
|
||||||
R_UploadStretchRaw,
|
|
||||||
|
|
||||||
GL_Bind,
|
GL_Bind,
|
||||||
GL_SelectTexture,
|
|
||||||
GL_LoadTexMatrixExt,
|
|
||||||
GL_LoadIdentityTexMatrix,
|
|
||||||
GL_CleanUpTextureUnits,
|
|
||||||
GL_TexGen,
|
|
||||||
GL_TextureTarget,
|
|
||||||
GL_SetTexCoordArrayMode,
|
|
||||||
GL_UpdateTexSize,
|
|
||||||
|
|
||||||
CL_DrawParticlesExternal,
|
|
||||||
R_LightVec,
|
|
||||||
R_StudioGetTexture,
|
|
||||||
|
|
||||||
R_RenderFrame,
|
R_RenderFrame,
|
||||||
Mod_SetOrthoBounds,
|
Mod_SetOrthoBounds,
|
||||||
@@ -510,23 +518,19 @@ const ref_interface_t gReffuncs =
|
|||||||
Mod_GetCurrentVis,
|
Mod_GetCurrentVis,
|
||||||
R_NewMap,
|
R_NewMap,
|
||||||
R_ClearScene,
|
R_ClearScene,
|
||||||
R_GetProcAddress,
|
|
||||||
|
|
||||||
TriRenderMode,
|
TriRenderMode,
|
||||||
TriBegin,
|
TriBegin,
|
||||||
TriEnd,
|
TriEnd,
|
||||||
_TriColor4f,
|
_TriColor4f,
|
||||||
_TriColor4ub,
|
_TriColor4ub,
|
||||||
TriTexCoord2f,
|
|
||||||
TriVertex3fv,
|
TriVertex3fv,
|
||||||
TriVertex3f,
|
TriVertex3f,
|
||||||
TriFog,
|
|
||||||
R_ScreenToWorld,
|
|
||||||
TriGetMatrix,
|
|
||||||
TriFogParams,
|
|
||||||
TriCullFace,
|
TriCullFace,
|
||||||
|
|
||||||
|
R_FillRenderAPI,
|
||||||
|
R_FillTriAPI,
|
||||||
|
|
||||||
VGUI_SetupDrawing,
|
VGUI_SetupDrawing,
|
||||||
VGUI_UploadTextureBlock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -219,19 +219,10 @@ void Draw_Fill( int x, int y, int w, int h )
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_DrawStretchRaw
|
GL_UpdateTexture
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void GAME_EXPORT R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty )
|
void GAME_EXPORT GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt )
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
R_UploadStretchRaw
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
void GAME_EXPORT R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -877,7 +877,7 @@ static void D_TurbulentSurf( surf_t *s )
|
|||||||
// TODO: store once at start of frame
|
// TODO: store once at start of frame
|
||||||
RI.currententity = s->entity; // FIXME: make this passed in to
|
RI.currententity = s->entity; // FIXME: make this passed in to
|
||||||
// R_RotateBmodel ()
|
// R_RotateBmodel ()
|
||||||
VectorSubtract( RI.vieworg, RI.currententity->origin,
|
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin,
|
||||||
local_modelorg );
|
local_modelorg );
|
||||||
TransformVector( local_modelorg, transformed_modelorg );
|
TransformVector( local_modelorg, transformed_modelorg );
|
||||||
|
|
||||||
@@ -940,7 +940,7 @@ static void D_AlphaSurf( surf_t *s )
|
|||||||
// TODO: store once at start of frame
|
// TODO: store once at start of frame
|
||||||
RI.currententity = s->entity; // FIXME: make this passed in to
|
RI.currententity = s->entity; // FIXME: make this passed in to
|
||||||
// R_RotateBmodel ()
|
// R_RotateBmodel ()
|
||||||
VectorSubtract( RI.vieworg, RI.currententity->origin, local_modelorg );
|
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin, local_modelorg );
|
||||||
TransformVector( local_modelorg, transformed_modelorg );
|
TransformVector( local_modelorg, transformed_modelorg );
|
||||||
|
|
||||||
R_RotateBmodel(); // FIXME: don't mess with the frustum,
|
R_RotateBmodel(); // FIXME: don't mess with the frustum,
|
||||||
@@ -1021,7 +1021,7 @@ static void D_SolidSurf( surf_t *s )
|
|||||||
// TODO: store once at start of frame
|
// TODO: store once at start of frame
|
||||||
RI.currententity = s->entity; // FIXME: make this passed in to
|
RI.currententity = s->entity; // FIXME: make this passed in to
|
||||||
// R_RotateBmodel ()
|
// R_RotateBmodel ()
|
||||||
VectorSubtract( RI.vieworg, RI.currententity->origin, local_modelorg );
|
VectorSubtract( RI.rvp.vieworigin, RI.currententity->origin, local_modelorg );
|
||||||
TransformVector( local_modelorg, transformed_modelorg );
|
TransformVector( local_modelorg, transformed_modelorg );
|
||||||
|
|
||||||
R_RotateBmodel(); // FIXME: don't mess with the frustum,
|
R_RotateBmodel(); // FIXME: don't mess with the frustum,
|
||||||
@@ -1123,7 +1123,7 @@ void D_DrawSurfaces( void )
|
|||||||
surf_t *s;
|
surf_t *s;
|
||||||
|
|
||||||
// currententity = NULL; //&r_worldentity;
|
// currententity = NULL; //&r_worldentity;
|
||||||
VectorSubtract( RI.vieworg, vec3_origin, tr.modelorg );
|
VectorSubtract( RI.rvp.vieworigin, vec3_origin, tr.modelorg );
|
||||||
TransformVector( tr.modelorg, transformed_modelorg );
|
TransformVector( tr.modelorg, transformed_modelorg );
|
||||||
VectorCopy( transformed_modelorg, world_transformed_modelorg );
|
VectorCopy( transformed_modelorg, world_transformed_modelorg );
|
||||||
|
|
||||||
@@ -1148,7 +1148,7 @@ void D_DrawSurfaces( void )
|
|||||||
D_DrawflatSurfaces();
|
D_DrawflatSurfaces();
|
||||||
|
|
||||||
// RI.currententity = NULL; //&r_worldentity;
|
// RI.currententity = NULL; //&r_worldentity;
|
||||||
VectorSubtract( RI.vieworg, vec3_origin, tr.modelorg );
|
VectorSubtract( RI.rvp.vieworigin, vec3_origin, tr.modelorg );
|
||||||
R_TransformFrustum();
|
R_TransformFrustum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -659,7 +659,20 @@ int GAME_EXPORT GL_CreateTexture( const char *name, int width, int height, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GL_LoadTextureInternal( name, &r_empty, flags );
|
int texnum = GL_LoadTextureInternal( name, &r_empty, flags );
|
||||||
|
|
||||||
|
if( !Q_strcmp( name, REF_DEFAULT_TEXTURE ))
|
||||||
|
tr.defaultTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_PARTICLE_TEXTURE ))
|
||||||
|
tr.particleTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_WHITE_TEXTURE ))
|
||||||
|
tr.whiteTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_GRAY_TEXTURE ))
|
||||||
|
tr.grayTexture = texnum;
|
||||||
|
else if( !Q_strcmp( name, REF_BLACK_TEXTURE ))
|
||||||
|
tr.blackTexture = texnum;
|
||||||
|
|
||||||
|
return texnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -838,74 +851,6 @@ void R_InitDlightTexture( void )
|
|||||||
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP | TF_CLAMP | TF_ATLAS_PAGE );
|
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP | TF_CLAMP | TF_ATLAS_PAGE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
GL_CreateInternalTextures
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
static void GL_CreateInternalTextures( void )
|
|
||||||
{
|
|
||||||
int dx2, dy, d;
|
|
||||||
int x, y;
|
|
||||||
rgbdata_t *pic;
|
|
||||||
|
|
||||||
// emo-texture from quake1
|
|
||||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR );
|
|
||||||
|
|
||||||
for( y = 0; y < 16; y++ )
|
|
||||||
{
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
{
|
|
||||||
if(( y < 8 ) ^ ( x < 8 ))
|
|
||||||
((uint *)pic->buffer )[y * 16 + x] = 0xFFFF00FF;
|
|
||||||
else
|
|
||||||
((uint *)pic->buffer )[y * 16 + x] = 0xFF000000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// particle texture from quake1
|
|
||||||
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
|
|
||||||
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
{
|
|
||||||
dx2 = x - 8;
|
|
||||||
dx2 = dx2 * dx2;
|
|
||||||
|
|
||||||
for( y = 0; y < 16; y++ )
|
|
||||||
{
|
|
||||||
dy = y - 8;
|
|
||||||
d = 255 - 35 * sqrt( dx2 + dy * dy );
|
|
||||||
pic->buffer[( y * 16 + x ) * 4 + 3] = bound( 0, d, 255 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.particleTexture = GL_LoadTextureInternal( "*particle", pic, TF_CLAMP );
|
|
||||||
|
|
||||||
// white texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer )[x] = 0xFFFFFFFF;
|
|
||||||
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// gray texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer )[x] = 0xFF7F7F7F;
|
|
||||||
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// black texture
|
|
||||||
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
|
|
||||||
for( x = 0; x < 16; x++ )
|
|
||||||
((uint *)pic->buffer )[x] = 0xFF000000;
|
|
||||||
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
|
|
||||||
|
|
||||||
// cinematic dummy
|
|
||||||
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );
|
|
||||||
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP | TF_CLAMP );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_TextureList_f
|
R_TextureList_f
|
||||||
@@ -971,7 +916,6 @@ void R_InitImages( void )
|
|||||||
r_numImages = 1;
|
r_numImages = 1;
|
||||||
|
|
||||||
// validate cvars
|
// validate cvars
|
||||||
GL_CreateInternalTextures();
|
|
||||||
|
|
||||||
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
|
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,17 +61,9 @@ typedef int fixed16_t;
|
|||||||
#define SHADE_LAMBERT 1.4953241
|
#define SHADE_LAMBERT 1.4953241
|
||||||
#define DEFAULT_ALPHATEST 0.0f
|
#define DEFAULT_ALPHATEST 0.0f
|
||||||
|
|
||||||
// refparams
|
|
||||||
#define RP_NONE 0
|
|
||||||
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
|
|
||||||
#define RP_OLDVIEWLEAF BIT( 1 )
|
|
||||||
#define RP_CLIPPLANE BIT( 2 )
|
|
||||||
|
|
||||||
#define RP_NONVIEWERREF ( RP_ENVVIEW )
|
|
||||||
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
|
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
|
||||||
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
|
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
|
||||||
#define RP_LOCALCLIENT( e ) (( e ) != NULL && ( e )->index == ( gp_cl->playernum + 1 ) && e->player )
|
#define RP_LOCALCLIENT( e ) (( e ) != NULL && ( e )->index == ( gp_cl->playernum + 1 ) && e->player )
|
||||||
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
|
|
||||||
|
|
||||||
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
|
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
|
||||||
|
|
||||||
@@ -130,27 +122,16 @@ extern viddef_t vid;
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int params; // rendering parameters
|
ref_viewpass_t rvp;
|
||||||
|
|
||||||
qboolean drawWorld; // ignore world for drawing PlayerModel
|
|
||||||
qboolean isSkyVisible; // sky is visible
|
|
||||||
qboolean onlyClientDraw; // disabled by client request
|
|
||||||
qboolean drawOrtho; // draw world as orthogonal projection
|
|
||||||
|
|
||||||
float fov_x, fov_y; // current view fov
|
|
||||||
|
|
||||||
cl_entity_t *currententity;
|
cl_entity_t *currententity;
|
||||||
model_t *currentmodel;
|
model_t *currentmodel;
|
||||||
cl_entity_t *currentbeam; // same as above but for beams
|
cl_entity_t *currentbeam; // same as above but for beams
|
||||||
|
|
||||||
int viewport[4];
|
|
||||||
// gl_frustum_t frustum;
|
// gl_frustum_t frustum;
|
||||||
|
|
||||||
mleaf_t *viewleaf;
|
mleaf_t *viewleaf;
|
||||||
mleaf_t *oldviewleaf;
|
mleaf_t *oldviewleaf;
|
||||||
vec3_t pvsorigin;
|
|
||||||
vec3_t vieworg; // locked vieworigin
|
|
||||||
vec3_t viewangles;
|
|
||||||
vec3_t vforward;
|
vec3_t vforward;
|
||||||
vec3_t vright;
|
vec3_t vright;
|
||||||
vec3_t vup;
|
vec3_t vup;
|
||||||
@@ -224,7 +205,6 @@ typedef struct
|
|||||||
int lightmapTextures[MAX_LIGHTMAPS];
|
int lightmapTextures[MAX_LIGHTMAPS];
|
||||||
int dlightTexture; // custom dlight texture
|
int dlightTexture; // custom dlight texture
|
||||||
int skyboxTextures[6]; // skybox sides
|
int skyboxTextures[6]; // skybox sides
|
||||||
int cinTexture; // cinematic texture
|
|
||||||
|
|
||||||
// entity lists
|
// entity lists
|
||||||
draw_list_t draw_stack[MAX_DRAW_STACK];
|
draw_list_t draw_stack[MAX_DRAW_STACK];
|
||||||
@@ -336,7 +316,6 @@ typedef struct image_s
|
|||||||
// gl_beams.c
|
// gl_beams.c
|
||||||
//
|
//
|
||||||
void CL_DrawBeams( int fTrans, BEAM *active_beams );
|
void CL_DrawBeams( int fTrans, BEAM *active_beams );
|
||||||
qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// gl_decals.c
|
// gl_decals.c
|
||||||
@@ -355,7 +334,7 @@ void GL_Bind( int tmu, unsigned int texnum );
|
|||||||
// gl_draw.c
|
// gl_draw.c
|
||||||
//
|
//
|
||||||
void R_Set2DMode( qboolean enable );
|
void R_Set2DMode( qboolean enable );
|
||||||
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data ); //
|
void GL_UpdateTexture( int texnum, int cols, int rows, int width, int height, const byte *buffer, pixformat_t fmt );
|
||||||
|
|
||||||
// gl_image.c
|
// gl_image.c
|
||||||
//
|
//
|
||||||
@@ -420,11 +399,11 @@ struct mstudiotex_s *R_StudioGetTexture( cl_entity_t *e );
|
|||||||
int R_GetEntityRenderMode( cl_entity_t *ent );
|
int R_GetEntityRenderMode( cl_entity_t *ent );
|
||||||
void R_DrawStudioModel( cl_entity_t *e );
|
void R_DrawStudioModel( cl_entity_t *e );
|
||||||
player_info_t *pfnPlayerInfo( int index );
|
player_info_t *pfnPlayerInfo( int index );
|
||||||
void R_GatherPlayerLight( void );
|
|
||||||
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc, double time );
|
||||||
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
|
||||||
void R_StudioResetPlayerModels( void );
|
void R_StudioResetPlayerModels( void );
|
||||||
void CL_InitStudioAPI( void );
|
qboolean R_StudioFillAPI( struct engine_studio_api_s *api, struct r_studio_interface_s *pDefaultDraw );
|
||||||
|
void R_StudioSetDrawInterface( struct r_studio_interface_s *pDraw );
|
||||||
void Mod_StudioLoadTextures( model_t *mod, void *data );
|
void Mod_StudioLoadTextures( model_t *mod, void *data );
|
||||||
void Mod_StudioUnloadTextures( void *data );
|
void Mod_StudioUnloadTextures( void *data );
|
||||||
|
|
||||||
@@ -470,7 +449,6 @@ void R_RenderFrame( const struct ref_viewpass_s *vp );
|
|||||||
void R_EndFrame( void );
|
void R_EndFrame( void );
|
||||||
void R_ClearScene( void );
|
void R_ClearScene( void );
|
||||||
void R_GetTextureParms( int *w, int *h, int texnum );
|
void R_GetTextureParms( int *w, int *h, int texnum );
|
||||||
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
|
|
||||||
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
|
||||||
qboolean R_SpeedsMessage( char *out, size_t size );
|
qboolean R_SpeedsMessage( char *out, size_t size );
|
||||||
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
|
|||||||
{
|
{
|
||||||
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
|
VectorAverage( ent1->model->mins, ent1->model->maxs, org );
|
||||||
VectorAdd( ent1->origin, org, org );
|
VectorAdd( ent1->origin, org, org );
|
||||||
VectorSubtract( RI.vieworg, org, vecLen );
|
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
|
||||||
dist1 = DotProduct( vecLen, vecLen );
|
dist1 = DotProduct( vecLen, vecLen );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -182,7 +182,7 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
|
|||||||
{
|
{
|
||||||
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
|
VectorAverage( ent2->model->mins, ent2->model->maxs, org );
|
||||||
VectorAdd( ent2->origin, org, org );
|
VectorAdd( ent2->origin, org, org );
|
||||||
VectorSubtract( RI.vieworg, org, vecLen );
|
VectorSubtract( RI.rvp.vieworigin, org, vecLen );
|
||||||
dist2 = DotProduct( vecLen, vecLen );
|
dist2 = DotProduct( vecLen, vecLen );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -379,7 +379,7 @@ R_GetFarClip
|
|||||||
*/
|
*/
|
||||||
static float R_GetFarClip( void )
|
static float R_GetFarClip( void )
|
||||||
{
|
{
|
||||||
if( WORLDMODEL && RI.drawWorld )
|
if( WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return tr.movevars->zmax * 1.73f;
|
return tr.movevars->zmax * 1.73f;
|
||||||
return 2048.0f;
|
return 2048.0f;
|
||||||
}
|
}
|
||||||
@@ -392,10 +392,10 @@ R_SetupFrustum
|
|||||||
void R_SetupFrustum( void )
|
void R_SetupFrustum( void )
|
||||||
{
|
{
|
||||||
// build the transformation matrix for the given view angles
|
// build the transformation matrix for the given view angles
|
||||||
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
|
AngleVectors( RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup );
|
||||||
|
|
||||||
{
|
{
|
||||||
VectorCopy( RI.vieworg, RI.cullorigin );
|
VectorCopy( RI.rvp.vieworigin, RI.cullorigin );
|
||||||
VectorCopy( RI.vforward, RI.cull_vforward );
|
VectorCopy( RI.vforward, RI.cull_vforward );
|
||||||
VectorCopy( RI.vright, RI.cull_vright );
|
VectorCopy( RI.vright, RI.cull_vright );
|
||||||
VectorCopy( RI.vup, RI.cull_vup );
|
VectorCopy( RI.vup, RI.cull_vup );
|
||||||
@@ -411,22 +411,15 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
|
|||||||
{
|
{
|
||||||
float xMin, xMax, yMin, yMax, zNear, zFar;
|
float xMin, xMax, yMin, yMax, zNear, zFar;
|
||||||
|
|
||||||
if( RI.drawOrtho )
|
|
||||||
{
|
|
||||||
const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
|
||||||
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RI.farClip = R_GetFarClip();
|
RI.farClip = R_GetFarClip();
|
||||||
|
|
||||||
zNear = 4.0f;
|
zNear = 4.0f;
|
||||||
zFar = Q_max( 256.0f, RI.farClip );
|
zFar = Q_max( 256.0f, RI.farClip );
|
||||||
|
|
||||||
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
|
yMax = zNear * tan( RI.rvp.fov_y * M_PI_F / 360.0f );
|
||||||
yMin = -yMax;
|
yMin = -yMax;
|
||||||
|
|
||||||
xMax = zNear * tan( RI.fov_x * M_PI_F / 360.0f );
|
xMax = zNear * tan( RI.rvp.fov_x * M_PI_F / 360.0f );
|
||||||
xMin = -xMax;
|
xMin = -xMax;
|
||||||
|
|
||||||
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );
|
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );
|
||||||
@@ -440,10 +433,10 @@ R_SetupModelviewMatrix
|
|||||||
static void R_SetupModelviewMatrix( matrix4x4 m )
|
static void R_SetupModelviewMatrix( matrix4x4 m )
|
||||||
{
|
{
|
||||||
Matrix4x4_CreateModelview( m );
|
Matrix4x4_CreateModelview( m );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[2], 1, 0, 0 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[2], 1, 0, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[0], 0, 1, 0 );
|
||||||
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
|
Matrix4x4_ConcatRotate( m, -RI.rvp.viewangles[1], 0, 0, 1 );
|
||||||
Matrix4x4_ConcatTranslate( m, -RI.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
|
Matrix4x4_ConcatTranslate( m, -RI.rvp.vieworigin[0], -RI.rvp.vieworigin[1], -RI.rvp.vieworigin[2] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -481,7 +474,7 @@ R_FindViewLeaf
|
|||||||
void R_FindViewLeaf( void )
|
void R_FindViewLeaf( void )
|
||||||
{
|
{
|
||||||
RI.oldviewleaf = RI.viewleaf;
|
RI.oldviewleaf = RI.viewleaf;
|
||||||
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
|
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes, WORLDMODEL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -492,7 +485,7 @@ R_SetupFrame
|
|||||||
static void R_SetupFrame( void )
|
static void R_SetupFrame( void )
|
||||||
{
|
{
|
||||||
// setup viewplane dist
|
// setup viewplane dist
|
||||||
RI.viewplanedist = DotProduct( RI.vieworg, RI.vforward );
|
RI.viewplanedist = DotProduct( RI.rvp.vieworigin, RI.vforward );
|
||||||
|
|
||||||
// if( !gl_nosort->value )
|
// if( !gl_nosort->value )
|
||||||
{
|
{
|
||||||
@@ -501,11 +494,8 @@ static void R_SetupFrame( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// current viewleaf
|
// current viewleaf
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
|
||||||
RI.isSkyVisible = false; // unknown at this moment
|
|
||||||
R_FindViewLeaf();
|
R_FindViewLeaf();
|
||||||
}
|
|
||||||
|
|
||||||
// setup twice until globals fully refactored
|
// setup twice until globals fully refactored
|
||||||
R_SetupFrameQ();
|
R_SetupFrameQ();
|
||||||
@@ -527,7 +517,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
d_pdrawspans = R_PolysetFillSpans8;
|
d_pdrawspans = R_PolysetFillSpans8;
|
||||||
GL_SetRenderMode( kRenderNormal );
|
GL_SetRenderMode( kRenderNormal );
|
||||||
// first draw solid entities
|
// first draw solid entities
|
||||||
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->solid_entities[i];
|
RI.currententity = tr.draw_list->solid_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -555,7 +545,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
R_SetUpWorldTransform();
|
R_SetUpWorldTransform();
|
||||||
// draw sprites seperately, because of alpha blending
|
// draw sprites seperately, because of alpha blending
|
||||||
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_solid_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->solid_entities[i];
|
RI.currententity = tr.draw_list->solid_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -571,17 +561,17 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
{
|
{
|
||||||
gEngfuncs.CL_DrawEFX( tr.frametime, false );
|
gEngfuncs.CL_DrawEFX( tr.frametime, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
gEngfuncs.pfnDrawNormalTriangles();
|
gEngfuncs.pfnDrawNormalTriangles();
|
||||||
|
|
||||||
d_pdrawspans = R_PolysetDrawSpans8_33;
|
d_pdrawspans = R_PolysetDrawSpans8_33;
|
||||||
// then draw translucent entities
|
// then draw translucent entities
|
||||||
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_trans_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
RI.currententity = tr.draw_list->trans_entities[i];
|
RI.currententity = tr.draw_list->trans_entities[i];
|
||||||
RI.currentmodel = RI.currententity->model;
|
RI.currentmodel = RI.currententity->model;
|
||||||
@@ -619,12 +609,10 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
|
||||||
gEngfuncs.pfnDrawTransparentTriangles();
|
gEngfuncs.pfnDrawTransparentTriangles();
|
||||||
}
|
|
||||||
|
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
{
|
{
|
||||||
R_AllowFog( false );
|
R_AllowFog( false );
|
||||||
gEngfuncs.CL_DrawEFX( tr.frametime, true );
|
gEngfuncs.CL_DrawEFX( tr.frametime, true );
|
||||||
@@ -633,7 +621,7 @@ static void R_DrawEntitiesOnList( void )
|
|||||||
|
|
||||||
GL_SetRenderMode( kRenderNormal );
|
GL_SetRenderMode( kRenderNormal );
|
||||||
R_SetUpWorldTransform();
|
R_SetUpWorldTransform();
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
R_DrawViewModel();
|
R_DrawViewModel();
|
||||||
gEngfuncs.CL_ExtraUpdate();
|
gEngfuncs.CL_ExtraUpdate();
|
||||||
|
|
||||||
@@ -804,7 +792,7 @@ static void R_DrawBEntitiesOnList( void )
|
|||||||
VectorCopy( tr.modelorg, oldorigin );
|
VectorCopy( tr.modelorg, oldorigin );
|
||||||
insubmodel = true;
|
insubmodel = true;
|
||||||
|
|
||||||
for( i = 0; i < tr.draw_list->num_edge_entities && !RI.onlyClientDraw; i++ )
|
for( i = 0; i < tr.draw_list->num_edge_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
RI.currententity = tr.draw_list->edge_entities[i];
|
RI.currententity = tr.draw_list->edge_entities[i];
|
||||||
@@ -832,7 +820,7 @@ static void R_DrawBEntitiesOnList( void )
|
|||||||
continue; // no part in a visible leaf
|
continue; // no part in a visible leaf
|
||||||
|
|
||||||
VectorCopy( RI.currententity->origin, r_entorigin );
|
VectorCopy( RI.currententity->origin, r_entorigin );
|
||||||
VectorSubtract( RI.vieworg, r_entorigin, tr.modelorg );
|
VectorSubtract( RI.rvp.vieworigin, r_entorigin, tr.modelorg );
|
||||||
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
|
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
|
||||||
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
||||||
|
|
||||||
@@ -890,7 +878,7 @@ void R_DrawBrushModel( cl_entity_t *pent )
|
|||||||
surf_t lsurfs[NUMSTACKSURFACES
|
surf_t lsurfs[NUMSTACKSURFACES
|
||||||
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
||||||
|
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( auxedges )
|
if( auxedges )
|
||||||
@@ -944,7 +932,7 @@ void R_DrawBrushModel( cl_entity_t *pent )
|
|||||||
|
|
||||||
alphaspans = true;
|
alphaspans = true;
|
||||||
VectorCopy( RI.currententity->origin, r_entorigin );
|
VectorCopy( RI.currententity->origin, r_entorigin );
|
||||||
VectorSubtract( RI.vieworg, r_entorigin, tr.modelorg );
|
VectorSubtract( RI.rvp.vieworigin, r_entorigin, tr.modelorg );
|
||||||
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
|
// VectorSubtract (r_origin, RI.currententity->origin, modelorg);
|
||||||
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
r_pcurrentvertbase = RI.currentmodel->vertexes;
|
||||||
|
|
||||||
@@ -998,7 +986,7 @@ static void R_EdgeDrawing( void )
|
|||||||
surf_t lsurfs[NUMSTACKSURFACES
|
surf_t lsurfs[NUMSTACKSURFACES
|
||||||
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
+ (( CACHE_SIZE - 1 ) / sizeof( surf_t )) + 1];
|
||||||
|
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( auxedges )
|
if( auxedges )
|
||||||
@@ -1053,7 +1041,7 @@ static void R_MarkLeaves( void )
|
|||||||
tr.visframecount++;
|
tr.visframecount++;
|
||||||
r_oldviewcluster = r_viewcluster;
|
r_oldviewcluster = r_viewcluster;
|
||||||
|
|
||||||
gEngfuncs.R_FatPVS( RI.pvsorigin, r_pvs_radius->value, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), false );
|
gEngfuncs.R_FatPVS( RI.rvp.vieworigin, r_pvs_radius->value, RI.visbytes, false, false );
|
||||||
vis = RI.visbytes;
|
vis = RI.visbytes;
|
||||||
|
|
||||||
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
||||||
@@ -1082,14 +1070,11 @@ R_SetupRefParams must be called right before
|
|||||||
*/
|
*/
|
||||||
void GAME_EXPORT R_RenderScene( void )
|
void GAME_EXPORT R_RenderScene( void )
|
||||||
{
|
{
|
||||||
if( !WORLDMODEL && RI.drawWorld )
|
if( !WORLDMODEL && FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
|
gEngfuncs.Host_Error( "%s: NULL worldmodel\n", __func__ );
|
||||||
|
|
||||||
// frametime is valid only for normal pass
|
// frametime is valid only for normal pass
|
||||||
if( RP_NORMALPASS( ))
|
|
||||||
tr.frametime = gp_cl->time - gp_cl->oldtime;
|
tr.frametime = gp_cl->time - gp_cl->oldtime;
|
||||||
else
|
|
||||||
tr.frametime = 0.0;
|
|
||||||
|
|
||||||
// begin a new frame
|
// begin a new frame
|
||||||
tr.framecount++;
|
tr.framecount++;
|
||||||
@@ -1160,28 +1145,7 @@ set initial params for renderer
|
|||||||
*/
|
*/
|
||||||
void R_SetupRefParams( const ref_viewpass_t *rvp )
|
void R_SetupRefParams( const ref_viewpass_t *rvp )
|
||||||
{
|
{
|
||||||
RI.params = RP_NONE;
|
RI.rvp = *rvp;
|
||||||
RI.drawWorld = FBitSet( rvp->flags, RF_DRAW_WORLD );
|
|
||||||
RI.onlyClientDraw = FBitSet( rvp->flags, RF_ONLY_CLIENTDRAW );
|
|
||||||
|
|
||||||
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
|
|
||||||
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
|
|
||||||
else
|
|
||||||
RI.drawOrtho = false;
|
|
||||||
|
|
||||||
// setup viewport
|
|
||||||
RI.viewport[0] = rvp->viewport[0];
|
|
||||||
RI.viewport[1] = rvp->viewport[1];
|
|
||||||
RI.viewport[2] = rvp->viewport[2];
|
|
||||||
RI.viewport[3] = rvp->viewport[3];
|
|
||||||
|
|
||||||
// calc FOV
|
|
||||||
RI.fov_x = rvp->fov_x;
|
|
||||||
RI.fov_y = rvp->fov_y;
|
|
||||||
|
|
||||||
VectorCopy( rvp->vieworigin, RI.vieworg );
|
|
||||||
VectorCopy( rvp->viewangles, RI.viewangles );
|
|
||||||
VectorCopy( rvp->vieworigin, RI.pvsorigin );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1208,7 +1172,7 @@ void GAME_EXPORT R_RenderFrame( const ref_viewpass_t *rvp )
|
|||||||
|
|
||||||
if( gEngfuncs.drawFuncs->GL_RenderFrame( rvp ))
|
if( gEngfuncs.drawFuncs->GL_RenderFrame( rvp ))
|
||||||
{
|
{
|
||||||
// R_GatherPlayerLight();
|
// R_GatherPlayerLight( tr.viewent );
|
||||||
tr.realframecount++;
|
tr.realframecount++;
|
||||||
tr.fResetVis = true;
|
tr.fResetVis = true;
|
||||||
return;
|
return;
|
||||||
@@ -1216,7 +1180,7 @@ void GAME_EXPORT R_RenderFrame( const ref_viewpass_t *rvp )
|
|||||||
}
|
}
|
||||||
|
|
||||||
tr.fCustomRendering = false;
|
tr.fCustomRendering = false;
|
||||||
if( !RI.onlyClientDraw )
|
if( !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ))
|
||||||
R_RunViewmodelEvents();
|
R_RunViewmodelEvents();
|
||||||
|
|
||||||
tr.realframecount++; // right called after viewmodel events
|
tr.realframecount++; // right called after viewmodel events
|
||||||
@@ -1482,43 +1446,31 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
|
blend = e->curstate.renderamt + 0x10 * sin( gp_cl->time * 8 + offset );
|
||||||
break;
|
break;
|
||||||
case kRenderFxFadeSlow:
|
case kRenderFxFadeSlow:
|
||||||
if( RP_NORMALPASS( ))
|
|
||||||
{
|
|
||||||
if( e->curstate.renderamt > 0 )
|
if( e->curstate.renderamt > 0 )
|
||||||
e->curstate.renderamt -= 1;
|
e->curstate.renderamt -= 1;
|
||||||
else
|
else
|
||||||
e->curstate.renderamt = 0;
|
e->curstate.renderamt = 0;
|
||||||
}
|
|
||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxFadeFast:
|
case kRenderFxFadeFast:
|
||||||
if( RP_NORMALPASS( ))
|
|
||||||
{
|
|
||||||
if( e->curstate.renderamt > 3 )
|
if( e->curstate.renderamt > 3 )
|
||||||
e->curstate.renderamt -= 4;
|
e->curstate.renderamt -= 4;
|
||||||
else
|
else
|
||||||
e->curstate.renderamt = 0;
|
e->curstate.renderamt = 0;
|
||||||
}
|
|
||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxSolidSlow:
|
case kRenderFxSolidSlow:
|
||||||
if( RP_NORMALPASS( ))
|
|
||||||
{
|
|
||||||
if( e->curstate.renderamt < 255 )
|
if( e->curstate.renderamt < 255 )
|
||||||
e->curstate.renderamt += 1;
|
e->curstate.renderamt += 1;
|
||||||
else
|
else
|
||||||
e->curstate.renderamt = 255;
|
e->curstate.renderamt = 255;
|
||||||
}
|
|
||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxSolidFast:
|
case kRenderFxSolidFast:
|
||||||
if( RP_NORMALPASS( ))
|
|
||||||
{
|
|
||||||
if( e->curstate.renderamt < 252 )
|
if( e->curstate.renderamt < 252 )
|
||||||
e->curstate.renderamt += 4;
|
e->curstate.renderamt += 4;
|
||||||
else
|
else
|
||||||
e->curstate.renderamt = 255;
|
e->curstate.renderamt = 255;
|
||||||
}
|
|
||||||
blend = e->curstate.renderamt;
|
blend = e->curstate.renderamt;
|
||||||
break;
|
break;
|
||||||
case kRenderFxStrobeSlow:
|
case kRenderFxStrobeSlow:
|
||||||
@@ -1559,7 +1511,7 @@ int CL_FxBlend( cl_entity_t *e )
|
|||||||
case kRenderFxHologram:
|
case kRenderFxHologram:
|
||||||
case kRenderFxDistort:
|
case kRenderFxDistort:
|
||||||
VectorCopy( e->origin, tmp );
|
VectorCopy( e->origin, tmp );
|
||||||
VectorSubtract( tmp, RI.vieworg, tmp );
|
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
|
||||||
dist = DotProduct( tmp, RI.vforward );
|
dist = DotProduct( tmp, RI.vforward );
|
||||||
|
|
||||||
// turn off distance fade
|
// turn off distance fade
|
||||||
|
|||||||
@@ -87,10 +87,8 @@ void D_ViewChanged( void )
|
|||||||
/*
|
/*
|
||||||
** clear Z-buffer and color-buffers if we're doing the gallery
|
** clear Z-buffer and color-buffers if we're doing the gallery
|
||||||
*/
|
*/
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
|
||||||
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ));
|
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ));
|
||||||
}
|
|
||||||
|
|
||||||
D_Patch();
|
D_Patch();
|
||||||
}
|
}
|
||||||
@@ -184,8 +182,8 @@ static void R_ViewChanged( vrect_t *vr )
|
|||||||
|
|
||||||
RI.vrect = *vr;
|
RI.vrect = *vr;
|
||||||
|
|
||||||
horizontalFieldOfView = 2 * tan((float)RI.fov_x / 360.0f * M_PI_F );
|
horizontalFieldOfView = 2 * tan((float)RI.rvp.fov_x / 360.0f * M_PI_F );
|
||||||
verticalFieldOfView = 2 * tan((float)RI.fov_y / 360.0f * M_PI_F );
|
verticalFieldOfView = 2 * tan((float)RI.rvp.fov_y / 360.0f * M_PI_F );
|
||||||
|
|
||||||
RI.fvrectx = (float)RI.vrect.x;
|
RI.fvrectx = (float)RI.vrect.x;
|
||||||
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
|
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
|
||||||
@@ -288,14 +286,14 @@ void R_SetupFrameQ( void )
|
|||||||
|
|
||||||
|
|
||||||
// build the transformation matrix for the given view angles
|
// build the transformation matrix for the given view angles
|
||||||
VectorCopy( RI.vieworg, tr.modelorg );
|
VectorCopy( RI.rvp.vieworigin, tr.modelorg );
|
||||||
|
|
||||||
// AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
|
// AngleVectors (RI.rvp.viewangles, RI.vforward, RI.vright, RI.vup);
|
||||||
|
|
||||||
// current viewleaf
|
// current viewleaf
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.vieworg, WORLDMODEL->nodes );
|
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.rvp.vieworigin, WORLDMODEL->nodes, WORLDMODEL );
|
||||||
r_viewcluster = RI.viewleaf->cluster;
|
r_viewcluster = RI.viewleaf->cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,10 +305,10 @@ void R_SetupFrameQ( void )
|
|||||||
vrect.y = 0;//r_newrefdef.y;
|
vrect.y = 0;//r_newrefdef.y;
|
||||||
vrect.width = gpGlobals->width;
|
vrect.width = gpGlobals->width;
|
||||||
vrect.height = gpGlobals->height;*/
|
vrect.height = gpGlobals->height;*/
|
||||||
vrect.x = RI.viewport[0];
|
vrect.x = RI.rvp.viewport[0];
|
||||||
vrect.y = RI.viewport[1];
|
vrect.y = RI.rvp.viewport[1];
|
||||||
vrect.width = RI.viewport[2];
|
vrect.width = RI.rvp.viewport[2];
|
||||||
vrect.height = RI.viewport[3];
|
vrect.height = RI.rvp.viewport[3];
|
||||||
|
|
||||||
d_viewbuffer = (void *)vid.buffer;
|
d_viewbuffer = (void *)vid.buffer;
|
||||||
r_screenwidth = vid.rowbytes;
|
r_screenwidth = vid.rowbytes;
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
|
|||||||
size = partsize; // get initial size of particle
|
size = partsize; // get initial size of particle
|
||||||
|
|
||||||
// scale up to keep particles from disappearing
|
// scale up to keep particles from disappearing
|
||||||
size += ( p->org[0] - RI.vieworg[0] ) * RI.cull_vforward[0];
|
size += ( p->org[0] - RI.rvp.vieworigin[0] ) * RI.cull_vforward[0];
|
||||||
size += ( p->org[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
|
size += ( p->org[1] - RI.rvp.vieworigin[1] ) * RI.cull_vforward[1];
|
||||||
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
|
size += ( p->org[2] - RI.rvp.vieworigin[2] ) * RI.cull_vforward[2];
|
||||||
|
|
||||||
if( size < 20.0f )
|
if( size < 20.0f )
|
||||||
size = partsize;
|
size = partsize;
|
||||||
|
|||||||
@@ -65,16 +65,12 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
|
|||||||
float dist, brightness;
|
float dist, brightness;
|
||||||
vec3_t glowDist;
|
vec3_t glowDist;
|
||||||
|
|
||||||
VectorSubtract( origin, RI.vieworg, glowDist );
|
VectorSubtract( origin, RI.rvp.vieworigin, glowDist );
|
||||||
dist = VectorLength( glowDist );
|
dist = VectorLength( glowDist );
|
||||||
|
|
||||||
if( RP_NORMALPASS( ))
|
pmtrace_t *tr = gEngfuncs.EV_VisTraceLine( RI.rvp.vieworigin, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
|
||||||
{
|
|
||||||
pmtrace_t *tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
|
|
||||||
|
|
||||||
if(( 1.0f - tr->fraction ) * dist > 8.0f )
|
if(( 1.0f - tr->fraction ) * dist > 8.0f )
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
|
||||||
|
|
||||||
if( renderfx == kRenderFxNoDissipation )
|
if( renderfx == kRenderFxNoDissipation )
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
@@ -102,9 +98,9 @@ static qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
|
|||||||
|
|
||||||
TriWorldToScreen( origin, v );
|
TriWorldToScreen( origin, v );
|
||||||
|
|
||||||
if( v[0] < RI.viewport[0] || v[0] > RI.viewport[0] + RI.viewport[2] )
|
if( v[0] < RI.rvp.viewport[0] || v[0] > RI.rvp.viewport[0] + RI.rvp.viewport[2] )
|
||||||
return true; // do scissor
|
return true; // do scissor
|
||||||
if( v[1] < RI.viewport[1] || v[1] > RI.viewport[1] + RI.viewport[3] )
|
if( v[1] < RI.rvp.viewport[1] || v[1] > RI.rvp.viewport[1] + RI.rvp.viewport[3] )
|
||||||
return true; // do scissor
|
return true; // do scissor
|
||||||
|
|
||||||
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
|
blend = R_SpriteGlowBlend( origin, e->curstate.rendermode, e->curstate.renderfx, pscale );
|
||||||
@@ -172,9 +168,6 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||||||
vec3_t v_forward, v_right, v_up;
|
vec3_t v_forward, v_right, v_up;
|
||||||
vec3_t origin, color;
|
vec3_t origin, color;
|
||||||
|
|
||||||
if( RI.params & RP_ENVVIEW )
|
|
||||||
return;
|
|
||||||
|
|
||||||
model = e->model;
|
model = e->model;
|
||||||
psprite = (msprite_t *)model->cache.data;
|
psprite = (msprite_t *)model->cache.data;
|
||||||
VectorCopy( e->origin, origin ); // set render origin
|
VectorCopy( e->origin, origin ); // set render origin
|
||||||
@@ -242,7 +235,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
|
|||||||
VectorSubtract( origin, v_forward, origin );
|
VectorSubtract( origin, v_forward, origin );
|
||||||
break;
|
break;
|
||||||
case SPR_FACING_UPRIGHT:
|
case SPR_FACING_UPRIGHT:
|
||||||
VectorSet( v_right, origin[1] - RI.vieworg[1], -( origin[0] - RI.vieworg[0] ), 0.0f );
|
VectorSet( v_right, origin[1] - RI.rvp.vieworigin[1], -( origin[0] - RI.rvp.vieworigin[0] ), 0.0f );
|
||||||
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
|
||||||
VectorNormalize( v_right );
|
VectorNormalize( v_right );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ init current time for a given model
|
|||||||
*/
|
*/
|
||||||
static void R_StudioSetupTimings( void )
|
static void R_StudioSetupTimings( void )
|
||||||
{
|
{
|
||||||
if( RI.drawWorld )
|
if( FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
// synchronize with server time
|
// synchronize with server time
|
||||||
g_studio.time = gp_cl->time;
|
g_studio.time = gp_cl->time;
|
||||||
@@ -353,23 +353,12 @@ pfnPlayerInfo
|
|||||||
*/
|
*/
|
||||||
player_info_t *pfnPlayerInfo( int index )
|
player_info_t *pfnPlayerInfo( int index )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
index = -1;
|
index = -1;
|
||||||
|
|
||||||
return gEngfuncs.pfnPlayerInfo( index );
|
return gEngfuncs.pfnPlayerInfo( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnMod_ForName
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static model_t *pfnMod_ForName( const char *model, int crash )
|
|
||||||
{
|
|
||||||
return gEngfuncs.Mod_ForName( model, crash, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetPlayerState
|
pfnGetPlayerState
|
||||||
@@ -378,23 +367,12 @@ pfnGetPlayerState
|
|||||||
*/
|
*/
|
||||||
static entity_state_t *R_StudioGetPlayerState( int index )
|
static entity_state_t *R_StudioGetPlayerState( int index )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
return &RI.currententity->curstate;
|
return &RI.currententity->curstate;
|
||||||
|
|
||||||
return gEngfuncs.pfnGetPlayerState( index );
|
return gEngfuncs.pfnGetPlayerState( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnGetViewEntity
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static cl_entity_t *pfnGetViewEntity( void )
|
|
||||||
{
|
|
||||||
return tr.viewent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetEngineTimes
|
pfnGetEngineTimes
|
||||||
@@ -420,7 +398,7 @@ pfnGetViewInfo
|
|||||||
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
|
static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *forwardv )
|
||||||
{
|
{
|
||||||
if( origin )
|
if( origin )
|
||||||
VectorCopy( RI.vieworg, origin );
|
VectorCopy( RI.rvp.vieworigin, origin );
|
||||||
if( forwardv )
|
if( forwardv )
|
||||||
VectorCopy( RI.vforward, forwardv );
|
VectorCopy( RI.vforward, forwardv );
|
||||||
if( rightv )
|
if( rightv )
|
||||||
@@ -429,17 +407,6 @@ static void pfnGetViewInfo( float *origin, float *upv, float *rightv, float *for
|
|||||||
VectorCopy( RI.vup, upv );
|
VectorCopy( RI.vup, upv );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
R_GetChromeSprite
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static model_t *R_GetChromeSprite( void )
|
|
||||||
{
|
|
||||||
return gEngfuncs.GetDefaultSprite( REF_CHROME_SPRITE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnGetModelCounters
|
pfnGetModelCounters
|
||||||
@@ -452,20 +419,6 @@ static void pfnGetModelCounters( int **s, int **a )
|
|||||||
*a = &r_stats.c_studio_models_drawn;
|
*a = &r_stats.c_studio_models_drawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnGetAliasScale
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static void pfnGetAliasScale( float *x, float *y )
|
|
||||||
{
|
|
||||||
if( x )
|
|
||||||
*x = 1.0f;
|
|
||||||
if( y )
|
|
||||||
*y = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnStudioGetBoneTransform
|
pfnStudioGetBoneTransform
|
||||||
@@ -488,17 +441,6 @@ static float ****pfnStudioGetLightTransform( void )
|
|||||||
return (float ****)g_studio.lighttransform;
|
return (float ****)g_studio.lighttransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnStudioGetAliasTransform
|
|
||||||
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static float ***pfnStudioGetAliasTransform( void )
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
pfnStudioGetRotationMatrix
|
pfnStudioGetRotationMatrix
|
||||||
@@ -1352,7 +1294,7 @@ static void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
|
|||||||
if( !plight || !ent || !ent->model )
|
if( !plight || !ent || !ent->model )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !RI.drawWorld || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ) || r_fullbright->value || FBitSet( ent->curstate.effects, EF_FULLBRIGHT ))
|
||||||
{
|
{
|
||||||
plight->shadelight = 0;
|
plight->shadelight = 0;
|
||||||
plight->ambientlight = 192;
|
plight->ambientlight = 192;
|
||||||
@@ -2333,7 +2275,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
|
|||||||
state = &g_studio.player_models[index];
|
state = &g_studio.player_models[index];
|
||||||
|
|
||||||
// g-cont: force for "dev-mode", non-local games and menu preview
|
// g-cont: force for "dev-mode", non-local games and menu preview
|
||||||
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !RI.drawWorld ) && info->model[0] )
|
if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )) && info->model[0] )
|
||||||
{
|
{
|
||||||
if( Q_strcmp( state->name, info->model ))
|
if( Q_strcmp( state->name, info->model ))
|
||||||
{
|
{
|
||||||
@@ -2572,19 +2514,7 @@ R_StudioSetChromeOrigin
|
|||||||
*/
|
*/
|
||||||
static void R_StudioSetChromeOrigin( void )
|
static void R_StudioSetChromeOrigin( void )
|
||||||
{
|
{
|
||||||
VectorCopy( RI.vieworg, g_studio.chrome_origin );
|
VectorCopy( RI.rvp.vieworigin, g_studio.chrome_origin );
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
pfnIsHardware
|
|
||||||
|
|
||||||
Xash3D is always works in hardware mode
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static int pfnIsHardware( void )
|
|
||||||
{
|
|
||||||
return 1; // 0 is Software, 1 is OpenGL, 2 is Direct3D
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2683,7 +2613,7 @@ static void R_StudioRenderModel( void )
|
|||||||
R_StudioRenderFinal( );
|
R_StudioRenderFinal( );
|
||||||
|
|
||||||
R_StudioSetForceFaceFlags( STUDIO_NF_CHROME );
|
R_StudioSetForceFaceFlags( STUDIO_NF_CHROME );
|
||||||
TriSpriteTexture( R_GetChromeSprite(), 0 );
|
TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_CHROME_SPRITE ), 0 );
|
||||||
RI.currententity->curstate.renderfx = kRenderFxGlowShell;
|
RI.currententity->curstate.renderfx = kRenderFxGlowShell;
|
||||||
|
|
||||||
R_StudioRenderFinal( );
|
R_StudioRenderFinal( );
|
||||||
@@ -2926,7 +2856,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
|
|||||||
if( flags & STUDIO_RENDER )
|
if( flags & STUDIO_RENDER )
|
||||||
{
|
{
|
||||||
// change body if it's a menu entity
|
// change body if it's a menu entity
|
||||||
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !RI.drawWorld ))
|
if( cl_himodels->value && ( RI.currentmodel != RI.currententity->model || !FBitSet( RI.rvp.flags, RF_DRAW_WORLD )))
|
||||||
{
|
{
|
||||||
// show highest resolution multiplayer model
|
// show highest resolution multiplayer model
|
||||||
RI.currententity->curstate.body = 255;
|
RI.currententity->curstate.body = 255;
|
||||||
@@ -3087,7 +3017,7 @@ R_StudioDrawModelInternal
|
|||||||
*/
|
*/
|
||||||
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
|
static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
|
||||||
{
|
{
|
||||||
if( !RI.drawWorld )
|
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
|
||||||
{
|
{
|
||||||
if( e->player )
|
if( e->player )
|
||||||
R_StudioDrawPlayer( flags, &e->curstate );
|
R_StudioDrawPlayer( flags, &e->curstate );
|
||||||
@@ -3124,9 +3054,6 @@ R_DrawStudioModel
|
|||||||
*/
|
*/
|
||||||
void R_DrawStudioModel( cl_entity_t *e )
|
void R_DrawStudioModel( cl_entity_t *e )
|
||||||
{
|
{
|
||||||
if( FBitSet( RI.params, RP_ENVVIEW ))
|
|
||||||
return;
|
|
||||||
|
|
||||||
R_StudioSetupTimings();
|
R_StudioSetupTimings();
|
||||||
|
|
||||||
if( e->player )
|
if( e->player )
|
||||||
@@ -3180,7 +3107,7 @@ void R_RunViewmodelEvents( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ignore in thirdperson, camera view or client is died
|
// ignore in thirdperson, camera view or client is died
|
||||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
if( ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RI.currententity = tr.viewent;
|
RI.currententity = tr.viewent;
|
||||||
@@ -3198,20 +3125,6 @@ void R_RunViewmodelEvents( void )
|
|||||||
R_StudioDrawModelInternal( RI.currententity, STUDIO_EVENTS );
|
R_StudioDrawModelInternal( RI.currententity, STUDIO_EVENTS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
R_GatherPlayerLight
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void R_GatherPlayerLight( void )
|
|
||||||
{
|
|
||||||
cl_entity_t *view = tr.viewent;
|
|
||||||
colorVec c;
|
|
||||||
|
|
||||||
c = R_LightPoint( view->origin );
|
|
||||||
gEngfuncs.SetLocalLightLevel(( c.r + c.g + c.b ) / 3 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
R_DrawViewModel
|
R_DrawViewModel
|
||||||
@@ -3221,7 +3134,7 @@ void R_DrawViewModel( void )
|
|||||||
{
|
{
|
||||||
cl_entity_t *view = tr.viewent;
|
cl_entity_t *view = tr.viewent;
|
||||||
|
|
||||||
R_GatherPlayerLight();
|
R_GatherPlayerLight( view );
|
||||||
|
|
||||||
if( r_drawviewmodel->value == 0 )
|
if( r_drawviewmodel->value == 0 )
|
||||||
return;
|
return;
|
||||||
@@ -3230,7 +3143,7 @@ void R_DrawViewModel( void )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// ignore in thirdperson, camera view or client is died
|
// ignore in thirdperson, camera view or client is died
|
||||||
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
if( ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tr.blend = CL_FxBlend( view ) / 255.0f;
|
tr.blend = CL_FxBlend( view ) / 255.0f;
|
||||||
@@ -3418,113 +3331,53 @@ void Mod_StudioUnloadTextures( void *data )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static model_t *pfnModelHandle( int modelindex )
|
qboolean R_StudioFillAPI( engine_studio_api_t *api, r_studio_interface_t *pDefaultDraw )
|
||||||
{
|
{
|
||||||
return CL_ModelHandle( modelindex );
|
|
||||||
}
|
|
||||||
|
|
||||||
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 =
|
|
||||||
{
|
|
||||||
pfnMod_Calloc,
|
|
||||||
pfnMod_CacheCheck,
|
|
||||||
pfnMod_LoadCacheFile,
|
|
||||||
pfnMod_ForName,
|
|
||||||
pfnMod_StudioExtradata,
|
|
||||||
pfnModelHandle,
|
|
||||||
pfnGetCurrentEntity,
|
|
||||||
pfnPlayerInfo,
|
|
||||||
R_StudioGetPlayerState,
|
|
||||||
pfnGetViewEntity,
|
|
||||||
pfnGetEngineTimes,
|
|
||||||
pfnGetCvarPointer,
|
|
||||||
pfnGetViewInfo,
|
|
||||||
R_GetChromeSprite,
|
|
||||||
pfnGetModelCounters,
|
|
||||||
pfnGetAliasScale,
|
|
||||||
pfnStudioGetBoneTransform,
|
|
||||||
pfnStudioGetLightTransform,
|
|
||||||
pfnStudioGetAliasTransform,
|
|
||||||
pfnStudioGetRotationMatrix,
|
|
||||||
R_StudioSetupModel,
|
|
||||||
R_StudioCheckBBox,
|
|
||||||
R_StudioDynamicLight,
|
|
||||||
R_StudioEntityLight,
|
|
||||||
R_StudioSetupLighting,
|
|
||||||
R_StudioDrawPoints,
|
|
||||||
R_StudioDrawHulls,
|
|
||||||
R_StudioDrawAbsBBox,
|
|
||||||
R_StudioDrawBones,
|
|
||||||
(void *)R_StudioSetupSkin,
|
|
||||||
R_StudioSetRemapColors,
|
|
||||||
R_StudioSetupPlayerModel,
|
|
||||||
R_StudioClientEvents,
|
|
||||||
R_StudioGetForceFaceFlags,
|
|
||||||
R_StudioSetForceFaceFlags,
|
|
||||||
(void *)R_StudioSetHeader,
|
|
||||||
R_StudioSetRenderModel,
|
|
||||||
R_StudioSetupRenderer,
|
|
||||||
R_StudioRestoreRenderer,
|
|
||||||
R_StudioSetChromeOrigin,
|
|
||||||
pfnIsHardware,
|
|
||||||
GL_StudioDrawShadow,
|
|
||||||
GL_StudioSetRenderMode,
|
|
||||||
R_StudioSetRenderamt,
|
|
||||||
R_StudioSetCullState,
|
|
||||||
R_StudioRenderShadow,
|
|
||||||
};
|
|
||||||
|
|
||||||
static r_studio_interface_t gStudioDraw =
|
|
||||||
{
|
|
||||||
STUDIO_INTERFACE_VERSION,
|
|
||||||
R_StudioDrawModel,
|
|
||||||
R_StudioDrawPlayer,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
CL_InitStudioAPI
|
|
||||||
|
|
||||||
Initialize client studio
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void GAME_EXPORT CL_InitStudioAPI( void )
|
|
||||||
{
|
|
||||||
pStudioDraw = &gStudioDraw;
|
|
||||||
|
|
||||||
// trying to grab them from client.dll
|
|
||||||
cl_righthand = gEngfuncs.pfnGetCvarPointer( "cl_righthand" );
|
cl_righthand = gEngfuncs.pfnGetCvarPointer( "cl_righthand" );
|
||||||
|
|
||||||
// Xash will be used internal StudioModelRenderer
|
api->GetCurrentEntity = pfnGetCurrentEntity;
|
||||||
if( gEngfuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI ))
|
api->PlayerInfo = pfnPlayerInfo;
|
||||||
return;
|
api->GetPlayerState = R_StudioGetPlayerState;
|
||||||
|
api->GetTimes = pfnGetEngineTimes;
|
||||||
|
api->GetViewInfo = pfnGetViewInfo;
|
||||||
|
api->GetModelCounters = pfnGetModelCounters;
|
||||||
|
api->StudioGetBoneTransform = pfnStudioGetBoneTransform;
|
||||||
|
api->StudioGetLightTransform = pfnStudioGetLightTransform;
|
||||||
|
api->StudioGetRotationMatrix = pfnStudioGetRotationMatrix;
|
||||||
|
api->StudioSetupModel = R_StudioSetupModel;
|
||||||
|
api->StudioCheckBBox = R_StudioCheckBBox;
|
||||||
|
api->StudioDynamicLight = R_StudioDynamicLight;
|
||||||
|
api->StudioEntityLight = R_StudioEntityLight;
|
||||||
|
api->StudioSetupLighting = R_StudioSetupLighting;
|
||||||
|
api->StudioDrawPoints = R_StudioDrawPoints;
|
||||||
|
api->StudioDrawHulls = R_StudioDrawHulls;
|
||||||
|
api->StudioDrawAbsBBox = R_StudioDrawAbsBBox;
|
||||||
|
api->StudioDrawBones = R_StudioDrawBones;
|
||||||
|
api->StudioSetupSkin = (void *)R_StudioSetupSkin;
|
||||||
|
api->StudioSetRemapColors = R_StudioSetRemapColors;
|
||||||
|
api->SetupPlayerModel = R_StudioSetupPlayerModel;
|
||||||
|
api->StudioClientEvents = R_StudioClientEvents;
|
||||||
|
api->GetForceFaceFlags = R_StudioGetForceFaceFlags;
|
||||||
|
api->SetForceFaceFlags = R_StudioSetForceFaceFlags;
|
||||||
|
api->StudioSetHeader = (void *)R_StudioSetHeader;
|
||||||
|
api->SetRenderModel = R_StudioSetRenderModel;
|
||||||
|
api->SetupRenderer = R_StudioSetupRenderer;
|
||||||
|
api->RestoreRenderer = R_StudioRestoreRenderer;
|
||||||
|
api->SetChromeOrigin = R_StudioSetChromeOrigin;
|
||||||
|
api->GL_StudioDrawShadow = GL_StudioDrawShadow;
|
||||||
|
api->GL_SetRenderMode = GL_StudioSetRenderMode;
|
||||||
|
api->StudioSetRenderamt = R_StudioSetRenderamt;
|
||||||
|
api->StudioSetCullState = R_StudioSetCullState;
|
||||||
|
api->StudioRenderShadow = R_StudioRenderShadow;
|
||||||
|
|
||||||
// NOTE: we always return true even if game interface was not correct
|
pDefaultDraw->version = STUDIO_INTERFACE_VERSION;
|
||||||
// because we need Draw our StudioModels
|
pDefaultDraw->StudioDrawModel = R_StudioDrawModel;
|
||||||
// just restore pointer to builtin function
|
pDefaultDraw->StudioDrawPlayer = R_StudioDrawPlayer;
|
||||||
pStudioDraw = &gStudioDraw;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_StudioSetDrawInterface( r_studio_interface_t *pDraw )
|
||||||
|
{
|
||||||
|
pStudioDraw = pDraw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ void R_SetUpWorldTransform( void )
|
|||||||
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasworldtransform[0][3] = -RI.vieworg[0];
|
aliasworldtransform[0][3] = -RI.rvp.vieworigin[0];
|
||||||
aliasworldtransform[1][3] = -RI.vieworg[1];
|
aliasworldtransform[1][3] = -RI.rvp.vieworigin[1];
|
||||||
aliasworldtransform[2][3] = -RI.vieworg[2];
|
aliasworldtransform[2][3] = -RI.rvp.vieworigin[2];
|
||||||
|
|
||||||
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
|
||||||
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user