Browse Source

ref: make API thinner by moving simple calls into EngineGetParm(RenderGetParm with ref extensions), fix some UBs

pull/2/head
Alibek Omarov 6 years ago
parent
commit
92b89936b3
  1. 1
      common/r_efx.h
  2. 3
      common/render_api.h
  3. 4
      engine/client/cl_game.c
  4. 108
      engine/client/cl_render.c
  5. 2
      engine/client/cl_tent.h
  6. 13
      engine/client/client.h
  7. 2
      engine/client/console.c
  8. 76
      engine/client/ref_common.c
  9. 2
      engine/client/ref_common.h
  10. 2
      engine/client/s_vox.c
  11. 2
      engine/common/mod_bmodel.c
  12. 1
      engine/eiface.h
  13. 2
      engine/platform/platform.h
  14. 7
      engine/platform/sdl/vid_sdl.c
  15. 62
      engine/ref_api.h
  16. 7
      ref_gl/gl_alias.c
  17. 4
      ref_gl/gl_backend.c
  18. 2
      ref_gl/gl_beams.c
  19. 8
      ref_gl/gl_context.c
  20. 6
      ref_gl/gl_cull.c
  21. 4
      ref_gl/gl_decals.c
  22. 2
      ref_gl/gl_image.c
  23. 11
      ref_gl/gl_local.h
  24. 2
      ref_gl/gl_rlight.c
  25. 21
      ref_gl/gl_rmain.c
  26. 2
      ref_gl/gl_rmisc.c
  27. 24
      ref_gl/gl_rsurf.c
  28. 25
      ref_gl/gl_studio.c
  29. 2
      ref_gl/gl_triapi.c
  30. 2
      ref_gl/gl_warp.c

1
common/r_efx.h

@ -85,6 +85,7 @@ color24 gTracerColors[] =
#define FTENT_SCALE 0x00100000 // An experiment #define FTENT_SCALE 0x00100000 // An experiment
typedef struct tempent_s TEMPENTITY; typedef struct tempent_s TEMPENTITY;
struct pmtrace_s;
typedef struct tempent_s typedef struct tempent_s
{ {
int flags; int flags;

3
common/render_api.h

@ -235,7 +235,8 @@ typedef struct render_api_s
float (*pfnTime)( void ); // Sys_DoubleTime float (*pfnTime)( void ); // Sys_DoubleTime
void (*Cvar_Set)( const char *name, const char *value ); void (*Cvar_Set)( const char *name, const char *value );
void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents) void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents)
void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random // a1ba: changed long to int
void (*SetRandomSeed)( int lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 37 // ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 37
} render_api_t; } render_api_t;

4
engine/client/cl_game.c

@ -3177,7 +3177,7 @@ TriWorldToScreen
convert world coordinates (x,y,z) into screen (x, y) convert world coordinates (x,y,z) into screen (x, y)
============= =============
*/ */
int TriWorldToScreen( float *world, float *screen ) int TriWorldToScreen( const float *world, float *screen )
{ {
int retval; int retval;
@ -3281,7 +3281,7 @@ Demo_IsPlayingback
================= =================
*/ */
int Demo_IsPlayingback( void ) static int Demo_IsPlayingback( void )
{ {
return cls.demoplayback; return cls.demoplayback;
} }

108
engine/client/cl_render.c

@ -135,7 +135,7 @@ const char *CL_GenericHandle( int fileindex )
return cl.files_precache[fileindex]; return cl.files_precache[fileindex];
} }
int CL_RenderGetParm( int parm, int arg, const qboolean checkRef ) int CL_RenderGetParm( const int parm, const int arg, const qboolean checkRef )
{ {
switch( parm ) switch( parm )
{ {
@ -163,7 +163,41 @@ int CL_RenderGetParm( int parm, int arg, const qboolean checkRef )
case PARM_WATER_ALPHA: case PARM_WATER_ALPHA:
return FBitSet( world.flags, FWORLD_WATERALPHA ); return FBitSet( world.flags, FWORLD_WATERALPHA );
default: default:
if( checkRef ) return ref.dllFuncs.RenderGetParm( parm, arg ); // indicates call from client.dll
if( checkRef )
{
return ref.dllFuncs.RefGetParm( parm, arg );
}
// call issued from ref_dll, check extensions here
else switch( parm )
{
case PARM_DEV_OVERVIEW:
return CL_IsDevOverviewMode();
case PARM_THIRDPERSON:
return CL_IsThirdPerson();
case PARM_QUAKE_COMPATIBLE:
return Host_IsQuakeCompatible();
case PARM_PLAYER_INDEX:
return cl.playernum + 1;
case PARM_VIEWENT_INDEX:
return cl.viewentity;
case PARM_CONNSTATE:
return (int)cls.state;
case PARM_PLAYING_DEMO:
return cls.demoplayback;
case PARM_WATER_LEVEL:
return cl.local.waterlevel;
case PARM_MAX_CLIENTS:
return cl.maxclients;
case PARM_LOCAL_HEALTH:
return cl.local.health;
case PARM_LOCAL_GAME:
return Host_IsLocalGame();
case PARM_NUMENTITIES:
return pfnNumberOfEntities();
case PARM_NUMMODELS:
return cl.nummodels;
}
} }
return 0; return 0;
} }
@ -186,7 +220,7 @@ static render_api_t gRenderAPI =
NULL, // R_SetCurrentEntity, NULL, // R_SetCurrentEntity,
NULL, // R_SetCurrentModel, NULL, // R_SetCurrentModel,
R_FatPVS, R_FatPVS,
NULL, // R_StoreEfrags, R_StoreEfrags,
NULL, // GL_FindTexture, NULL, // GL_FindTexture,
NULL, // GL_TextureName, NULL, // GL_TextureName,
NULL, // GL_TextureData, NULL, // GL_TextureData,
@ -216,7 +250,7 @@ static render_api_t gRenderAPI =
NULL, // GL_TexGen, NULL, // GL_TexGen,
NULL, // GL_TextureTarget, NULL, // GL_TextureTarget,
NULL, // GL_SetTexCoordArrayMode, NULL, // GL_SetTexCoordArrayMode,
NULL, // GL_GetProcAddress, GL_GetProcAddress,
NULL, // GL_UpdateTexSize, NULL, // GL_UpdateTexSize,
NULL, NULL,
NULL, NULL,
@ -242,6 +276,39 @@ 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;
}
/* /*
=============== ===============
R_InitRenderAPI R_InitRenderAPI
@ -255,38 +322,7 @@ qboolean R_InitRenderAPI( void )
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs )); memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
// fill missing functions from renderer // fill missing functions from renderer
gRenderAPI.GetDetailScaleForTexture = ref.dllFuncs.GetDetailScaleForTexture; R_FillRenderAPIFromRef( &gRenderAPI, &ref.dllFuncs );
gRenderAPI.GetExtraParmsForTexture = ref.dllFuncs.GetDetailScaleForTexture;
gRenderAPI.GetFrameTime = ref.dllFuncs.GetFrameTime;
gRenderAPI.R_SetCurrentEntity = ref.dllFuncs.R_SetCurrentEntity;
gRenderAPI.R_SetCurrentModel = ref.dllFuncs.R_SetCurrentModel;
gRenderAPI.R_StoreEfrags = R_StoreEfrags;
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_CreateTexture = ref.dllFuncs.GL_CreateTexture;
gRenderAPI.GL_LoadTextureArray = ref.dllFuncs.GL_LoadTextureArray;
gRenderAPI.GL_CreateTextureArray = ref.dllFuncs.GL_CreateTextureArray;
gRenderAPI.GL_FreeTexture = ref.dllFuncs.GL_FreeTexture;
gRenderAPI.DrawSingleDecal = ref.dllFuncs.DrawSingleDecal;
gRenderAPI.R_DecalSetupVerts = ref.dllFuncs.R_DecalSetupVerts;
gRenderAPI.R_EntityRemoveDecals = ref.dllFuncs.R_EntityRemoveDecals;
gRenderAPI.AVI_UploadRawFrame = ref.dllFuncs.AVI_UploadRawFrame;
gRenderAPI.GL_Bind = ref.dllFuncs.GL_Bind;
gRenderAPI.GL_SelectTexture = ref.dllFuncs.GL_SelectTexture;
gRenderAPI.GL_LoadTextureMatrix = ref.dllFuncs.GL_LoadTextureMatrix;
gRenderAPI.GL_TexMatrixIdentity = ref.dllFuncs.GL_TexMatrixIdentity;
gRenderAPI.GL_CleanUpTextureUnits = ref.dllFuncs.GL_CleanUpTextureUnits;
gRenderAPI.GL_TexGen = ref.dllFuncs.GL_TexGen;
gRenderAPI.GL_TextureTarget = ref.dllFuncs.GL_TextureTarget;
gRenderAPI.GL_TexCoordArrayMode = ref.dllFuncs.GL_TexCoordArrayMode;
gRenderAPI.GL_GetProcAddress = GL_GetProcAddress;
gRenderAPI.GL_UpdateTexSize = ref.dllFuncs.GL_UpdateTexSize;
gRenderAPI.GL_DrawParticles = ref.dllFuncs.GL_DrawParticles;
gRenderAPI.LightVec = ref.dllFuncs.LightVec;
gRenderAPI.StudioGetTexture = ref.dllFuncs.StudioGetTexture;
if( clgame.dllFuncs.pfnGetRenderInterface ) if( clgame.dllFuncs.pfnGetRenderInterface )
{ {

2
engine/client/cl_tent.h

@ -109,7 +109,7 @@ void TriColor4f( float r, float g, float b, float a );
void TriColor4ub( byte r, byte g, byte b, byte a ); void TriColor4ub( byte r, byte g, byte b, byte a );
void TriBrightness( float brightness ); void TriBrightness( float brightness );
void TriCullFace( TRICULLSTYLE mode ); void TriCullFace( TRICULLSTYLE mode );
int TriWorldToScreen( float *world, float *screen ); int TriWorldToScreen( const float *world, float *screen );
int TriBoxInPVS( float *mins, float *maxs ); int TriBoxInPVS( float *mins, float *maxs );
void TriLightAtPoint( float *pos, float *value ); void TriLightAtPoint( float *pos, float *value );
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode ); void TriColor4fRendermode( float r, float g, float b, float a, int rendermode );

13
engine/client/client.h

@ -275,16 +275,6 @@ of server connections
================================================================== ==================================================================
*/ */
typedef enum
{
ca_disconnected = 0,// not talking to a server
ca_connecting, // sending request packets to the server
ca_connected, // netchan_t established, waiting for svc_serverdata
ca_validate, // download resources, validating, auth on server
ca_active, // game views should be displayed
ca_cinematic, // playing a cinematic, not connected to a server
} connstate_t;
typedef enum typedef enum
{ {
scrshot_inactive, scrshot_inactive,
@ -831,7 +821,6 @@ void CL_PlayerTrace( float *start, float *end, int traceFlags, int ignore_pe, pm
void CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr ); void CL_PlayerTraceExt( float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ), pmtrace_t *tr );
void CL_SetTraceHull( int hull ); void CL_SetTraceHull( int hull );
void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input void CL_GetMousePosition( int *mx, int *my ); // TODO: move to input
int Demo_IsPlayingback( void );
cl_entity_t* CL_GetViewModel( void ); cl_entity_t* CL_GetViewModel( void );
void pfnGetScreenFade( struct screenfade_s *fade ); void pfnGetScreenFade( struct screenfade_s *fade );
physent_t *pfnGetPhysent( int idx ); physent_t *pfnGetPhysent( int idx );
@ -958,7 +947,7 @@ void CL_ClearAllRemaps( void );
// cl_render.c // cl_render.c
// //
qboolean R_InitRenderAPI( void ); qboolean R_InitRenderAPI( void );
int CL_RenderGetParm( int parm, int arg, const qboolean checkRef ); int CL_RenderGetParm( const int parm, const int arg, const qboolean checkRef );
lightstyle_t *CL_GetLightStyle( int number ); lightstyle_t *CL_GetLightStyle( int number );
int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis ); int R_FatPVS( const vec3_t org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis );
const ref_overview_t *GL_GetOverviewParms( void ); const ref_overview_t *GL_GetOverviewParms( void );

2
engine/client/console.c

@ -883,7 +883,7 @@ static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
return con.curFont->charWidths[number]; return con.curFont->charWidths[number];
// don't apply color to fixed fonts it's already colored // don't apply color to fixed fonts it's already colored
if( con.curFont->type != FONT_FIXED || RENDER_GET_PARM( PARM_TEX_GLFORMAT, 0x8045 ) ) // GL_LUMINANCE8_ALPHA8 if( con.curFont->type != FONT_FIXED || REF_GET_PARM( PARM_TEX_GLFORMAT, 0x8045 ) ) // GL_LUMINANCE8_ALPHA8
ref.dllFuncs.Color4ub( color[0], color[1], color[2], color[3] ); ref.dllFuncs.Color4ub( color[0], color[1], color[2], color[3] );
else ref.dllFuncs.Color4ub( 255, 255, 255, color[3] ); else ref.dllFuncs.Color4ub( 255, 255, 255, color[3] );

76
engine/client/ref_common.c

@ -16,8 +16,8 @@ convar_t *gl_wgl_msaa_samples;
void R_GetTextureParms( int *w, int *h, int texnum ) void R_GetTextureParms( int *w, int *h, int texnum )
{ {
if( w ) *w = RENDER_GET_PARM( PARM_TEX_WIDTH, texnum ); if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
if( h ) *h = RENDER_GET_PARM( PARM_TEX_HEIGHT, texnum ); if( h ) *h = REF_GET_PARM( PARM_TEX_HEIGHT, texnum );
} }
/* /*
@ -35,52 +35,11 @@ void GL_FreeImage( const char *name )
ref.dllFuncs.GL_FreeTexture( texnum ); ref.dllFuncs.GL_FreeTexture( texnum );
} }
static int TriGetRenderMode( void ) static int pfnEngineGetParm( int parm, int arg )
{
return clgame.ds.renderMode;
}
static int pfnRefRenderGetParm( int parm, int arg )
{ {
return CL_RenderGetParm( parm, arg, false ); // prevent recursion return CL_RenderGetParm( parm, arg, false ); // prevent recursion
} }
static int pfnGetPlayerIndex( void )
{
return cl.playernum + 1;
}
static int pfnGetViewEntIndex( void )
{
return cl.viewentity;
}
static ref_connstate_t pfnCL_GetConnState( void )
{
switch( cls.state )
{
case ca_disconnected: return ref_ca_disconnected;
case ca_connecting: return ref_ca_connecting;
case ca_connected: return ref_ca_connected;
case ca_validate: return ref_ca_validate;
case ca_active: return ref_ca_active;
case ca_cinematic: return ref_ca_cinematic;
default:
ASSERT( 0 );
}
return ref_ca_disconnected;
}
static int pfnGetWaterLevel( void )
{
return cl.local.waterlevel;
}
static int pfnGetLocalHealth( void )
{
return cl.local.health;
}
static void pfnCbuf_SetOpenGLConfigHack( qboolean set ) static void pfnCbuf_SetOpenGLConfigHack( qboolean set )
{ {
host.apply_opengl_config = set; host.apply_opengl_config = set;
@ -140,11 +99,6 @@ static void pfnMod_SetCurrentLoadingModel( model_t *m )
loadmodel = m; loadmodel = m;
} }
static int pfnCL_NumModels( void )
{
return cl.nummodels;
}
static void pfnGetPredictedOrigin( vec3_t v ) static void pfnGetPredictedOrigin( vec3_t v )
{ {
VectorCopy( cl.simorg, v ); VectorCopy( cl.simorg, v );
@ -207,7 +161,7 @@ static byte *pfnImage_GetPool( void )
return host.imagepool; return host.imagepool;
} }
static struct bpc_desc_s *pfnImage_GetPFDesc( int idx ) static const bpc_desc_t *pfnImage_GetPFDesc( int idx )
{ {
return &PFDesc[idx]; return &PFDesc[idx];
} }
@ -222,20 +176,14 @@ static void pfnDrawTransparentTriangles( void )
clgame.dllFuncs.pfnDrawTransparentTriangles(); clgame.dllFuncs.pfnDrawTransparentTriangles();
} }
static screenfade_t *pfnRefGetScreenFade( void )
{
return &clgame.fade;
}
static ref_api_t gEngfuncs = static ref_api_t gEngfuncs =
{ {
CL_IsDevOverviewMode, pfnEngineGetParm,
CL_IsThirdPerson,
Host_IsQuakeCompatible,
pfnGetPlayerIndex,
pfnGetViewEntIndex,
pfnCL_GetConnState,
Demo_IsPlayingback,
pfnGetWaterLevel,
pfnRefRenderGetParm,
CL_GetMaxClients,
pfnGetLocalHealth,
Host_IsLocalGame,
Cvar_Get, Cvar_Get,
Cvar_FindVarExt, Cvar_FindVarExt,
@ -271,7 +219,6 @@ static ref_api_t gEngfuncs =
CL_GetLocalPlayer, CL_GetLocalPlayer,
CL_GetViewModel, CL_GetViewModel,
CL_GetEntityByIndex, CL_GetEntityByIndex,
pfnNumberOfEntities,
R_BeamGetEntity, R_BeamGetEntity,
CL_GetWaterEntity, CL_GetWaterEntity,
CL_AddVisibleEntity, CL_AddVisibleEntity,
@ -301,7 +248,6 @@ static ref_api_t gEngfuncs =
CL_ModelHandle, CL_ModelHandle,
pfnMod_GetCurrentLoadingModel, pfnMod_GetCurrentLoadingModel,
pfnMod_SetCurrentLoadingModel, pfnMod_SetCurrentLoadingModel,
pfnCL_NumModels,
CL_GetRemapInfoForEntity, CL_GetRemapInfoForEntity,
CL_AllocRemapInfo, CL_AllocRemapInfo,
@ -315,7 +261,7 @@ static ref_api_t gEngfuncs =
COM_SetRandomSeed, COM_SetRandomSeed,
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,
pfnGetScreenFade, pfnRefGetScreenFade,
CL_TextMessageGet, CL_TextMessageGet,
pfnGetPredictedOrigin, pfnGetPredictedOrigin,
pfnCL_GetPaletteColor, pfnCL_GetPaletteColor,

2
engine/client/ref_common.h

@ -33,7 +33,7 @@ extern ref_globals_t refState;
// handy API wrappers // handy API wrappers
void R_GetTextureParms( int *w, int *h, int texnum ); void R_GetTextureParms( int *w, int *h, int texnum );
#define RENDER_GET_PARM( parm, arg ) ref.dllFuncs.RenderGetParm( (parm), (arg) ) #define REF_GET_PARM( parm, arg ) ref.dllFuncs.RefGetParm( (parm), (arg) )
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false ) #define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true ) #define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true )

2
engine/client/s_vox.c

@ -606,7 +606,7 @@ void VOX_ReadSentenceFile( const char *psentenceFileName )
{ {
char c, *pch, *pFileData; char c, *pch, *pFileData;
char *pchlast, *pSentenceData; char *pchlast, *pSentenceData;
size_t fileSize; fs_offset_t fileSize;
// load file // load file
pFileData = (char *)FS_LoadFile( psentenceFileName, &fileSize, false ); pFileData = (char *)FS_LoadFile( psentenceFileName, &fileSize, false );

2
engine/common/mod_bmodel.c

@ -1924,7 +1924,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
} }
// check for luma texture // check for luma texture
if( FBitSet( RENDER_GET_PARM( PARM_TEX_FLAGS, tx->gl_texturenum ), TF_HAS_LUMA )) if( FBitSet( REF_GET_PARM( PARM_TEX_FLAGS, tx->gl_texturenum ), TF_HAS_LUMA ))
{ {
Q_snprintf( texname, sizeof( texname ), "#%s:%s_luma.mip", loadstat.name, mt->name ); Q_snprintf( texname, sizeof( texname ), "#%s:%s_luma.mip", loadstat.name, mt->name );

1
engine/eiface.h

@ -398,6 +398,7 @@ struct playermove_s;
struct clientdata_s; struct clientdata_s;
struct usercmd_s; struct usercmd_s;
struct edict_s; struct edict_s;
struct netadr_s;
typedef struct typedef struct
{ {

2
engine/platform/platform.h

@ -82,7 +82,7 @@ typedef enum
typedef struct vidmode_s vidmode_t; typedef struct vidmode_s vidmode_t;
// Window // Window
qboolean R_Init_Video( void ); qboolean R_Init_Video( const int type );
void R_Free_Video( void ); void R_Free_Video( void );
qboolean VID_SetMode( void ); qboolean VID_SetMode( void );
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen ); rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen );

7
engine/platform/sdl/vid_sdl.c

@ -518,7 +518,7 @@ int GL_GetAttribute( int attr, int *val )
R_Init_Video R_Init_Video
================== ==================
*/ */
qboolean R_Init_Video( void ) qboolean R_Init_Video( const int type )
{ {
SDL_DisplayMode displayMode; SDL_DisplayMode displayMode;
string safe; string safe;
@ -529,6 +529,11 @@ qboolean R_Init_Video( void )
glw_state.desktopWidth = displayMode.w; glw_state.desktopWidth = displayMode.w;
glw_state.desktopHeight = displayMode.h; glw_state.desktopHeight = displayMode.h;
if( type != REF_GL )
{
Host_Error( "Can't initialize unknown context type %d!\n", type );
}
if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", safe ) ) if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", safe ) )
glw_state.safe = bound( SAFE_NO, Q_atoi( safe ), SAFE_DONTCARE ); glw_state.safe = bound( SAFE_NO, Q_atoi( safe ), SAFE_DONTCARE );

62
engine/ref_api.h

@ -135,15 +135,15 @@ enum ref_shared_texture_e
REF_ALPHASKY_TEXTURE, REF_ALPHASKY_TEXTURE,
}; };
typedef enum ref_connstate_e typedef enum connstate_e
{ {
ref_ca_disconnected = 0,// not talking to a server ca_disconnected = 0,// not talking to a server
ref_ca_connecting, // sending request packets to the server ca_connecting, // sending request packets to the server
ref_ca_connected, // netchan_t established, waiting for svc_serverdata ca_connected, // netchan_t established, waiting for svc_serverdata
ref_ca_validate, // download resources, validating, auth on server ca_validate, // download resources, validating, auth on server
ref_ca_active, // game views should be displayed ca_active, // game views should be displayed
ref_ca_cinematic, // playing a cinematic, not connected to a server ca_cinematic, // playing a cinematic, not connected to a server
} ref_connstate_t; } connstate_t;
enum ref_defaultsprite_e enum ref_defaultsprite_e
{ {
@ -216,9 +216,6 @@ enum
REF_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 REF_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
}; };
struct con_nprint_s;
struct engine_studio_api_s;
typedef struct remap_info_s typedef struct remap_info_s
{ {
unsigned short textures[MAX_SKINS];// alias textures unsigned short textures[MAX_SKINS];// alias textures
@ -229,21 +226,30 @@ typedef struct remap_info_s
model_t *model; // for catch model changes model_t *model; // for catch model changes
} remap_info_t; } remap_info_t;
struct con_nprint_s;
struct engine_studio_api_s;
struct r_studio_interface_s;
typedef enum
{
PARM_DEV_OVERVIEW = -1,
PARM_THIRDPERSON = -2,
PARM_QUAKE_COMPATIBLE = -3,
PARM_PLAYER_INDEX = -4, // cl.playernum + 1
PARM_VIEWENT_INDEX = -5, // cl.viewentity
PARM_CONNSTATE = -6, // cls.state
PARM_PLAYING_DEMO = -7, // cls.demoplayback
PARM_WATER_LEVEL = -8, // cl.local.water_level
PARM_MAX_CLIENTS = -9, // cl.maxclients
PARM_LOCAL_HEALTH = -10, // cl.local.health
PARM_LOCAL_GAME = -11,
PARM_NUMENTITIES = -12, // local game only
PARM_NUMMODELS = -13, // cl.nummodels
} ref_parm_e;
typedef struct ref_api_s typedef struct ref_api_s
{ {
qboolean (*CL_IsDevOverviewMode)( void ); int (*EngineGetParm)( int parm, int arg ); // generic
qboolean (*CL_IsThirdPersonMode)( void );
qboolean (*Host_IsQuakeCompatible)( void );
int (*GetPlayerIndex)( void ); // cl.playernum + 1
int (*GetViewEntIndex)( void ); // cl.viewentity
ref_connstate_t (*CL_GetConnState)( void ); // cls.state == ca_connected
int (*IsDemoPlaying)( void ); // cls.demoplayback
int (*GetWaterLevel)( void ); // cl.local.waterlevel
int (*CL_GetRenderParm)( int parm, int arg ); // generic int (*GetMaxClients)( void );
int (*GetMaxClients)( void ); // cl.maxclients
int (*GetLocalHealth)( void ); // cl.local.health
qboolean (*Host_IsLocalGame)( void );
// cvar handlers // cvar handlers
cvar_t *(*Cvar_Get)( const char *szName, const char *szValue, int flags, const char *description ); cvar_t *(*Cvar_Get)( const char *szName, const char *szValue, int flags, const char *description );
@ -257,7 +263,7 @@ typedef struct ref_api_s
// command handlers // command handlers
int (*Cmd_AddCommand)( const char *cmd_name, void (*function)(void), const char *description ); int (*Cmd_AddCommand)( const char *cmd_name, void (*function)(void), const char *description );
int (*Cmd_RemoveCommand)( const char *cmd_name ); void (*Cmd_RemoveCommand)( const char *cmd_name );
int (*Cmd_Argc)( void ); int (*Cmd_Argc)( void );
const char *(*Cmd_Argv)( int arg ); const char *(*Cmd_Argv)( int arg );
const char *(*Cmd_Args)( void ); const char *(*Cmd_Args)( void );
@ -276,7 +282,7 @@ typedef struct ref_api_s
// debug print // debug print
void (*Con_NPrintf)( int pos, const char *fmt, ... ); void (*Con_NPrintf)( int pos, const char *fmt, ... );
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ); void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... );
void (*CL_CenterPrint)( const char *fmt, ... ); void (*CL_CenterPrint)( const char *s, float y );
void (*Con_DrawStringLen)( const char *pText, int *length, int *height ); void (*Con_DrawStringLen)( const char *pText, int *length, int *height );
int (*Con_DrawString)( int x, int y, const char *string, rgba_t setColor ); int (*Con_DrawString)( int x, int y, const char *string, rgba_t setColor );
void (*CL_DrawCenterPrint)(); void (*CL_DrawCenterPrint)();
@ -285,7 +291,6 @@ typedef struct ref_api_s
struct cl_entity_s *(*GetLocalPlayer)( void ); struct cl_entity_s *(*GetLocalPlayer)( void );
struct cl_entity_s *(*GetViewModel)( void ); struct cl_entity_s *(*GetViewModel)( void );
struct cl_entity_s *(*GetEntityByIndex)( int idx ); struct cl_entity_s *(*GetEntityByIndex)( int idx );
int (*pfnNumberOfEntities)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index ); struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( vec3_t p ); struct cl_entity_s *(*CL_GetWaterEntity)( vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType ); qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
@ -319,7 +324,6 @@ typedef struct ref_api_s
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
struct model_s *(*Mod_GetCurrentLoadingModel)( void ); // loadmodel struct model_s *(*Mod_GetCurrentLoadingModel)( void ); // loadmodel
void (*Mod_SetCurrentLoadingModel)( struct model_s* ); // loadmodel void (*Mod_SetCurrentLoadingModel)( struct model_s* ); // loadmodel
int (*CL_NumModels)( void ); // cl.nummodels
// remap // remap
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e ); struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
@ -415,7 +419,7 @@ typedef struct ref_api_s
void (*FS_FreeImage)( rgbdata_t *pack ); void (*FS_FreeImage)( rgbdata_t *pack );
void (*Image_SetMDLPointer)( byte *p ); void (*Image_SetMDLPointer)( byte *p );
byte *(*Image_GetPool)( void ); byte *(*Image_GetPool)( void );
struct bpc_desc_s *(*Image_GetPFDesc)( int idx ); const struct bpc_desc_s *(*Image_GetPFDesc)( int idx );
// client exports // client exports
void (*pfnDrawNormalTriangles)( void ); void (*pfnDrawNormalTriangles)( void );
@ -523,7 +527,7 @@ typedef struct ref_interface_s
// Xash3D Render Interface // Xash3D Render Interface
// Get renderer info (doesn't changes engine state at all) // Get renderer info (doesn't changes engine state at all)
int (*RenderGetParm)( int parm, int arg ); // generic int (*RefGetParm)( int parm, int arg ); // generic
void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale ); void (*GetDetailScaleForTexture)( int texture, float *xScale, float *yScale );
void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha ); void (*GetExtraParmsForTexture)( int texture, byte *red, byte *green, byte *blue, byte *alpha );
float (*GetFrameTime)( void ); float (*GetFrameTime)( void );

7
ref_gl/gl_alias.c

@ -19,7 +19,6 @@ GNU General Public License for more details.
#include "triangleapi.h" #include "triangleapi.h"
#include "alias.h" #include "alias.h"
#include "pm_local.h" #include "pm_local.h"
#include "cl_tent.h"
#include "pmtrace.h" #include "pmtrace.h"
extern cvar_t r_shadows; extern cvar_t r_shadows;
@ -803,7 +802,7 @@ void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
msurface_t *psurf = NULL; msurface_t *psurf = NULL;
pmtrace_t trace; pmtrace_t trace;
if( FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_WRITE_LARGE_COORD )) if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_WRITE_LARGE_COORD ))
{ {
vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f; vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f;
vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f; vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f;
@ -1170,7 +1169,7 @@ void R_AliasLerpMovement( cl_entity_t *e )
if( g_alias.interpolate && ( g_alias.time < e->curstate.animtime + 1.0f ) && ( e->curstate.animtime != e->latched.prevanimtime )) if( g_alias.interpolate && ( g_alias.time < e->curstate.animtime + 1.0f ) && ( e->curstate.animtime != e->latched.prevanimtime ))
f = ( g_alias.time - e->curstate.animtime ) / ( e->curstate.animtime - e->latched.prevanimtime ); f = ( g_alias.time - e->curstate.animtime ) / ( e->curstate.animtime - e->latched.prevanimtime );
if( gEngfuncs.IsDemoPlaying() == DEMO_QUAKE1 ) if( ENGINE_GET_PARM( PARM_PLAYING_DEMO ) == DEMO_QUAKE1 )
f = f + 1.0f; f = f + 1.0f;
g_alias.lerpfrac = bound( 0.0f, f, 1.0f ); g_alias.lerpfrac = bound( 0.0f, f, 1.0f );
@ -1388,7 +1387,7 @@ void R_DrawAliasModel( cl_entity_t *e )
R_AliasLerpMovement( e ); R_AliasLerpMovement( e );
if( !FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_COMPENSATE_QUAKE_BUG )) if( !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPENSATE_QUAKE_BUG ))
e->angles[PITCH] = -e->angles[PITCH]; // stupid quake bug e->angles[PITCH] = -e->angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim // don't rotate clients, only aim

4
ref_gl/gl_backend.c

@ -105,7 +105,7 @@ void GL_BackendEndFrame( void )
break; break;
case 4: case 4:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i static entities\n%3i normal entities\n%3i server entities", Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i static entities\n%3i normal entities\n%3i server entities",
r_numStatics, r_numEntities - r_numStatics, gEngfuncs.pfnNumberOfEntities( )); r_numStatics, r_numEntities - r_numStatics, ENGINE_GET_PARM( PARM_NUMENTITIES ));
break; break;
case 5: case 5:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i tempents\n%3i viewbeams\n%3i particles", Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i tempents\n%3i viewbeams\n%3i particles",
@ -820,7 +820,7 @@ void SCR_TimeRefresh_f( void )
double start, stop; double start, stop;
double time; double time;
if( gEngfuncs.CL_GetConnState() != ref_ca_active ) if( ENGINE_GET_PARM( PARM_CONNSTATE ) != ca_active )
return; return;
start = gEngfuncs.pfnTime(); start = gEngfuncs.pfnTime();

2
ref_gl/gl_beams.c

@ -869,7 +869,7 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
// get attachment // get attachment
if( attach > 0 ) if( attach > 0 )
VectorCopy( ent->attachment[attach - 1], pt ); VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == gEngfuncs.GetPlayerIndex() ) else if( ent->index == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
{ {
vec3_t simorg; vec3_t simorg;
gEngfuncs.GetPredictedOrigin( simorg ); gEngfuncs.GetPredictedOrigin( simorg );

8
ref_gl/gl_context.c

@ -237,7 +237,7 @@ qboolean Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf )
return loaded; return loaded;
} }
static int GL_RenderGetParm( int parm, int arg ) static int GL_RefGetParm( int parm, int arg )
{ {
gl_texture_t *glt; gl_texture_t *glt;
@ -312,9 +312,9 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_STENCIL_ACTIVE: case PARM_STENCIL_ACTIVE:
return glState.stencilEnabled; return glState.stencilEnabled;
case PARM_SKY_SPHERE: case PARM_SKY_SPHERE:
return gEngfuncs.CL_GetRenderParm( parm, arg ) && !tr.fCustomSkybox; return ENGINE_GET_PARM_( parm, arg ) && !tr.fCustomSkybox;
default: default:
return gEngfuncs.CL_GetRenderParm( parm, arg ); return ENGINE_GET_PARM_( parm, arg );
} }
return 0; return 0;
} }
@ -462,7 +462,7 @@ ref_interface_t gReffuncs =
CL_DrawBeams, CL_DrawBeams,
R_BeamCull, R_BeamCull,
GL_RenderGetParm, GL_RefGetParm,
R_GetDetailScaleForTexture, R_GetDetailScaleForTexture,
R_GetExtraParmsForTexture, R_GetExtraParmsForTexture,
R_GetFrameTime, R_GetFrameTime,

6
ref_gl/gl_cull.c

@ -56,17 +56,17 @@ int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax )
{ {
if( e == gEngfuncs.GetViewModel() ) if( e == gEngfuncs.GetViewModel() )
{ {
if( gEngfuncs.CL_IsDevOverviewMode( )) if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
return 1; return 1;
if( RP_NORMALPASS() && !gEngfuncs.CL_IsThirdPersonMode() && CL_IsViewEntityLocalPlayer()) if( RP_NORMALPASS() && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
return 0; return 0;
return 1; return 1;
} }
// local client can't view himself if camera or thirdperson is not active // local client can't view himself if camera or thirdperson is not active
if( RP_LOCALCLIENT( e ) && !gEngfuncs.CL_IsThirdPersonMode() && CL_IsViewEntityLocalPlayer()) if( RP_LOCALCLIENT( e ) && !ENGINE_GET_PARM( PARM_THIRDPERSON ) && CL_IsViewEntityLocalPlayer())
return 1; return 1;
if( R_CullBox( absmin, absmax )) if( R_CullBox( absmin, absmax ))

4
ref_gl/gl_decals.c

@ -618,10 +618,10 @@ void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
decal_t *decal = surf->pdecals; decal_t *decal = surf->pdecals;
vec4_t textureU, textureV; vec4_t textureU, textureV;
float s, t, w, h; float s, t, w, h;
ref_connstate_t state = gEngfuncs.CL_GetConnState(); connstate_t state = ENGINE_GET_PARM( PARM_CONNSTATE );
// we in restore mode // we in restore mode
if( state == ref_ca_connected || state == ref_ca_validate ) if( state == ca_connected || state == ca_validate )
{ {
// NOTE: we may have the decal on this surface that come from another level. // NOTE: we may have the decal on this surface that come from another level.
// check duplicate with same position and texture // check duplicate with same position and texture

2
ref_gl/gl_image.c

@ -878,7 +878,7 @@ byte *GL_ApplyFilter( const byte *source, int width, int height )
byte *out = (byte *)source; byte *out = (byte *)source;
int i; int i;
if( gEngfuncs.Host_IsQuakeCompatible() || glConfig.max_multisamples > 1 ) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) || glConfig.max_multisamples > 1 )
return in; return in;
for( i = 0; source && i < width * height; i++, in += 4 ) for( i = 0; source && i < width * height; i++, in += 4 )

11
ref_gl/gl_local.h

@ -81,10 +81,10 @@ extern byte *r_temppool;
#define RP_NONVIEWERREF (RP_ENVVIEW) #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 == gEngfuncs.GetPlayerIndex() && e->player ) #define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 ) #define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( gEngfuncs.GetViewEntIndex() == gEngfuncs.GetPlayerIndex() ) #define CL_IsViewEntityLocalPlayer() ( ENGINE_GET_PARM( PARM_VIEWENT_INDEX ) == ENGINE_GET_PARM( PARM_PLAYER_INDEX ) )
#define CULL_VISIBLE 0 // not culled #define CULL_VISIBLE 0 // not culled
#define CULL_BACKSIDE 1 // backside of transparent wall #define CULL_BACKSIDE 1 // backside of transparent wall
@ -577,8 +577,10 @@ void TriTexCoord2f( float u, float v );
void TriVertex3fv( const float *v ); void TriVertex3fv( const float *v );
void TriVertex3f( float x, float y, float z ); void TriVertex3f( float x, float y, float z );
void _TriColor4f( float r, float g, float b, float a ); void _TriColor4f( float r, float g, float b, float a );
void TriColor4f( float r, float g, float b, float a );
void TriColor4ub( byte r, byte g, byte b, byte a ); void TriColor4ub( byte r, byte g, byte b, byte a );
int TriWorldToScreen( float *world, float *screen ); void TriBrightness( float brightness );
int TriWorldToScreen( const float *world, float *screen );
int TriSpriteTexture( model_t *pSpriteModel, int frame ); int TriSpriteTexture( model_t *pSpriteModel, int frame );
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn ); void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn );
void TriGetMatrix( const int pname, float *matrix ); void TriGetMatrix( const int pname, float *matrix );
@ -709,6 +711,9 @@ extern glwstate_t glw_state;
extern ref_api_t gEngfuncs; extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals; extern ref_globals_t *gpGlobals;
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( ( parm ), 0 )
// //
// renderer cvars // renderer cvars
// //

2
ref_gl/gl_rlight.c

@ -55,7 +55,7 @@ void CL_RunLightStyles( void )
continue; continue;
} }
if( !gEngfuncs.CL_GetRenderParm( PARAM_GAMEPAUSED, 0 ) && frametime <= 0.1f ) if( !ENGINE_GET_PARM( PARAM_GAMEPAUSED ) && frametime <= 0.1f )
ls->time += frametime; // evaluate local time ls->time += frametime; // evaluate local time
flight = (int)Q_floor( ls->time * 10 ); flight = (int)Q_floor( ls->time * 10 );

21
ref_gl/gl_rmain.c

@ -283,7 +283,7 @@ static void R_Clear( int bitMask )
{ {
int bits; int bits;
if( gEngfuncs.CL_IsDevOverviewMode( )) if( ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
pglClearColor( 0.0f, 1.0f, 0.0f, 1.0f ); // green background (Valve rules) pglClearColor( 0.0f, 1.0f, 0.0f, 1.0f ); // green background (Valve rules)
else pglClearColor( 0.5f, 0.5f, 0.5f, 1.0f ); else pglClearColor( 0.5f, 0.5f, 0.5f, 1.0f );
@ -332,9 +332,9 @@ R_SetupFrustum
*/ */
void R_SetupFrustum( void ) void R_SetupFrustum( void )
{ {
ref_overview_t *ov = gEngfuncs.GetOverviewParms(); const ref_overview_t *ov = gEngfuncs.GetOverviewParms();
if( RP_NORMALPASS() && ( gEngfuncs.GetWaterLevel() >= 3 )) if( RP_NORMALPASS() && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ))
{ {
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0); RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0); RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
@ -367,7 +367,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
if( RI.drawOrtho ) if( RI.drawOrtho )
{ {
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 );
return; return;
} }
@ -661,7 +661,7 @@ static void R_CheckFog( void )
int i, cnt, count; int i, cnt, count;
// quake global fog // quake global fog
if( gEngfuncs.Host_IsQuakeCompatible( )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{ {
if( !MOVEVARS->fog_settings ) if( !MOVEVARS->fog_settings )
{ {
@ -686,12 +686,12 @@ static void R_CheckFog( void )
RI.fogEnabled = false; RI.fogEnabled = false;
if( RI.onlyClientDraw || gEngfuncs.GetWaterLevel() < 3 || !RI.drawWorld || !RI.viewleaf ) if( RI.onlyClientDraw || ENGINE_GET_PARM( PARM_WATER_LEVEL ) < 3 || !RI.drawWorld || !RI.viewleaf )
{ {
if( RI.cached_waterlevel == 3 ) if( RI.cached_waterlevel == 3 )
{ {
// in some cases waterlevel jumps from 3 to 1. Catch it // in some cases waterlevel jumps from 3 to 1. Catch it
RI.cached_waterlevel = gEngfuncs.GetWaterLevel(); RI.cached_waterlevel = ENGINE_GET_PARM( PARM_WATER_LEVEL );
RI.cached_contents = CONTENTS_EMPTY; RI.cached_contents = CONTENTS_EMPTY;
if( !RI.fogCustom ) pglDisable( GL_FOG ); if( !RI.fogCustom ) pglDisable( GL_FOG );
} }
@ -703,7 +703,7 @@ static void R_CheckFog( void )
cnt = ent->curstate.skin; cnt = ent->curstate.skin;
else cnt = RI.viewleaf->contents; else cnt = RI.viewleaf->contents;
RI.cached_waterlevel = gEngfuncs.GetWaterLevel(); RI.cached_waterlevel = ENGINE_GET_PARM( PARM_WATER_LEVEL );
if( !IsLiquidContents( RI.cached_contents ) && IsLiquidContents( cnt )) if( !IsLiquidContents( RI.cached_contents ) && IsLiquidContents( cnt ))
{ {
@ -784,7 +784,7 @@ void R_DrawFog( void )
if( !RI.fogEnabled ) return; if( !RI.fogEnabled ) return;
pglEnable( GL_FOG ); pglEnable( GL_FOG );
if( gEngfuncs.Host_IsQuakeCompatible( )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
pglFogi( GL_FOG_MODE, GL_EXP2 ); pglFogi( GL_FOG_MODE, GL_EXP2 );
else pglFogi( GL_FOG_MODE, GL_EXP ); else pglFogi( GL_FOG_MODE, GL_EXP );
pglFogf( GL_FOG_DENSITY, RI.fogDensity ); pglFogf( GL_FOG_DENSITY, RI.fogDensity );
@ -1017,7 +1017,8 @@ void R_BeginFrame( qboolean clearScene )
{ {
glConfig.softwareGammaUpdate = false; // in case of possible fails glConfig.softwareGammaUpdate = false; // in case of possible fails
if(( gl_clear->value || gEngfuncs.CL_IsDevOverviewMode( )) && clearScene && gEngfuncs.CL_GetConnState() != ref_ca_cinematic ) if(( gl_clear->value || ENGINE_GET_PARM( PARM_DEV_OVERVIEW )) &&
clearScene && ENGINE_GET_PARM( PARM_CONNSTATE ) != ca_cinematic )
{ {
pglClear( GL_COLOR_BUFFER_BIT ); pglClear( GL_COLOR_BUFFER_BIT );
} }

2
ref_gl/gl_rmisc.c

@ -131,7 +131,7 @@ void R_NewMap( void )
client_textmessage_t *title; client_textmessage_t *title;
title = gEngfuncs.pfnTextMessageGet( "GAMETITLE" ); title = gEngfuncs.pfnTextMessageGet( "GAMETITLE" );
if( gEngfuncs.Host_IsQuakeCompatible( )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
fadetime = 1.0f; fadetime = 1.0f;
if( title ) if( title )

24
ref_gl/gl_rsurf.c

@ -793,7 +793,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
float flRate, flAngle; float flRate, flAngle;
gl_texture_t *texture; gl_texture_t *texture;
if( gEngfuncs.Host_IsQuakeCompatible() && RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) ) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && RI.currententity == gEngfuncs.GetEntityByIndex( 0 ) )
{ {
// same as doom speed // same as doom speed
flConveyorSpeed = -35.0f; flConveyorSpeed = -35.0f;
@ -1272,7 +1272,7 @@ void R_DrawTextureChains( void )
RI.currententity = gEngfuncs.GetEntityByIndex( 0 ); RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model; RI.currentmodel = RI.currententity->model;
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) ) if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) )
{ {
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
pglColor3f( 1.0f, 1.0f, 1.0f ); pglColor3f( 1.0f, 1.0f, 1.0f );
@ -1282,7 +1282,7 @@ void R_DrawTextureChains( void )
for( s = skychain; s != NULL; s = s->texturechain ) for( s = skychain; s != NULL; s = s->texturechain )
R_AddSkyBoxSurface( s ); R_AddSkyBoxSurface( s );
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) ) if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) )
{ {
pglEnable( GL_TEXTURE_2D ); pglEnable( GL_TEXTURE_2D );
if( skychain ) if( skychain )
@ -1303,7 +1303,7 @@ void R_DrawTextureChains( void )
if(( s->flags & SURF_DRAWTURB ) && MOVEVARS->wateralpha < 1.0f ) if(( s->flags & SURF_DRAWTURB ) && MOVEVARS->wateralpha < 1.0f )
continue; // draw translucent water later continue; // draw translucent water later
if( gEngfuncs.Host_IsQuakeCompatible() && FBitSet( s->flags, SURF_TRANSPARENT )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && FBitSet( s->flags, SURF_TRANSPARENT ))
{ {
draw_alpha_surfaces = true; draw_alpha_surfaces = true;
continue; // draw transparent surfaces later continue; // draw transparent surfaces later
@ -1483,7 +1483,7 @@ void R_SetRenderMode( cl_entity_t *e )
case kRenderTransAlpha: case kRenderTransAlpha:
pglEnable( GL_ALPHA_TEST ); pglEnable( GL_ALPHA_TEST );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
if( gEngfuncs.Host_IsQuakeCompatible( )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{ {
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( 1.0f, 1.0f, 1.0f, tr.blend ); pglColor4f( 1.0f, 1.0f, 1.0f, tr.blend );
@ -1558,7 +1558,7 @@ void R_DrawBrushModel( cl_entity_t *e )
if( rotated ) R_RotateForEntity( e ); if( rotated ) R_RotateForEntity( e );
else R_TranslateForEntity( e ); else R_TranslateForEntity( e );
if( gEngfuncs.Host_IsQuakeCompatible() && FBitSet( clmodel->flags, MODEL_TRANSPARENT )) if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) && FBitSet( clmodel->flags, MODEL_TRANSPARENT ))
e->curstate.rendermode = kRenderTransAlpha; e->curstate.rendermode = kRenderTransAlpha;
e->visframe = tr.realframecount; // visible e->visframe = tr.realframecount; // visible
@ -1599,7 +1599,7 @@ void R_DrawBrushModel( cl_entity_t *e )
for( i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ ) for( i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ )
{ {
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !gEngfuncs.Host_IsQuakeCompatible( )) if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{ {
if( psurf->plane->type != PLANE_Z && !FBitSet( e->curstate.effects, EF_WATERSIDES )) if( psurf->plane->type != PLANE_Z && !FBitSet( e->curstate.effects, EF_WATERSIDES ))
continue; continue;
@ -3343,7 +3343,7 @@ void R_DrawWorld( void )
R_DrawTextureChains(); R_DrawTextureChains();
if( !gEngfuncs.CL_IsDevOverviewMode( )) if( !ENGINE_GET_PARM( PARM_DEV_OVERVIEW ))
{ {
DrawDecalsBatch(); DrawDecalsBatch();
GL_ResetFogColor(); GL_ResetFogColor();
@ -3498,7 +3498,7 @@ void GL_RebuildLightmaps( void )
int i, j; int i, j;
model_t *m; model_t *m;
if( !gEngfuncs.CL_GetRenderParm( PARM_CLIENT_ACTIVE, 0 ) ) if( !ENGINE_GET_PARM( PARM_CLIENT_ACTIVE ) )
return; // wait for worldmodel return; // wait for worldmodel
ClearBits( vid_brightness->flags, FCVAR_CHANGED ); ClearBits( vid_brightness->flags, FCVAR_CHANGED );
@ -3519,7 +3519,7 @@ void GL_RebuildLightmaps( void )
LM_InitBlock(); LM_InitBlock();
for( i = 0; i < gEngfuncs.CL_NumModels(); i++ ) for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
{ {
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL ) if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
continue; continue;
@ -3565,7 +3565,7 @@ void GL_BuildLightmaps( void )
memset( &RI, 0, sizeof( RI )); memset( &RI, 0, sizeof( RI ));
// update the lightmap blocksize // update the lightmap blocksize
if( FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_LARGE_LIGHTMAPS )) if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LARGE_LIGHTMAPS ))
tr.block_size = BLOCK_SIZE_MAX; tr.block_size = BLOCK_SIZE_MAX;
else tr.block_size = BLOCK_SIZE_DEFAULT; else tr.block_size = BLOCK_SIZE_DEFAULT;
@ -3585,7 +3585,7 @@ void GL_BuildLightmaps( void )
LM_InitBlock(); LM_InitBlock();
for( i = 0; i < gEngfuncs.CL_NumModels(); i++ ) for( i = 0; i < ENGINE_GET_PARM( PARM_NUMMODELS ); i++ )
{ {
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL ) if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
continue; continue;

25
ref_gl/gl_studio.c

@ -602,12 +602,12 @@ void R_StudioSetUpTransform( cl_entity_t *e )
VectorCopy( e->angles, angles ); VectorCopy( e->angles, angles );
// interpolate monsters position (moved into UpdateEntityFields by user request) // interpolate monsters position (moved into UpdateEntityFields by user request)
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_COMPUTE_STUDIO_LERP )) if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPUTE_STUDIO_LERP ))
{ {
R_StudioLerpMovement( e, g_studio.time, origin, angles ); R_StudioLerpMovement( e, g_studio.time, origin, angles );
} }
if( !FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_COMPENSATE_QUAKE_BUG )) if( !FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_COMPENSATE_QUAKE_BUG ))
angles[PITCH] = -angles[PITCH]; // stupid quake bug angles[PITCH] = -angles[PITCH]; // stupid quake bug
// don't rotate clients, only aim // don't rotate clients, only aim
@ -1402,7 +1402,7 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
msurface_t *psurf = NULL; msurface_t *psurf = NULL;
pmtrace_t trace; pmtrace_t trace;
if( FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_WRITE_LARGE_COORD )) if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_WRITE_LARGE_COORD ))
{ {
vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f; vecEnd[0] = origin[0] - mv->skyvec_x * 65536.0f;
vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f; vecEnd[1] = origin[1] - mv->skyvec_y * 65536.0f;
@ -2703,7 +2703,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 || !gEngfuncs.Host_IsLocalGame( ) || !RI.drawWorld ) && info->model[0] ) if(( gpGlobals->developer || !ENGINE_GET_PARM( PARM_LOCAL_GAME ) || !RI.drawWorld ) && info->model[0] )
{ {
if( Q_strcmp( state->name, info->model )) if( Q_strcmp( state->name, info->model ))
{ {
@ -3353,7 +3353,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
m_nPlayerIndex = pplayer->number - 1; m_nPlayerIndex = pplayer->number - 1;
if( m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients() ) if( m_nPlayerIndex < 0 || m_nPlayerIndex >= ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
return 0; return 0;
RI.currentmodel = R_StudioSetupPlayerModel( m_nPlayerIndex ); RI.currentmodel = R_StudioSetupPlayerModel( m_nPlayerIndex );
@ -3435,7 +3435,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
RI.currententity->curstate.body = 255; RI.currententity->curstate.body = 255;
} }
if( !( !gpGlobals->developer && gEngfuncs.GetMaxClients() == 1 ) && ( RI.currentmodel == RI.currententity->model )) if( !( !gpGlobals->developer && ENGINE_GET_PARM( PARM_MAX_CLIENTS ) == 1 ) && ( RI.currentmodel == RI.currententity->model ))
RI.currententity->curstate.body = 1; // force helmet RI.currententity->curstate.body = 1; // force helmet
lighting.plightvec = dir; lighting.plightvec = dir;
@ -3497,7 +3497,8 @@ static int R_StudioDrawModel( int flags )
entity_state_t deadplayer; entity_state_t deadplayer;
int result; int result;
if( RI.currententity->curstate.renderamt <= 0 || RI.currententity->curstate.renderamt > gEngfuncs.GetMaxClients() ) if( RI.currententity->curstate.renderamt <= 0 ||
RI.currententity->curstate.renderamt > ENGINE_GET_PARM( PARM_MAX_CLIENTS ) )
return 0; return 0;
// get copy of player // get copy of player
@ -3648,11 +3649,11 @@ void R_RunViewmodelEvents( void )
if( r_drawviewmodel->value == 0 ) if( r_drawviewmodel->value == 0 )
return; return;
if( gEngfuncs.CL_IsThirdPersonMode( )) if( ENGINE_GET_PARM( PARM_THIRDPERSON ))
return; return;
// ignore in thirdperson, camera view or client is died // ignore in thirdperson, camera view or client is died
if( !RP_NORMALPASS() || gEngfuncs.GetLocalHealth() <= 0 || !CL_IsViewEntityLocalPlayer()) if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return; return;
RI.currententity = gEngfuncs.GetViewModel(); RI.currententity = gEngfuncs.GetViewModel();
@ -3700,11 +3701,11 @@ void R_DrawViewModel( void )
if( r_drawviewmodel->value == 0 ) if( r_drawviewmodel->value == 0 )
return; return;
if( gEngfuncs.CL_IsThirdPersonMode( )) if( ENGINE_GET_PARM( PARM_THIRDPERSON ))
return; return;
// ignore in thirdperson, camera view or client is died // ignore in thirdperson, camera view or client is died
if( !RP_NORMALPASS() || gEngfuncs.GetLocalHealth() <= 0 || !CL_IsViewEntityLocalPlayer()) if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return; return;
tr.blend = gEngfuncs.CL_FxBlend( view ) / 255.0f; tr.blend = gEngfuncs.CL_FxBlend( view ) / 255.0f;
@ -3825,7 +3826,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
gEngfuncs.Image_SetMDLPointer((byte *)phdr + ptexture->index); gEngfuncs.Image_SetMDLPointer((byte *)phdr + ptexture->index);
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768; size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( gEngfuncs.CL_GetRenderParm( PARM_FEATURES, 0 ), ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED )) if( FBitSet( ENGINE_GET_PARM( PARM_FEATURES ), ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))
flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing flags |= TF_KEEP_SOURCE; // Paranoia2 texture alpha-tracing
// build the texname // build the texname

2
ref_gl/gl_triapi.c

@ -204,7 +204,7 @@ TriWorldToScreen
convert world coordinates (x,y,z) into screen (x, y) convert world coordinates (x,y,z) into screen (x, y)
============= =============
*/ */
int TriWorldToScreen( float *world, float *screen ) int TriWorldToScreen( const float *world, float *screen )
{ {
int retval; int retval;

2
ref_gl/gl_warp.c

@ -309,7 +309,7 @@ void R_AddSkyBoxSurface( msurface_t *fa )
float *v; float *v;
int i; int i;
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) && fa->polys && !tr.fCustomSkybox ) if( ENGINE_GET_PARM( PARM_SKY_SPHERE ) && fa->polys && !tr.fCustomSkybox )
{ {
glpoly_t *p = fa->polys; glpoly_t *p = fa->polys;

Loading…
Cancel
Save