ref: now it compiles, not linking yet. ref_api header moved to engine/ to clarify, that it's sort of engine internals

This commit is contained in:
Alibek Omarov 2019-03-06 16:23:33 +03:00
parent 437ba6d7a2
commit e7234bada2
42 changed files with 1062 additions and 907 deletions

View File

@ -19,7 +19,6 @@ PARTICLES MANAGEMENT
static int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
static int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
static int ramp3[6] = { 0x6d, 0x6b, 6, 5, 4, 3 };
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
static int gSparkRamp[9] = { 0xfe, 0xfd, 0xfc, 0x6f, 0x6e, 0x6d, 0x6c, 0x67, 0x60 };
static color24 gTracerColors[] =
@ -2097,7 +2096,6 @@ void CL_FreeDeadBeams()
}
}
void CL_DrawEFX( float time, qboolean fTrans )
{
CL_FreeDeadBeams();
@ -2112,3 +2110,87 @@ void CL_DrawEFX( float time, qboolean fTrans )
}
}
void CL_ThinkParticle( double frametime, particle_t *p )
{
float time3 = 15.0f * frametime;
float time2 = 10.0f * frametime;
float time1 = 5.0f * frametime;
float dvel = 4.0f * frametime;
float grav = frametime * clgame.movevars.gravity * 0.05f;
if( p->type != pt_clientcustom )
{
// update position.
VectorMA( p->org, frametime, p->vel, p->org );
}
switch( p->type )
{
case pt_static:
break;
case pt_fire:
p->ramp += time1;
if( p->ramp >= 6.0f ) p->die = -1.0f;
else p->color = ramp3[(int)p->ramp];
p->vel[2] += grav;
break;
case pt_explode:
p->ramp += time2;
if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp1[(int)p->ramp];
VectorMA( p->vel, dvel, p->vel, p->vel );
p->vel[2] -= grav;
break;
case pt_explode2:
p->ramp += time3;
if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp2[(int)p->ramp];
VectorMA( p->vel,-frametime, p->vel, p->vel );
p->vel[2] -= grav;
break;
case pt_blob:
if( p->packedColor == 255 )
{
// normal blob explosion
VectorMA( p->vel, dvel, p->vel, p->vel );
p->vel[2] -= grav;
break;
}
case pt_blob2:
if( p->packedColor == 255 )
{
// normal blob explosion
p->vel[0] -= p->vel[0] * dvel;
p->vel[1] -= p->vel[1] * dvel;
p->vel[2] -= grav;
}
else
{
p->ramp += time2;
if( p->ramp >= 9.0f ) p->ramp = 0.0f;
p->color = gSparkRamp[(int)p->ramp];
VectorMA( p->vel, -frametime * 0.5f, p->vel, p->vel );
p->type = COM_RandomLong( 0, 3 ) ? pt_blob : pt_blob2;
p->vel[2] -= grav * 5.0f;
}
break;
case pt_grav:
p->vel[2] -= grav * 20.0f;
break;
case pt_slowgrav:
p->vel[2] -= grav;
break;
case pt_vox_grav:
p->vel[2] -= grav * 8.0f;
break;
case pt_vox_slowgrav:
p->vel[2] -= grav * 4.0f;
break;
case pt_clientcustom:
if( p->callback )
p->callback( p, frametime );
break;
}
}

View File

@ -2930,7 +2930,7 @@ void CL_Init( void )
CL_InitLocal();
R_Init(); // init renderer
VID_Init(); // init video
S_Init(); // init sound
// unreliable buffer. unsed for unreliable commands and voice stream

View File

@ -1020,8 +1020,8 @@ void CL_ParseClientData( sizebuf_t *msg )
}
}
cl.parsecount = i; // ack'd incoming messages.
cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
refState.parsecount = cl.parsecount = i; // ack'd incoming messages.
refState.parsecountmod = cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
frame = &cl.frames[cl.parsecountmod]; // frame at index.
frame->time = cl.mtime[0]; // mark network received time

View File

@ -349,8 +349,8 @@ static void CL_ParseQuakeClientData( sizebuf_t *msg )
// this is the frame update that this message corresponds to
i = cls.netchan.incoming_sequence;
cl.parsecount = i; // ack'd incoming messages.
cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
refState.parsecount = cl.parsecount = i; // ack'd incoming messages.
refState.parsecountmod = cl.parsecountmod = cl.parsecount & CL_UPDATE_MASK; // index into window.
frame = &cl.frames[cl.parsecountmod]; // frame at index.
frame->time = cl.mtime[0]; // mark network received time
frame->receivedtime = host.realtime; // time now that we are parsing.

View File

@ -82,6 +82,45 @@ static uint pfnFileBufferCRC32( const void *buffer, const int length )
return CRC32_Final( modelCRC );
}
/*
=================
R_EnvShot
=================
*/
static void R_EnvShot( const float *vieworg, const char *name, qboolean skyshot, int shotsize )
{
static vec3_t viewPoint;
if( !COM_CheckString( name ))
return;
if( cls.scrshot_action != scrshot_inactive )
{
if( cls.scrshot_action != scrshot_skyshot && cls.scrshot_action != scrshot_envshot )
Con_Printf( S_ERROR "R_%sShot: subsystem is busy, try for next frame.\n", skyshot ? "Sky" : "Env" );
return;
}
cls.envshot_vieworg = NULL; // use client view
Q_strncpy( cls.shotname, name, sizeof( cls.shotname ));
if( vieworg )
{
// make sure what viewpoint don't temporare
VectorCopy( vieworg, viewPoint );
cls.envshot_vieworg = viewPoint;
cls.envshot_disable_vis = true;
}
// make request for envshot
if( skyshot ) cls.scrshot_action = scrshot_skyshot;
else cls.scrshot_action = scrshot_envshot;
// catch negative values
cls.envshot_viewsize = max( 0, shotsize );
}
/*
=============
CL_GenericHandle
@ -143,7 +182,7 @@ static render_api_t gRenderAPI =
NULL,
NULL,
NULL, // CL_DrawParticlesExternal,
NULL, // R_EnvShot,
R_EnvShot,
pfnSPR_LoadExt,
NULL, // R_LightVec,
NULL, // R_StudioGetTexture,

View File

@ -226,6 +226,37 @@ void SCR_MakeLevelShot( void )
Cbuf_AddText( "levelshot\n" );
}
/*
===============
VID_WriteOverviewScript
Create overview script file
===============
*/
void VID_WriteOverviewScript( void )
{
ref_overview_t *ov = &clgame.overView;
string filename;
file_t *f;
Q_snprintf( filename, sizeof( filename ), "overviews/%s.txt", clgame.mapname );
f = FS_Open( filename, "w", false );
if( !f ) return;
FS_Printf( f, "// overview description file for %s.bsp\n\n", clgame.mapname );
FS_Print( f, "global\n{\n" );
FS_Printf( f, "\tZOOM\t%.2f\n", ov->flZoom );
FS_Printf( f, "\tORIGIN\t%.2f\t%.2f\t%.2f\n", ov->origin[0], ov->origin[1], ov->origin[2] );
FS_Printf( f, "\tROTATED\t%i\n", ov->rotated ? 1 : 0 );
FS_Print( f, "}\n\nlayer\n{\n" );
FS_Printf( f, "\tIMAGE\t\"overviews/%s.bmp\"\n", clgame.mapname );
FS_Printf( f, "\tHEIGHT\t%.2f\n", ov->zFar ); // ???
FS_Print( f, "}\n" );
FS_Close( f );
}
/*
================
SCR_MakeScreenShot
@ -264,6 +295,8 @@ void SCR_MakeScreenShot( void )
break;
case scrshot_mapshot:
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_MAPSHOT );
if( iRet )
VID_WriteOverviewScript(); // store overview script too
break;
case scrshot_inactive:
return;

View File

@ -425,7 +425,7 @@ typedef struct
float applied_angle;
} screen_shake_t;
typedef struct
typedef struct remap_info_s
{
unsigned short textures[MAX_SKINS];// alias textures
struct mstudiotex_s *ptexture; // array of textures with local copy of remapped textures
@ -731,7 +731,6 @@ void CL_SaveShot_f( void );
void CL_LevelShot_f( void );
void CL_SetSky_f( void );
void SCR_Viewpos_f( void );
void SCR_TimeRefresh_f( void );
//
// cl_custom.c
@ -963,7 +962,6 @@ void CL_EmitEntities( void );
remap_info_t *CL_GetRemapInfoForEntity( cl_entity_t *e );
void CL_AllocRemapInfo( int topcolor, int bottomcolor );
void CL_FreeRemapInfo( remap_info_t *info );
void R_StudioSetRemapColors( int top, int bottom );
void CL_UpdateRemapInfo( int topcolor, int bottomcolor );
void CL_ClearAllRemaps( void );

View File

@ -184,11 +184,22 @@ static qboolean R_LoadProgs( const char *name )
void R_Shutdown( void )
{
int i;
model_t *mod;
// release SpriteTextures
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( !mod->name[0] ) continue;
Mod_UnloadSpriteModel( mod );
}
memset( clgame.sprites, 0, sizeof( clgame.sprites ));
R_UnloadProgs();
ref.initialized = false;
}
void R_Init( void )
qboolean R_Init( void )
{
char refdll[64];
@ -206,6 +217,10 @@ void R_Init( void )
{
R_Shutdown();
Host_Error( "Can't initialize %s renderer!\n", refdll );
return;
return false;
}
SCR_Init();
return true;
}

View File

@ -43,7 +43,7 @@ void R_GetTextureParms( int *w, int *h, int texnum );
extern convar_t *r_decals;
extern convar_t *r_adjust_fov;
void R_Init( void );
qboolean R_Init( void );
void R_Shutdown( void );
#endif // REF_COMMON_H

View File

@ -29,9 +29,6 @@ static SDL_Cursor* s_pDefaultCursor[20];
#endif
#include "platform/platform.h"
int g_textures[VGUI_MAX_TEXTURES];
int g_textureId = 0;
int g_iBoundTexture;
static enum VGUI_KeyCode s_pVirtualKeyTrans[256];
static enum VGUI_DefaultCursor s_currentCursor;
static HINSTANCE s_pVGuiSupport; // vgui_support library

View File

@ -22,8 +22,6 @@ extern "C" {
#include "port.h"
#define VGUI_MAX_TEXTURES 2048 // a half of total textures count
//
// vgui_draw.c
//

View File

@ -163,17 +163,6 @@ static void VID_Mode_f( void )
R_ChangeDisplaySettings( w, h, Cvar_VariableInteger( "fullscreen" ) );
}
/*
=================
GL_RemoveCommands
=================
*/
void GL_RemoveCommands( void )
{
Cmd_RemoveCommand( "r_info");
}
static void SetWidthAndHeightFromCommandLine()
{
int width, height;
@ -206,6 +195,27 @@ static void SetFullscreenModeFromCommandLine( )
void VID_Init()
{
// system screen width and height (don't suppose for change from console at all)
Cvar_Get( "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
Cvar_Get( "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
window_xpos = Cvar_Get( "_window_xpos", "130", FCVAR_RENDERINFO, "window position by horizontal" );
window_ypos = Cvar_Get( "_window_ypos", "48", FCVAR_RENDERINFO, "window position by vertical" );
vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
vid_displayfrequency = Cvar_Get ( "vid_displayfrequency", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen refresh rate" );
vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
// a1ba: planned to be named vid_mode for compability
// but supported mode list is filled by backends, so numbers are not portable any more
Cmd_AddCommand( "vid_setmode", VID_Mode_f, "display video mode" );
// Set screen resolution and fullscreen mode if passed in on command line.
// This is done after executing opengl.cfg, as the command line values should take priority.
SetWidthAndHeightFromCommandLine();
SetFullscreenModeFromCommandLine();
R_Init(); // init renderer
}

View File

@ -428,173 +428,9 @@ uint LZSS_Decompress( const byte *pInput, byte *pOutput )
return totalBytes;
}
/*
============
COM_FileBase
Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
============
*/
void COM_FileBase( const char *in, char *out )
{
int len, start, end;
len = Q_strlen( in );
if( !len ) return;
// scan backward for '.'
end = len - 1;
while( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
end--;
if( in[end] != '.' )
end = len-1; // no '.', copy to end
else end--; // found ',', copy to left of '.'
// scan backward for '/'
start = len - 1;
while( start >= 0 && in[start] != '/' && in[start] != '\\' )
start--;
if( start < 0 || ( in[start] != '/' && in[start] != '\\' ))
start = 0;
else start++;
// length of new sting
len = end - start + 1;
// Copy partial string
Q_strncpy( out, &in[start], len + 1 );
out[len] = 0;
}
/*
============
COM_FileExtension
============
*/
const char *COM_FileExtension( const char *in )
{
const char *separator, *backslash, *colon, *dot;
separator = Q_strrchr( in, '/' );
backslash = Q_strrchr( in, '\\' );
if( !separator || separator < backslash )
separator = backslash;
colon = Q_strrchr( in, ':' );
if( !separator || separator < colon )
separator = colon;
dot = Q_strrchr( in, '.' );
if( dot == NULL || ( separator && ( dot < separator )))
return "";
return dot + 1;
}
/*
============
COM_FileWithoutPath
============
*/
const char *COM_FileWithoutPath( const char *in )
{
const char *separator, *backslash, *colon;
separator = Q_strrchr( in, '/' );
backslash = Q_strrchr( in, '\\' );
if( !separator || separator < backslash )
separator = backslash;
colon = Q_strrchr( in, ':' );
if( !separator || separator < colon )
separator = colon;
return separator ? separator + 1 : in;
}
/*
============
COM_ExtractFilePath
============
*/
void COM_ExtractFilePath( const char *path, char *dest )
{
const char *src = path + Q_strlen( path ) - 1;
// back up until a \ or the start
while( src != path && !(*(src - 1) == '\\' || *(src - 1) == '/' ))
src--;
if( src != path )
{
memcpy( dest, path, src - path );
dest[src - path - 1] = 0; // cutoff backslash
}
else Q_strcpy( dest, "" ); // file without path
}
/*
============
COM_StripExtension
============
*/
void COM_StripExtension( char *path )
{
size_t length;
length = Q_strlen( path ) - 1;
while( length > 0 && path[length] != '.' )
{
length--;
if( path[length] == '/' || path[length] == '\\' || path[length] == ':' )
return; // no extension
}
if( length ) path[length] = 0;
}
/*
==================
COM_DefaultExtension
==================
*/
void COM_DefaultExtension( char *path, const char *extension )
{
const char *src;
// if path doesn't have a .EXT, append extension
// (extension should include the .)
src = path + Q_strlen( path ) - 1;
while( *src != '/' && src != path )
{
// it has an extension
if( *src == '.' ) return;
src--;
}
Q_strcat( path, extension );
}
/*
==================
COM_ReplaceExtension
==================
*/
void COM_ReplaceExtension( char *path, const char *extension )
{
COM_StripExtension( path );
COM_DefaultExtension( path, extension );
}
/*
==============

View File

@ -490,13 +490,7 @@ void FS_AllowDirectPaths( qboolean enable );
void FS_AddGameDirectory( const char *dir, uint flags );
void FS_AddGameHierarchy( const char *dir, uint flags );
void FS_LoadGameInfo( const char *rootfolder );
void COM_FileBase( const char *in, char *out );
const char *COM_FileExtension( const char *in );
void COM_DefaultExtension( char *path, const char *extension );
void COM_ReplaceExtension( char *path, const char *extension );
void COM_ExtractFilePath( const char *path, char *dest );
const char *FS_GetDiskPath( const char *name, qboolean gamedironly );
const char *COM_FileWithoutPath( const char *in );
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
void W_Close( wfile_t *wad );
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
@ -526,7 +520,6 @@ qboolean FS_SysFileExists( const char *path, qboolean casesensitive );
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
qboolean FS_Delete( const char *path );
int FS_UnGetc( file_t *file, byte c );
void COM_StripExtension( char *path );
fs_offset_t FS_Tell( file_t *file );
qboolean FS_Eof( file_t *file );
int FS_Close( file_t *file );
@ -920,6 +913,7 @@ byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize );
uint LZSS_Decompress( const byte *pInput, byte *pOutput );
void GL_FreeImage( const char *name );
void VID_InitDefaultResolution( void );
void VID_Init( void );
void UI_SetActiveMenu( qboolean fActive );
void Cmd_Null_f( void );

View File

@ -727,3 +727,171 @@ char *va( const char *format, ... )
return s;
}
/*
============
COM_FileBase
Extracts the base name of a file (no path, no extension, assumes '/' as path separator)
============
*/
void COM_FileBase( const char *in, char *out )
{
int len, start, end;
len = Q_strlen( in );
if( !len ) return;
// scan backward for '.'
end = len - 1;
while( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' )
end--;
if( in[end] != '.' )
end = len-1; // no '.', copy to end
else end--; // found ',', copy to left of '.'
// scan backward for '/'
start = len - 1;
while( start >= 0 && in[start] != '/' && in[start] != '\\' )
start--;
if( start < 0 || ( in[start] != '/' && in[start] != '\\' ))
start = 0;
else start++;
// length of new sting
len = end - start + 1;
// Copy partial string
Q_strncpy( out, &in[start], len + 1 );
out[len] = 0;
}
/*
============
COM_FileExtension
============
*/
const char *COM_FileExtension( const char *in )
{
const char *separator, *backslash, *colon, *dot;
separator = Q_strrchr( in, '/' );
backslash = Q_strrchr( in, '\\' );
if( !separator || separator < backslash )
separator = backslash;
colon = Q_strrchr( in, ':' );
if( !separator || separator < colon )
separator = colon;
dot = Q_strrchr( in, '.' );
if( dot == NULL || ( separator && ( dot < separator )))
return "";
return dot + 1;
}
/*
============
COM_FileWithoutPath
============
*/
const char *COM_FileWithoutPath( const char *in )
{
const char *separator, *backslash, *colon;
separator = Q_strrchr( in, '/' );
backslash = Q_strrchr( in, '\\' );
if( !separator || separator < backslash )
separator = backslash;
colon = Q_strrchr( in, ':' );
if( !separator || separator < colon )
separator = colon;
return separator ? separator + 1 : in;
}
/*
============
COM_ExtractFilePath
============
*/
void COM_ExtractFilePath( const char *path, char *dest )
{
const char *src = path + Q_strlen( path ) - 1;
// back up until a \ or the start
while( src != path && !(*(src - 1) == '\\' || *(src - 1) == '/' ))
src--;
if( src != path )
{
memcpy( dest, path, src - path );
dest[src - path - 1] = 0; // cutoff backslash
}
else Q_strcpy( dest, "" ); // file without path
}
/*
============
COM_StripExtension
============
*/
void COM_StripExtension( char *path )
{
size_t length;
length = Q_strlen( path ) - 1;
while( length > 0 && path[length] != '.' )
{
length--;
if( path[length] == '/' || path[length] == '\\' || path[length] == ':' )
return; // no extension
}
if( length ) path[length] = 0;
}
/*
==================
COM_DefaultExtension
==================
*/
void COM_DefaultExtension( char *path, const char *extension )
{
const char *src;
// if path doesn't have a .EXT, append extension
// (extension should include the .)
src = path + Q_strlen( path ) - 1;
while( *src != '/' && src != path )
{
// it has an extension
if( *src == '.' ) return;
src--;
}
Q_strcat( path, extension );
}
/*
==================
COM_ReplaceExtension
==================
*/
void COM_ReplaceExtension( char *path, const char *extension )
{
COM_StripExtension( path );
COM_DefaultExtension( path, extension );
}

View File

@ -111,6 +111,14 @@ int Q_sprintf( char *buffer, const char *format, ... ) _format( 2 );
#define Q_memprint( val ) Q_pretifymem( val, 2 )
char *Q_pretifymem( float value, int digitsafterdecimal );
char *va( const char *format, ... ) _format( 1 );
void COM_FileBase( const char *in, char *out );
const char *COM_FileExtension( const char *in );
void COM_DefaultExtension( char *path, const char *extension );
void COM_ReplaceExtension( char *path, const char *extension );
void COM_ExtractFilePath( const char *path, char *dest );
const char *COM_FileWithoutPath( const char *in );
void COM_StripExtension( char *path );
//
// zone.c

View File

@ -809,3 +809,64 @@ void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolea
if( *fov_x < x ) *fov_x = x;
else *fov_y = y;
}
/*
==================
BoxOnPlaneSide
Returns 1, 2, or 1 + 2
==================
*/
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p )
{
float dist1, dist2;
int sides = 0;
// general case
switch( p->signbits )
{
case 0:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 1:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 2:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 3:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 4:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 5:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 6:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
case 7:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
default:
// shut up compiler
dist1 = dist2 = 0;
break;
}
if( dist1 >= p->dist )
sides = 1;
if( dist2 < p->dist )
sides |= 2;
return sides;
}

View File

@ -196,6 +196,23 @@ qboolean Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 );
float V_CalcFov( float *fov_x, float width, float height );
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x );
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
#define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \
((( p )->type < 3 ) ? \
( \
((p)->dist <= (emins)[(p)->type]) ? \
1 \
: \
( \
((p)->dist >= (emaxs)[(p)->type]) ? \
2 \
: \
3 \
) \
) \
: \
BoxOnPlaneSide(( emins ), ( emaxs ), ( p )))
extern vec3_t vec3_origin;
extern int boxpnt[6][4];
extern const matrix3x4 matrix3x4_identity;

View File

@ -182,4 +182,11 @@ void Mod_StudioComputeBounds( void *buffer, vec3_t mins, vec3_t maxs, qboolean i
int Mod_HitgroupForStudioHull( int index );
void Mod_ClearStudioCache( void );
//
// mod_sprite.c
//
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags );
void Mod_UnloadSpriteModel( model_t *mod );
#endif//MOD_LOCAL_H

144
engine/common/mod_sprite.c Normal file
View File

@ -0,0 +1,144 @@
/*
mod_sprite.c - sprite loading
Copyright (C) 2010 Uncle Mike
Copyright (C) 2019 a1batross
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 "common.h"
#include "sprite.h"
#include "studio.h"
#ifndef XASH_DEDICATED
#include "ref_common.h"
#endif // XASH_DEDICATED
/*
====================
Mod_LoadSpriteModel
load sprite model
====================
*/
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags )
{
dsprite_q1_t *pinq1;
dsprite_hl_t *pinhl;
dsprite_t *pin;
short *numi = NULL;
msprite_t *psprite;
int i, size;
if( loaded ) *loaded = false;
pin = (dsprite_t *)buffer;
mod->type = mod_sprite;
i = pin->version;
if( pin->ident != IDSPRITEHEADER )
{
Con_DPrintf( S_ERROR "%s has wrong id (%x should be %x)\n", mod->name, pin->ident, IDSPRITEHEADER );
return;
}
if( i != SPRITE_VERSION_Q1 && i != SPRITE_VERSION_HL && i != SPRITE_VERSION_32 )
{
Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i or %i)\n", mod->name, i, SPRITE_VERSION_Q1, SPRITE_VERSION_HL );
return;
}
mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name ));
if( i == SPRITE_VERSION_Q1 || i == SPRITE_VERSION_32 )
{
pinq1 = (dsprite_q1_t *)buffer;
size = sizeof( msprite_t ) + ( pinq1->numframes - 1 ) * sizeof( psprite->frames );
psprite = Mem_Calloc( mod->mempool, size );
mod->cache.data = psprite; // make link to extradata
psprite->type = pinq1->type;
psprite->texFormat = SPR_ADDITIVE; //SPR_ALPHTEST;
psprite->numframes = mod->numframes = pinq1->numframes;
psprite->facecull = SPR_CULL_FRONT;
psprite->radius = pinq1->boundingradius;
psprite->synctype = pinq1->synctype;
// LordHavoc: hack to allow sprites to be non-fullbright
for( i = 0; i < MAX_QPATH && mod->name[i]; i++ )
if( mod->name[i] == '!' )
psprite->texFormat = SPR_ALPHTEST;
mod->mins[0] = mod->mins[1] = -pinq1->bounds[0] * 0.5f;
mod->maxs[0] = mod->maxs[1] = pinq1->bounds[0] * 0.5f;
mod->mins[2] = -pinq1->bounds[1] * 0.5f;
mod->maxs[2] = pinq1->bounds[1] * 0.5f;
numi = NULL;
}
else if( i == SPRITE_VERSION_HL )
{
pinhl = (dsprite_hl_t *)buffer;
size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
psprite = Mem_Calloc( mod->mempool, size );
mod->cache.data = psprite; // make link to extradata
psprite->type = pinhl->type;
psprite->texFormat = pinhl->texFormat;
psprite->numframes = mod->numframes = pinhl->numframes;
psprite->facecull = pinhl->facetype;
psprite->radius = pinhl->boundingradius;
psprite->synctype = pinhl->synctype;
mod->mins[0] = mod->mins[1] = -pinhl->bounds[0] * 0.5f;
mod->maxs[0] = mod->maxs[1] = pinhl->bounds[0] * 0.5f;
mod->mins[2] = -pinhl->bounds[1] * 0.5f;
mod->maxs[2] = pinhl->bounds[1] * 0.5f;
numi = (short *)(pinhl + 1);
}
if( Host_IsDedicated() )
{
// skip frames loading
if( loaded ) *loaded = true; // done
psprite->numframes = 0;
return;
}
// continue loading frames
#ifndef XASH_DEDICATED
ref.dllFuncs.Mod_LoadModel( mod_sprite, mod, buffer, loaded, texFlags );
#endif
}
/*
====================
Mod_UnloadSpriteModel
release sprite model and frames
====================
*/
void Mod_UnloadSpriteModel( model_t *mod )
{
Assert( mod != NULL );
if( mod->type == mod_sprite )
{
#ifndef XASH_DEDICATED
if( host.type != HOST_DEDICATED )
{
ref.dllFuncs.Mod_UnloadModel( mod );
}
#endif
Mem_FreePool( &mod->mempool );
memset( mod, 0, sizeof( *mod ));
}
}

View File

@ -192,64 +192,3 @@ int RankForContents( int contents )
default: return 13; // any user contents has more priority than default
}
}
/*
==================
BoxOnPlaneSide
Returns 1, 2, or 1 + 2
==================
*/
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p )
{
float dist1, dist2;
int sides = 0;
// general case
switch( p->signbits )
{
case 0:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 1:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
break;
case 2:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 3:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
break;
case 4:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 5:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
break;
case 6:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
case 7:
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
default:
// shut up compiler
dist1 = dist2 = 0;
break;
}
if( dist1 >= p->dist )
sides = 1;
if( dist2 < p->dist )
sides |= 2;
return sides;
}

View File

@ -46,26 +46,8 @@ void ClearLink( link_t *l );
void World_MoveBounds( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs );
void World_TransformAABB( matrix4x4 transform, const vec3_t mins, const vec3_t maxs, vec3_t outmins, vec3_t outmaxs );
trace_t World_CombineTraces( trace_t *cliptrace, trace_t *trace, edict_t *touch );
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const mplane_t *p );
int RankForContents( int contents );
#define BOX_ON_PLANE_SIDE( emins, emaxs, p ) \
((( p )->type < 3 ) ? \
( \
((p)->dist <= (emins)[(p)->type]) ? \
1 \
: \
( \
((p)->dist >= (emaxs)[(p)->type]) ? \
2 \
: \
3 \
) \
) \
: \
BoxOnPlaneSide(( emins ), ( emaxs ), ( p )))
#define check_angles( x ) ( (int)x == 90 || (int)x == 180 || (int)x == 270 || (int)x == -90 || (int)x == -180 || (int)x == -270 )
/*

View File

@ -26,6 +26,7 @@ GNU General Public License for more details.
#include "com_model.h"
#include "studio.h"
#include "r_efx.h"
#include "cvar.h"
#define REF_API_VERSION 1
@ -67,10 +68,14 @@ typedef struct
typedef struct ref_globals_s
{
qboolean developer;
qboolean video_prepped;
float time; // cl.time
float oldtime; // cl.oldtime
int parsecount; // cl.parsecount
int parsecountmod; // cl.parsecountmod
// viewport width and height
int width;
int height;
@ -120,7 +125,18 @@ enum ref_shared_texture_e
REF_ALPHASKY_TEXTURE,
};
typedef enum ref_connstate_e
{
ref_ca_disconnected = 0,// not talking to a server
ref_ca_connecting, // sending request packets to the server
ref_ca_connected, // netchan_t established, waiting for svc_serverdata
ref_ca_validate, // download resources, validating, auth on server
ref_ca_active, // game views should be displayed
ref_ca_cinematic, // playing a cinematic, not connected to a server
} ref_connstate_t;
struct con_nprint_s;
struct remap_info_s;
typedef struct ref_api_s
{
@ -129,10 +145,14 @@ typedef struct ref_api_s
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
// cvar handlers
cvar_t *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *description );
cvar_t *(*pfnGetCvarPointer)( const char *name );
convar_t *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *description );
convar_t *(*pfnGetCvarPointer)( const char *name );
float (*pfnGetCvarFloat)( const char *szName );
const char *(*pfnGetCvarString)( const char *szName );
@ -146,13 +166,21 @@ typedef struct ref_api_s
void (*Cbuf_AddText)( const char *commands );
void (*Cbuf_InsertText)( const char *commands );
void (*Cbuf_Execute)( void );
void (*Cbuf_SetOpenGLConfigHack)( qboolean set ); // host.apply_opengl_config
// logging
void (*Con_VPrintf)( const char *fmt, va_list args );
void (*Con_Printf)( const char *fmt, ... );
void (*Con_DPrintf)( const char *fmt, ... );
void (*Con_Printf)( const char *fmt, ... ); // typical console allowed messages
void (*Con_DPrintf)( const char *fmt, ... ); // -dev 1
void (*Con_Reportf)( const char *fmt, ... ); // -dev 2
// debug print
void (*Con_NPrintf)( int pos, const char *fmt, ... );
void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... );
void (*CL_CenterPrint)( const char *fmt, ... );
void (*Con_DrawStringLen)( const char *pText, int *length, int *height );
int (*Con_DrawString)( int x, int y, const char *string, rgba_t setColor );
void (*CL_DrawCenterPrint)();
// entity management
struct cl_entity_s *(*GetLocalPlayer)( void );
@ -160,11 +188,14 @@ typedef struct ref_api_s
struct cl_entity_s *(*GetEntityByIndex)( int idx );
int (*pfnNumberOfEntities)( void );
struct cl_entity_s *(*R_BeamGetEntity)( int index );
struct cl_entity_s *(*CL_GetWaterEntity)( vec3_t p );
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
// brushes
int (*Mod_SampleSizeForFace)( struct msurface_s *surf );
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
struct world_static_s *(*GetWorld)( void ); // returns &world
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
// studio models
void (*R_StudioSlerpBones)( int numbones, vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
@ -174,19 +205,25 @@ typedef struct ref_api_s
// efx
void (*CL_DrawEFX)( float time, qboolean fTrans );
void (*CL_ThinkParticle)( double frametime, particle_t *p );
void (*R_FreeDeadParticles)( particle_t **ppparticles );
efrag_t* (*GetEfragsFreeList)( void ); // clgame.free_efrags
void (*SetEfragsFreeList)( efrag_t* ); // clgame.free_efrags
color24 *(*GetTracerColors)( int num );
// model management
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
void *(*Mod_Extradata)( int type, model_t *model );
struct model_s *(*pfnGetModelByIndex)( int index ); // CL_ModelHandle
struct model_s *(*Mod_GetCurrentLoadingModel)( void ); // loadmodel
void (*Mod_SetCurrentLoadingModel)( struct model_s* ); // loadmodel
int (*CL_NumModels)( void );
// trace
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_t (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );
// remap
struct remap_info_s *(*CL_GetRemapInfoForEntity)( cl_entity_t *e );
void (*CL_AllocRemapInfo)( int topcolor, int bottomcolor );
void (*CL_FreeRemapInfo)( struct remap_info_s *info );
void (*CL_UpdateRemapInfo)( int topcolor, int bottomcolor );
// utils
void (*CL_ExtraUpdate)( void );
@ -198,6 +235,12 @@ typedef struct ref_api_s
struct screenfade_s *(*GetScreenFade)( void );
struct client_textmessage_s *(*pfnTextMessageGet)( const char *pName );
void (*GetPredictedOrigin)( vec3_t v );
byte *(*CL_GetPaletteColor)(int color); // clgame.palette[color]
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
// studio interface
player_info_t *(*pfnPlayerInfo)( int index );
entity_state_t *(*pfnGetPlayerState)( int index );
// memory
byte *(*_Mem_AllocPool)( const char *name, const char *filename, int fileline );
@ -212,6 +255,10 @@ typedef struct ref_api_s
void *(*COM_GetProcAddress)( void *handle, const char *name );
// filesystem
byte* (*COM_LoadFile)( const char *path, fs_offset_t *pLength, qboolean gamedironly );
char* (*COM_ParseFile)( char *data, char *token );
// use Mem_Free instead
// void (*COM_FreeFile)( void *buffer );
int (*FS_FileExists)( const char *filename, int gamedironly );
// GL
@ -221,11 +268,14 @@ typedef struct ref_api_s
void (*GL_DestroyContext)( );
void *(*GL_GetProcAddress)( const char *name );
// gamma
void (*BuildGammaTable)( float lightgamma, float brightness );
byte (*LightToTexGamma)( byte color ); // software gamma support
// renderapi
lightstyle_t* (*GetLightStyle)( int number );
dlight_t* (*GetDynamicLight)( int number );
dlight_t* (*GetEntityLight)( int number );
byte (*LightToTexGamma)( byte color ); // software gamma support
dlight_t* (*GetDynamicLight)( int number );
dlight_t* (*GetEntityLight)( int number );
int (*R_FatPVS)( const float *org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis );
void *(*AVI_LoadVideo)( const char *filename, qboolean load_audio );
int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration );
@ -248,12 +298,21 @@ typedef struct ref_api_s
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
// event api
struct physent_s *(*EV_GetPhysent)( int idx );
struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend );
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
struct movevars_s *(*pfnGetMoveVars)( void );
// imagelib
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
// client exports
void (*pfnDrawNormalTriangles)( void );
void (*pfnDrawTransparentTriangles)( void );
int (*pfnGetRenderInterface)( int version, render_api_t *renderfuncs, render_interface_t *callback );
int (*CL_GetRenderParm)( int parm, int arg ); // generic
} ref_api_t;
struct mip_s;

View File

@ -20,6 +20,9 @@ GNU General Public License for more details.
#include "alias.h"
#include "pm_local.h"
#include "cl_tent.h"
#include "common.h"
#include "client.h"
#include "pmtrace.h"
extern cvar_t r_shadows;
@ -418,6 +421,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
static rgbdata_t skin;
char name[MAX_QPATH];
int i;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
skin.width = width;
skin.height = height;
@ -427,7 +431,7 @@ rgbdata_t *Mod_CreateSkinData( model_t *mod, byte *data, int width, int height )
skin.encode = DXT_ENCODE_DEFAULT;
skin.numMips = 1;
skin.buffer = data;
skin.palette = (byte *)&clgame.palette;
skin.palette = (byte *)gEngfuncs.CL_GetPaletteColor( 0 );
skin.size = width * height;
if( !Image_CustomPalette() )
@ -480,6 +484,7 @@ void *Mod_LoadSingleSkin( daliasskintype_t *pskintype, int skinnum, int size )
string name, lumaname;
string checkname;
rgbdata_t *pic;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
Q_snprintf( name, sizeof( name ), "%s:frame%i", loadmodel->name, skinnum );
Q_snprintf( lumaname, sizeof( lumaname ), "%s:luma%i", loadmodel->name, skinnum );
@ -557,7 +562,7 @@ void *Mod_LoadAllSkins( int numskins, daliasskintype_t *pskintype )
int i, size;
if( numskins < 1 || numskins > MAX_SKINS )
Host_Error( "Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins );
gEngfuncs.Host_Error( "Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins );
size = m_pAliasHeader->skinwidth * m_pAliasHeader->skinheight;
@ -631,7 +636,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
if( i != ALIAS_VERSION )
{
Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i)\n", mod->name, i, ALIAS_VERSION );
gEngfuncs.Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i)\n", mod->name, i, ALIAS_VERSION );
return;
}
@ -658,7 +663,7 @@ void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded )
if( m_pAliasHeader->numverts > MAXALIASVERTS )
{
Con_DPrintf( S_ERROR "model %s has too many vertices\n", mod->name );
gEngfuncs.Con_DPrintf( S_ERROR "model %s has too many vertices\n", mod->name );
return;
}
@ -776,7 +781,7 @@ similar to R_StudioDynamicLight
*/
void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
{
movevars_t *mv = &clgame.movevars;
movevars_t *mv = gEngfuncs.pfnGetMoveVars();
vec3_t lightDir, vecSrc, vecEnd;
vec3_t origin, dist, finalLight;
float add, radius, total;
@ -825,9 +830,9 @@ void R_AliasDynamicLight( cl_entity_t *ent, alight_t *plight )
vecEnd[2] = origin[2] - mv->skyvec_z * 8192.0f;
}
trace = CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_IGNORE );
if( trace.ent > 0 ) psurf = PM_TraceSurface( &clgame.pmove->physents[trace.ent], vecSrc, vecEnd );
else psurf = PM_TraceSurface( clgame.pmove->physents, vecSrc, vecEnd );
trace = gEngfuncs.CL_TraceLine( vecSrc, vecEnd, PM_STUDIO_IGNORE );
if( trace.ent > 0 ) psurf = gEngfuncs.EV_TraceSurface( trace.ent, vecSrc, vecEnd );
else psurf = gEngfuncs.EV_TraceSurface( 0, vecSrc, vecEnd );
if( psurf && FBitSet( psurf->flags, SURF_DRAWSKY ))
{
@ -1013,11 +1018,11 @@ R_AliasSetRemapColors
*/
void R_AliasSetRemapColors( int newTop, int newBottom )
{
CL_AllocRemapInfo( newTop, newBottom );
gEngfuncs.CL_AllocRemapInfo( newTop, newBottom );
if( CL_GetRemapInfoForEntity( RI.currententity ))
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{
CL_UpdateRemapInfo( newTop, newBottom );
gEngfuncs.CL_UpdateRemapInfo( newTop, newBottom );
m_fDoRemap = true;
}
}
@ -1177,7 +1182,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 ))
f = ( g_alias.time - e->curstate.animtime ) / ( e->curstate.animtime - e->latched.prevanimtime );
if( cls.demoplayback == DEMO_QUAKE1 )
if( gEngfuncs.IsDemoPlaying() == DEMO_QUAKE1 )
f = f + 1.0f;
g_alias.lerpfrac = bound( 0.0f, f, 1.0f );
@ -1227,7 +1232,7 @@ void R_SetupAliasFrame( cl_entity_t *e, aliashdr_t *paliashdr )
else if( newframe >= paliashdr->numframes )
{
if( newframe > paliashdr->numframes )
Con_Reportf( S_WARN "R_GetAliasFrame: no such frame %d (%s)\n", newframe, e->model->name );
gEngfuncs.Con_Reportf( S_WARN "R_GetAliasFrame: no such frame %d (%s)\n", newframe, e->model->name );
newframe = paliashdr->numframes - 1;
}

View File

@ -16,6 +16,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "mathlib.h"
#include "common.h"
char r_speeds_msg[MAX_SYSPATH];
ref_speeds_t r_stats; // r_speeds counters
@ -184,7 +185,7 @@ void GL_SelectTexture( GLint tmu )
if( tmu >= GL_MaxTextureUnits( ))
{
Con_Reportf( S_ERROR "GL_SelectTexture: bad tmu state %i\n", tmu );
gEngfuncs.Con_Reportf( S_ERROR "GL_SelectTexture: bad tmu state %i\n", tmu );
return;
}
@ -277,7 +278,7 @@ void GL_TextureTarget( uint target )
{
if( glState.activeTMU < 0 || glState.activeTMU >= GL_MaxTextureUnits( ))
{
Con_Reportf( S_ERROR "GL_TextureTarget: bad tmu state %i\n", glState.activeTMU );
gEngfuncs.Con_Reportf( S_ERROR "GL_TextureTarget: bad tmu state %i\n", glState.activeTMU );
return;
}
@ -452,37 +453,6 @@ const envmap_t r_envMapInfo[6] =
{{ 90, 0, 90}, 0 }
};
/*
===============
VID_WriteOverviewScript
Create overview script file
===============
*/
void VID_WriteOverviewScript( void )
{
ref_overview_t *ov = &gEngfuncs.GetOverviewParms();
string filename;
file_t *f;
Q_snprintf( filename, sizeof( filename ), "overviews/%s.txt", clgame.mapname );
f = FS_Open( filename, "w", false );
if( !f ) return;
FS_Printf( f, "// overview description file for %s.bsp\n\n", clgame.mapname );
FS_Print( f, "global\n{\n" );
FS_Printf( f, "\tZOOM\t%.2f\n", ov->flZoom );
FS_Printf( f, "\tORIGIN\t%.2f\t%.2f\t%.2f\n", ov->origin[0], ov->origin[1], ov->origin[2] );
FS_Printf( f, "\tROTATED\t%i\n", ov->rotated ? 1 : 0 );
FS_Print( f, "}\n\nlayer\n{\n" );
FS_Printf( f, "\tIMAGE\t\"overviews/%s.bmp\"\n", clgame.mapname );
FS_Printf( f, "\tHEIGHT\t%.2f\n", ov->zFar ); // ???
FS_Print( f, "}\n" );
FS_Close( f );
}
qboolean VID_ScreenShot( const char *filename, int shot_type )
{
rgbdata_t *r_shot;
@ -511,7 +481,7 @@ qboolean VID_ScreenShot( const char *filename, int shot_type )
break;
case VID_LEVELSHOT:
flags |= IMAGE_RESAMPLE;
if( glState.wideScreen )
if( gpGlobals->wideScreen )
{
height = 480;
width = 800;
@ -528,7 +498,6 @@ qboolean VID_ScreenShot( const char *filename, int shot_type )
width = 320;
break;
case VID_MAPSHOT:
VID_WriteOverviewScript(); // store overview script too
flags |= IMAGE_RESAMPLE|IMAGE_QUANTIZE; // GoldSrc request overviews in 8-bit format
height = 768;
width = 1024;
@ -658,7 +627,7 @@ void R_ShowTextures( void )
if( showHelp )
{
CL_CenterPrint( "use '<-' and '->' keys to change atlas page, ESC to quit", 0.25f );
gEngfuncs.CL_CenterPrint( "use '<-' and '->' keys to change atlas page, ESC to quit", 0.25f );
showHelp = false;
}
@ -678,7 +647,7 @@ rebuild_page:
w = gpGlobals->width / base_w;
h = gpGlobals->height / base_h;
Con_DrawStringLen( NULL, NULL, &charHeight );
gEngfuncs.Con_DrawStringLen( NULL, NULL, &charHeight );
for( i = j = 0; i < MAX_TEXTURES; i++ )
{
@ -739,11 +708,11 @@ rebuild_page:
shortname[17] = '.';
shortname[18] = '\0';
}
Con_DrawString( x + 1, y + h - charHeight, shortname, color );
gEngfuncs.Con_DrawString( x + 1, y + h - charHeight, shortname, color );
j++, k++;
}
CL_DrawCenterPrint ();
gEngfuncs.CL_DrawCenterPrint ();
pglFinish();
}
@ -852,7 +821,7 @@ void SCR_TimeRefresh_f( void )
double start, stop;
double time;
if( cls.state != ca_active )
if( gEngfuncs.CL_GetConnState() != ref_ca_active )
return;
start = Sys_DoubleTime();
@ -863,7 +832,7 @@ void SCR_TimeRefresh_f( void )
pglDrawBuffer( GL_FRONT );
for( i = 0; i < 128; i++ )
{
refState.viewangles[1] = i / 128.0 * 360.0f;
gpGlobals->viewangles[1] = i / 128.0 * 360.0f;
R_RenderScene();
}
pglFinish();
@ -874,7 +843,7 @@ void SCR_TimeRefresh_f( void )
for( i = 0; i < 128; i++ )
{
R_BeginFrame( true );
refState.viewangles[1] = i / 128.0 * 360.0f;
gpGlobals->viewangles[1] = i / 128.0 * 360.0f;
R_RenderScene();
R_EndFrame();
}
@ -882,5 +851,5 @@ void SCR_TimeRefresh_f( void )
stop = Sys_DoubleTime ();
time = (stop - start);
Con_Printf( "%f seconds (%f fps)\n", time, 128 / time );
gEngfuncs.Con_Printf( "%f seconds (%f fps)\n", time, 128 / time );
}

View File

@ -948,7 +948,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
model_t *model;
vec3_t delta;
model = CL_ModelHandle( pbeam->modelIndex );
model = gEngfuncs.pfnGetModelByIndex( pbeam->modelIndex );
SetBits( pbeam->flags, FBEAM_ISACTIVE );
if( !model || model->type != mod_sprite )
@ -1151,7 +1151,7 @@ passed through this
*/
static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex, float life, float width, float amplitude, float brightness, float speed )
{
model_t *sprite = CL_ModelHandle( modelIndex );
model_t *sprite = gEngfuncs.pfnGetModelByIndex( modelIndex );
if( !sprite ) return;
@ -1260,7 +1260,7 @@ CL_DrawBeams
draw beam loop
==============
*/
void CL_DrawBeams(int fTrans , BEAM *active_beams )
void CL_DrawBeams( int fTrans, BEAM *active_beams )
{
BEAM *pBeam, *pNext;
BEAM *pPrev = NULL;

View File

@ -13,8 +13,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "gl_local.h"
#include "mod_local.h"
#define list_entry( ptr, type, member ) \
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member)))

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "cl_tent.h"
#include "common.h"
#define DECAL_OVERLAP_DISTANCE 2
#define DECAL_DISTANCE 4 // too big values produce more clipped polygons
@ -75,7 +76,7 @@ static void R_DecalUnlink( decal_t *pdecal )
else
{
tmp = pdecal->psurface->pdecals;
if( !tmp ) Host_Error( "D_DecalUnlink: bad decal list\n" );
if( !tmp ) gEngfuncs.Host_Error( "D_DecalUnlink: bad decal list\n" );
while( tmp->pnext )
{
@ -511,7 +512,7 @@ creates mesh for decal on first rendering
glpoly_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, msurface_t *surf )
{
int lnumverts;
glpoly_t *poly;
glpoly_t *poly;
float *v;
int i;
@ -522,7 +523,8 @@ glpoly_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, msurface_t
if( !lnumverts ) return NULL; // probably this never happens
// allocate glpoly
poly = Mem_Calloc( com_studiocache, sizeof( glpoly_t ) + ( lnumverts - 4 ) * VERTEXSIZE * sizeof( float ));
// REFTODO: com_studiocache pool!
poly = Mem_Calloc( r_temppool, sizeof( glpoly_t ) + ( lnumverts - 4 ) * VERTEXSIZE * sizeof( float ));
poly->next = pdecal->polys;
poly->flags = surf->flags;
pdecal->polys = poly;
@ -617,9 +619,10 @@ void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
decal_t *decal = surf->pdecals;
vec4_t textureU, textureV;
float s, t, w, h;
ref_connstate_t state = gEngfuncs.CL_GetConnState();
// we in restore mode
if( cls.state == ca_connected || cls.state == ca_validate )
if( state == ref_ca_connected || state == ref_ca_validate )
{
// NOTE: we may have the decal on this surface that come from another level.
// check duplicate with same position and texture
@ -758,7 +761,7 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
if( textureIndex <= 0 || textureIndex >= MAX_TEXTURES )
{
Con_Printf( S_ERROR "Decal has invalid texture!\n" );
gEngfuncs.Con_Printf( S_ERROR "Decal has invalid texture!\n" );
return;
}
@ -766,19 +769,19 @@ void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos
{
ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
if( modelIndex > 0 ) model = gEngfuncs.pfnGetModelByIndex( modelIndex );
else if( ent != NULL ) model = gEngfuncs.pfnGetModelByIndex( ent->curstate.modelindex );
else return;
}
else if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex );
model = gEngfuncs.pfnGetModelByIndex( modelIndex );
else model = WORLDMODEL;
if( !model ) return;
if( model->type != mod_brush )
{
Con_Printf( S_ERROR "Decals must hit mod_brush!\n" );
gEngfuncs.Con_Printf( S_ERROR "Decals must hit mod_brush!\n" );
return;
}

View File

@ -145,9 +145,9 @@ void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, c
}
if( cols > glConfig.max_2d_texture_size )
Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", cols );
gEngfuncs.Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", cols );
if( rows > glConfig.max_2d_texture_size )
Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", rows );
gEngfuncs.Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", rows );
pglDisable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
@ -220,9 +220,9 @@ void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height,
}
if( cols > glConfig.max_2d_texture_size )
Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", cols );
gEngfuncs.Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", cols );
if( rows > glConfig.max_2d_texture_size )
Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", rows );
gEngfuncs.Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", rows );
tex = R_GetTexture( texture );
GL_Bind( GL_KEEP_UNIT, texture );

View File

@ -14,6 +14,7 @@ GNU General Public License for more details.
*/
#include "gl_local.h"
#include "common.h"
#define TEXTURES_HASH_SIZE (MAX_TEXTURES >> 2)
@ -460,7 +461,7 @@ static size_t GL_CalcTextureSize( GLenum format, int width, int height, int dept
size = width * height * depth * 4;
break;
default:
Host_Error( "GL_CalcTextureSize: bad texture internal format (%u)\n", format );
gEngfuncs.Host_Error( "GL_CalcTextureSize: bad texture internal format (%u)\n", format );
break;
}
@ -1063,7 +1064,7 @@ static void GL_CheckTexImageError( gl_texture_t *tex )
// catch possible errors
if( CVAR_TO_BOOL( gl_check_errors ) && ( err = pglGetError()) != GL_NO_ERROR )
Con_Printf( S_OPENGL_ERROR "%s while uploading %s [%s]\n", GL_ErrorString( err ), tex->name, GL_TargetToString( tex->target ));
gEngfuncs.Con_Printf( S_OPENGL_ERROR "%s while uploading %s [%s]\n", GL_ErrorString( err ), tex->name, GL_TargetToString( tex->target ));
}
/*
@ -1091,7 +1092,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
// make sure what target is correct
if( tex->target == GL_NONE )
{
Con_DPrintf( S_ERROR "GL_UploadTexture: %s is not supported by your hardware\n", tex->name );
gEngfuncs.Con_DPrintf( S_ERROR "GL_UploadTexture: %s is not supported by your hardware\n", tex->name );
return false;
}
@ -1106,7 +1107,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
if(( pic->width * pic->height ) & 3 )
{
// will be resampled, just tell me for debug targets
Con_Reportf( "GL_UploadTexture: %s s&3 [%d x %d]\n", tex->name, pic->width, pic->height );
gEngfuncs.Con_Reportf( "GL_UploadTexture: %s s&3 [%d x %d]\n", tex->name, pic->width, pic->height );
}
buf = pic->buffer;
@ -1124,7 +1125,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic )
{
// track the buffer bounds
if( buf != NULL && buf >= bufend )
Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
gEngfuncs.Host_Error( "GL_UploadTexture: %s image buffer overflow\n", tex->name );
if( ImageDXT( pic->type ))
{
@ -1274,7 +1275,7 @@ qboolean GL_CheckTexName( const char *name )
// because multi-layered textures can exceed name string
if( Q_strlen( name ) >= sizeof( gl_textures->name ))
{
Con_Printf( S_ERROR "LoadTexture: too long name %s (%d)\n", name, Q_strlen( name ));
gEngfuncs.Con_Printf( S_ERROR "LoadTexture: too long name %s (%d)\n", name, Q_strlen( name ));
return false;
}
@ -1292,7 +1293,7 @@ static gl_texture_t *GL_TextureForName( const char *name )
uint hash;
// find the texture in array
hash = COM_HashKey( name, TEXTURES_HASH_SIZE );
hash = gEngfuncs.COM_HashKey( name, TEXTURES_HASH_SIZE );
for( tex = gl_texturesHashTable[hash]; tex != NULL; tex = tex->nextHash )
{
@ -1320,7 +1321,7 @@ static gl_texture_t *GL_AllocTexture( const char *name, texFlags_t flags )
if( i == gl_numTextures )
{
if( gl_numTextures == MAX_TEXTURES )
Host_Error( "GL_AllocTexture: MAX_TEXTURES limit exceeds\n" );
gEngfuncs.Host_Error( "GL_AllocTexture: MAX_TEXTURES limit exceeds\n" );
gl_numTextures++;
}
@ -1334,7 +1335,7 @@ static gl_texture_t *GL_AllocTexture( const char *name, texFlags_t flags )
tex->flags = flags;
// add to hash table
tex->hashValue = COM_HashKey( name, TEXTURES_HASH_SIZE );
tex->hashValue = gEngfuncs.COM_HashKey( name, TEXTURES_HASH_SIZE );
tex->nextHash = gl_texturesHashTable[tex->hashValue];
gl_texturesHashTable[tex->hashValue] = tex;
@ -1359,7 +1360,7 @@ static void GL_DeleteTexture( gl_texture_t *tex )
// debug
if( !tex->name[0] )
{
Con_Printf( S_ERROR "GL_DeleteTexture: trying to free unnamed texture with texnum %i\n", tex->texnum );
gEngfuncs.Con_Printf( S_ERROR "GL_DeleteTexture: trying to free unnamed texture with texnum %i\n", tex->texnum );
return;
}
@ -1523,20 +1524,20 @@ int GL_LoadTextureArray( const char **names, int flags )
// mixed mode: DXT + RGB
if( pic->type != src->type )
{
Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch image format for %s and %s\n", names[0], names[i] );
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch image format for %s and %s\n", names[0], names[i] );
break;
}
// different mipcount
if( pic->numMips != src->numMips )
{
Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch mip count for %s and %s\n", names[0], names[i] );
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch mip count for %s and %s\n", names[0], names[i] );
break;
}
if( pic->encode != src->encode )
{
Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch custom encoding for %s and %s\n", names[0], names[i] );
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch custom encoding for %s and %s\n", names[0], names[i] );
break;
}
@ -1546,7 +1547,7 @@ int GL_LoadTextureArray( const char **names, int flags )
if( pic->size != src->size )
{
Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch image size for %s and %s\n", names[0], names[i] );
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: mismatch image size for %s and %s\n", names[0], names[i] );
break;
}
}
@ -1582,7 +1583,7 @@ int GL_LoadTextureArray( const char **names, int flags )
// there were errors
if( !pic || ( pic->depth != numLayers ))
{
Con_Printf( S_ERROR "GL_LoadTextureArray: not all layers were loaded. Texture array is not created\n" );
gEngfuncs.Con_Printf( S_ERROR "GL_LoadTextureArray: not all layers were loaded. Texture array is not created\n" );
if( pic ) FS_FreeImage( pic );
return 0;
}
@ -1631,7 +1632,7 @@ int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags
if( update )
{
if( tex == NULL )
Host_Error( "GL_LoadTextureFromBuffer: couldn't find texture %s for update\n", name );
gEngfuncs.Host_Error( "GL_LoadTextureFromBuffer: couldn't find texture %s for update\n", name );
SetBits( tex->flags, flags );
}
else
@ -1799,19 +1800,19 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
}
else
{
Con_Printf( S_ERROR "GL_ProcessTexture: bad operation for %s\n", image->name );
gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: bad operation for %s\n", image->name );
return;
}
if( !image->original )
{
Con_Printf( S_ERROR "GL_ProcessTexture: no input data for %s\n", image->name );
gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: no input data for %s\n", image->name );
return;
}
if( ImageDXT( image->original->type ))
{
Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name );
gEngfuncs.Con_Printf( S_ERROR "GL_ProcessTexture: can't process compressed texture %s\n", image->name );
return;
}
@ -1960,8 +1961,8 @@ void R_TextureList_f( void )
gl_texture_t *image;
int i, texCount, bytes = 0;
Con_Printf( "\n" );
Con_Printf( " -id- -w- -h- -size- -fmt- -type- -data- -encode- -wrap- -depth- -name--------\n" );
gEngfuncs.Con_Printf( "\n" );
gEngfuncs.Con_Printf( " -id- -w- -h- -size- -fmt- -type- -data- -encode- -wrap- -depth- -name--------\n" );
for( i = texCount = 0, image = gl_textures; i < gl_numTextures; i++, image++ )
{
@ -1970,192 +1971,192 @@ void R_TextureList_f( void )
bytes += image->size;
texCount++;
Con_Printf( "%4i: ", i );
Con_Printf( "%4i %4i ", image->width, image->height );
Con_Printf( "%12s ", Q_memprint( image->size ));
gEngfuncs.Con_Printf( "%4i: ", i );
gEngfuncs.Con_Printf( "%4i %4i ", image->width, image->height );
gEngfuncs.Con_Printf( "%12s ", Q_memprint( image->size ));
switch( image->format )
{
case GL_COMPRESSED_RGBA_ARB:
Con_Printf( "CRGBA " );
gEngfuncs.Con_Printf( "CRGBA " );
break;
case GL_COMPRESSED_RGB_ARB:
Con_Printf( "CRGB " );
gEngfuncs.Con_Printf( "CRGB " );
break;
case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
Con_Printf( "CLA " );
gEngfuncs.Con_Printf( "CLA " );
break;
case GL_COMPRESSED_LUMINANCE_ARB:
Con_Printf( "CL " );
gEngfuncs.Con_Printf( "CL " );
break;
case GL_COMPRESSED_ALPHA_ARB:
Con_Printf( "CA " );
gEngfuncs.Con_Printf( "CA " );
break;
case GL_COMPRESSED_INTENSITY_ARB:
Con_Printf( "CI " );
gEngfuncs.Con_Printf( "CI " );
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
Con_Printf( "DXT1c " );
gEngfuncs.Con_Printf( "DXT1c " );
break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
Con_Printf( "DXT1a " );
gEngfuncs.Con_Printf( "DXT1a " );
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
Con_Printf( "DXT3 " );
gEngfuncs.Con_Printf( "DXT3 " );
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
Con_Printf( "DXT5 " );
gEngfuncs.Con_Printf( "DXT5 " );
break;
case GL_COMPRESSED_RED_GREEN_RGTC2_EXT:
Con_Printf( "ATI2 " );
gEngfuncs.Con_Printf( "ATI2 " );
break;
case GL_RGBA:
Con_Printf( "RGBA " );
gEngfuncs.Con_Printf( "RGBA " );
break;
case GL_RGBA8:
Con_Printf( "RGBA8 " );
gEngfuncs.Con_Printf( "RGBA8 " );
break;
case GL_RGBA4:
Con_Printf( "RGBA4 " );
gEngfuncs.Con_Printf( "RGBA4 " );
break;
case GL_RGB:
Con_Printf( "RGB " );
gEngfuncs.Con_Printf( "RGB " );
break;
case GL_RGB8:
Con_Printf( "RGB8 " );
gEngfuncs.Con_Printf( "RGB8 " );
break;
case GL_RGB5:
Con_Printf( "RGB5 " );
gEngfuncs.Con_Printf( "RGB5 " );
break;
case GL_LUMINANCE4_ALPHA4:
Con_Printf( "L4A4 " );
gEngfuncs.Con_Printf( "L4A4 " );
break;
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE8_ALPHA8:
Con_Printf( "L8A8 " );
gEngfuncs.Con_Printf( "L8A8 " );
break;
case GL_LUMINANCE4:
Con_Printf( "L4 " );
gEngfuncs.Con_Printf( "L4 " );
break;
case GL_LUMINANCE:
case GL_LUMINANCE8:
Con_Printf( "L8 " );
gEngfuncs.Con_Printf( "L8 " );
break;
case GL_ALPHA8:
Con_Printf( "A8 " );
gEngfuncs.Con_Printf( "A8 " );
break;
case GL_INTENSITY8:
Con_Printf( "I8 " );
gEngfuncs.Con_Printf( "I8 " );
break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24:
Con_Printf( "DPTH24" );
gEngfuncs.Con_Printf( "DPTH24" );
break;
case GL_DEPTH_COMPONENT32F:
Con_Printf( "DPTH32" );
gEngfuncs.Con_Printf( "DPTH32" );
break;
case GL_LUMINANCE16F_ARB:
Con_Printf( "L16F " );
gEngfuncs.Con_Printf( "L16F " );
break;
case GL_LUMINANCE32F_ARB:
Con_Printf( "L32F " );
gEngfuncs.Con_Printf( "L32F " );
break;
case GL_LUMINANCE_ALPHA16F_ARB:
Con_Printf( "LA16F " );
gEngfuncs.Con_Printf( "LA16F " );
break;
case GL_LUMINANCE_ALPHA32F_ARB:
Con_Printf( "LA32F " );
gEngfuncs.Con_Printf( "LA32F " );
break;
case GL_RG16F:
Con_Printf( "RG16F " );
gEngfuncs.Con_Printf( "RG16F " );
break;
case GL_RG32F:
Con_Printf( "RG32F " );
gEngfuncs.Con_Printf( "RG32F " );
break;
case GL_RGB16F_ARB:
Con_Printf( "RGB16F" );
gEngfuncs.Con_Printf( "RGB16F" );
break;
case GL_RGB32F_ARB:
Con_Printf( "RGB32F" );
gEngfuncs.Con_Printf( "RGB32F" );
break;
case GL_RGBA16F_ARB:
Con_Printf( "RGBA16F" );
gEngfuncs.Con_Printf( "RGBA16F" );
break;
case GL_RGBA32F_ARB:
Con_Printf( "RGBA32F" );
gEngfuncs.Con_Printf( "RGBA32F" );
break;
default:
Con_Printf( " ^1ERROR^7 " );
gEngfuncs.Con_Printf( " ^1ERROR^7 " );
break;
}
switch( image->target )
{
case GL_TEXTURE_1D:
Con_Printf( " 1D " );
gEngfuncs.Con_Printf( " 1D " );
break;
case GL_TEXTURE_2D:
Con_Printf( " 2D " );
gEngfuncs.Con_Printf( " 2D " );
break;
case GL_TEXTURE_3D:
Con_Printf( " 3D " );
gEngfuncs.Con_Printf( " 3D " );
break;
case GL_TEXTURE_CUBE_MAP_ARB:
Con_Printf( "CUBE " );
gEngfuncs.Con_Printf( "CUBE " );
break;
case GL_TEXTURE_RECTANGLE_EXT:
Con_Printf( "RECT " );
gEngfuncs.Con_Printf( "RECT " );
break;
case GL_TEXTURE_2D_ARRAY_EXT:
Con_Printf( "ARRAY " );
gEngfuncs.Con_Printf( "ARRAY " );
break;
default:
Con_Printf( "???? " );
gEngfuncs.Con_Printf( "???? " );
break;
}
if( image->flags & TF_NORMALMAP )
Con_Printf( "normal " );
gEngfuncs.Con_Printf( "normal " );
else Con_Printf( "diffuse " );
switch( image->encode )
{
case DXT_ENCODE_COLOR_YCoCg:
Con_Printf( "YCoCg " );
gEngfuncs.Con_Printf( "YCoCg " );
break;
case DXT_ENCODE_NORMAL_AG_ORTHO:
Con_Printf( "ortho " );
gEngfuncs.Con_Printf( "ortho " );
break;
case DXT_ENCODE_NORMAL_AG_STEREO:
Con_Printf( "stereo " );
gEngfuncs.Con_Printf( "stereo " );
break;
case DXT_ENCODE_NORMAL_AG_PARABOLOID:
Con_Printf( "parabolic " );
gEngfuncs.Con_Printf( "parabolic " );
break;
case DXT_ENCODE_NORMAL_AG_QUARTIC:
Con_Printf( "quartic " );
gEngfuncs.Con_Printf( "quartic " );
break;
case DXT_ENCODE_NORMAL_AG_AZIMUTHAL:
Con_Printf( "azimuthal " );
gEngfuncs.Con_Printf( "azimuthal " );
break;
default:
Con_Printf( "default " );
gEngfuncs.Con_Printf( "default " );
break;
}
if( image->flags & TF_CLAMP )
Con_Printf( "clamp " );
gEngfuncs.Con_Printf( "clamp " );
else if( image->flags & TF_BORDER )
Con_Printf( "border " );
gEngfuncs.Con_Printf( "border " );
else Con_Printf( "repeat " );
Con_Printf( " %d ", image->depth );
Con_Printf( " %s\n", image->name );
gEngfuncs.Con_Printf( " %d ", image->depth );
gEngfuncs.Con_Printf( " %s\n", image->name );
}
Con_Printf( "---------------------------------------------------------\n" );
Con_Printf( "%i total textures\n", texCount );
Con_Printf( "%s total memory used\n", Q_memprint( bytes ));
Con_Printf( "\n" );
gEngfuncs.Con_Printf( "---------------------------------------------------------\n" );
gEngfuncs.Con_Printf( "%i total textures\n", texCount );
gEngfuncs.Con_Printf( "%s total memory used\n", Q_memprint( bytes ));
gEngfuncs.Con_Printf( "\n" );
}
/*
@ -2171,7 +2172,7 @@ void R_InitImages( void )
// create unused 0-entry
Q_strncpy( gl_textures->name, "*unused*", sizeof( gl_textures->name ));
gl_textures->hashValue = COM_HashKey( gl_textures->name, TEXTURES_HASH_SIZE );
gl_textures->hashValue = gEngfuncs.COM_HashKey( gl_textures->name, TEXTURES_HASH_SIZE );
gl_textures->nextHash = gl_texturesHashTable[gl_textures->hashValue];
gl_texturesHashTable[gl_textures->hashValue] = gl_textures;
gl_numTextures = 1;
@ -2180,7 +2181,7 @@ void R_InitImages( void )
R_SetTextureParameters();
GL_CreateInternalTextures();
Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
gEngfuncs.Cmd_AddCommand( "texturelist", R_TextureList_f, "display loaded textures list" );
}
/*
@ -2193,7 +2194,7 @@ void R_ShutdownImages( void )
gl_texture_t *tex;
int i;
Cmd_RemoveCommand( "texturelist" );
gEngfuncs.Cmd_RemoveCommand( "texturelist" );
GL_CleanupAllTextureUnits();
for( i = 0, tex = gl_textures; i < gl_numTextures; i++, tex++ )

View File

@ -32,27 +32,20 @@ GNU General Public License for more details.
#include "enginefeatures.h"
#include "com_strings.h"
#include "pm_movevars.h"
#include "cvar.h"
#define offsetof(s,m) (size_t)&(((s *)0)->m)
typedef cvar_t convar_t;
void CL_DrawEFX(double, double);
void *CL_ModelHandle(int);
void *GL_GetProcAddress(char *);
void GL_CheckForErrors();
void CL_ExtraUpdate();
void Cbuf_Execute();
extern convar_t cvstub;
#define Cvar_Get(...) &cvstub
#define Cvar_SetValue(...)
#define Cmd_AddCommand(...)
#define Cmd_RemoveCommand(...)
#define FS_FreeImage(...)
#define Host_Error(...)
#define ASSERT(x)
#define Assert(x)
#include <stdio.h>
#define Con_Reportf gEngfuncs.Con_DPrintf
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) convar_t cv = { cvname, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) convar_t cv = { #cv, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
@ -316,6 +309,7 @@ void GL_TextureTarget( uint target );
void GL_Cull( GLenum cull );
void R_ShowTextures( void );
void R_ShowTree( void );
void SCR_TimeRefresh_f( void );
//
// gl_cull.c
@ -380,6 +374,7 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount );
//
// gl_rlight.c
//
void CL_RunLightStyles( void );
void R_PushDlights( void );
void R_AnimateLight( void );
void R_GetLightSpot( vec3_t lightspot );
@ -747,12 +742,24 @@ extern convar_t *r_vbo_dlightmode;
extern convar_t *vid_brightness;
extern convar_t *vid_gamma;
extern convar_t *vid_highdpi;
//
// engine shared convars
//
extern convar_t *v_dark;
extern convar_t *cl_draw_beams;
extern convar_t *cl_draw_particles;
extern convar_t *cl_draw_tracers;
extern convar_t *gl_showtextures;
extern convar_t *tracerred;
extern convar_t *tracergreen;
extern convar_t *tracerblue;
extern convar_t *traceralpha;
extern convar_t *tracerspeed;
extern convar_t *tracerlength;
extern convar_t *traceroffset;
extern convar_t *cl_lightstyle_lerping;
//
// engine callbacks
@ -769,11 +776,6 @@ FORCEINLINE int COM_RandomLong( int rmin, int rmax )
return gEngfuncs.COM_RandomLong( rmin, rmax );
}
FORCEINLINE uint COM_HashKey( const char *str, uint hashSize )
{
return gEngfuncs.COM_HashKey( str, hashSize );
}
FORCEINLINE byte *_Mem_AllocPool( const char *name, const char *filename, int fileline )
{
return gEngfuncs._Mem_AllocPool( name, filename, fileline );

View File

@ -245,24 +245,23 @@ static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLui
switch( type )
{
case GL_DEBUG_TYPE_ERROR_ARB:
Con_Printf( S_OPENGL_ERROR "%s\n", message );
gEngfuncs.Con_Printf( S_OPENGL_ERROR "%s\n", message );
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
gEngfuncs.Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
gEngfuncs.Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
if( gpGlobals->developer < DEV_EXTENDED )
return;
Con_Printf( S_OPENGL_WARN "%s\n", message );
gEngfuncs.Con_Reportf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
Con_Printf( S_OPENGL_NOTE "%s\n", message );
gEngfuncs.Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
case GL_DEBUG_TYPE_OTHER_ARB:
default: Con_Printf( S_OPENGL_NOTE "%s\n", message );
default:
gEngfuncs.Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
}
}
@ -276,7 +275,7 @@ void GL_SetExtension( int r_ext, int enable )
{
if( r_ext >= 0 && r_ext < GL_EXTCOUNT )
glConfig.extension[r_ext] = enable ? GL_TRUE : GL_FALSE;
else Con_Printf( S_ERROR "GL_SetExtension: invalid extension %d\n", r_ext );
else gEngfuncs.Con_Printf( S_ERROR "GL_SetExtension: invalid extension %d\n", r_ext );
}
/*
@ -288,7 +287,7 @@ qboolean GL_Support( int r_ext )
{
if( r_ext >= 0 && r_ext < GL_EXTCOUNT )
return glConfig.extension[r_ext] ? true : false;
Con_Printf( S_ERROR "GL_Support: invalid extension %d\n", r_ext );
gEngfuncs.Con_Printf( S_ERROR "GL_Support: invalid extension %d\n", r_ext );
return false;
}
@ -316,7 +315,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv
convar_t *parm = NULL;
const char *extensions_string;
Con_Reportf( "GL_CheckExtension: %s ", name );
gEngfuncs.Con_Reportf( "GL_CheckExtension: %s ", name );
GL_SetExtension( r_ext, true );
if( cvarname )
@ -327,7 +326,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv
if(( parm && !CVAR_TO_BOOL( parm )) || ( !CVAR_TO_BOOL( gl_extensions ) && r_ext != GL_OPENGL_110 ))
{
Con_Reportf( "- disabled\n" );
gEngfuncs.Con_Reportf( "- disabled\n" );
GL_SetExtension( r_ext, false );
return; // nothing to process at
}
@ -337,7 +336,7 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv
if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( extensions_string, name ))
{
GL_SetExtension( r_ext, false ); // update render info
Con_Reportf( "- ^1failed\n" );
gEngfuncs.Con_Reportf( "- ^1failed\n" );
return;
}
@ -348,13 +347,13 @@ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cv
for( func = funcs; func && func->name != NULL; func++ )
{
// functions are cleared before all the extensions are evaluated
if((*func->func = (void *)GL_GetProcAddress( func->name )) == NULL )
if((*func->func = (void *)gEngfuncs.GL_GetProcAddress( func->name )) == NULL )
GL_SetExtension( r_ext, false ); // one or more functions are invalid, extension will be disabled
}
if( GL_Support( r_ext ))
Con_Reportf( "- ^2enabled\n" );
else Con_Reportf( "- ^1failed\n" );
gEngfuncs.Con_Reportf( "- ^2enabled\n" );
else gEngfuncs.Con_Reportf( "- ^1failed\n" );
}
/*
@ -410,7 +409,7 @@ static void GL_SetDefaults( void )
pglDepthFunc( GL_LEQUAL );
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
if( vidState.stencilEnabled )
if( glState.stencilEnabled )
{
pglDisable( GL_STENCIL_TEST );
pglStencilMask( ( GLuint ) ~0 );
@ -445,42 +444,39 @@ R_RenderInfo_f
*/
void R_RenderInfo_f( void )
{
Con_Printf( "\n" );
Con_Printf( "GL_VENDOR: %s\n", glConfig.vendor_string );
Con_Printf( "GL_RENDERER: %s\n", glConfig.renderer_string );
Con_Printf( "GL_VERSION: %s\n", glConfig.version_string );
gEngfuncs.Con_Printf( "\n" );
gEngfuncs.Con_Printf( "GL_VENDOR: %s\n", glConfig.vendor_string );
gEngfuncs.Con_Printf( "GL_RENDERER: %s\n", glConfig.renderer_string );
gEngfuncs.Con_Printf( "GL_VERSION: %s\n", glConfig.version_string );
// don't spam about extensions
if( host_developer.value >= DEV_EXTENDED )
{
Con_Printf( "GL_EXTENSIONS: %s\n", glConfig.extensions_string );
}
gEngfuncs.Con_Reportf( "GL_EXTENSIONS: %s\n", glConfig.extensions_string );
Con_Printf( "GL_MAX_TEXTURE_SIZE: %i\n", glConfig.max_2d_texture_size );
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_SIZE: %i\n", glConfig.max_2d_texture_size );
if( GL_Support( GL_ARB_MULTITEXTURE ))
Con_Printf( "GL_MAX_TEXTURE_UNITS_ARB: %i\n", glConfig.max_texture_units );
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_UNITS_ARB: %i\n", glConfig.max_texture_units );
if( GL_Support( GL_TEXTURE_CUBEMAP_EXT ))
Con_Printf( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: %i\n", glConfig.max_cubemap_size );
gEngfuncs.Con_Printf( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: %i\n", glConfig.max_cubemap_size );
if( GL_Support( GL_ANISOTROPY_EXT ))
Con_Printf( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: %.1f\n", glConfig.max_texture_anisotropy );
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: %.1f\n", glConfig.max_texture_anisotropy );
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
Con_Printf( "GL_MAX_RECTANGLE_TEXTURE_SIZE: %i\n", glConfig.max_2d_rectangle_size );
gEngfuncs.Con_Printf( "GL_MAX_RECTANGLE_TEXTURE_SIZE: %i\n", glConfig.max_2d_rectangle_size );
if( GL_Support( GL_TEXTURE_ARRAY_EXT ))
Con_Printf( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: %i\n", glConfig.max_2d_texture_layers );
gEngfuncs.Con_Printf( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: %i\n", glConfig.max_2d_texture_layers );
if( GL_Support( GL_SHADER_GLSL100_EXT ))
{
Con_Printf( "GL_MAX_TEXTURE_COORDS_ARB: %i\n", glConfig.max_texture_coords );
Con_Printf( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB: %i\n", glConfig.max_teximage_units );
Con_Printf( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: %i\n", glConfig.max_vertex_uniforms );
Con_Printf( "GL_MAX_VERTEX_ATTRIBS_ARB: %i\n", glConfig.max_vertex_attribs );
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_COORDS_ARB: %i\n", glConfig.max_texture_coords );
gEngfuncs.Con_Printf( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB: %i\n", glConfig.max_teximage_units );
gEngfuncs.Con_Printf( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: %i\n", glConfig.max_vertex_uniforms );
gEngfuncs.Con_Printf( "GL_MAX_VERTEX_ATTRIBS_ARB: %i\n", glConfig.max_vertex_attribs );
}
Con_Printf( "\n" );
Con_Printf( "MODE: %ix%i\n", vidState.width, vidState.height );
Con_Printf( "\n" );
Con_Printf( "VERTICAL SYNC: %s\n", gl_vsync->value ? "enabled" : "disabled" );
Con_Printf( "Color %d bits, Alpha %d bits, Depth %d bits, Stencil %d bits\n", glConfig.color_bits,
gEngfuncs.Con_Printf( "\n" );
gEngfuncs.Con_Printf( "MODE: %ix%i\n", vidState.width, vidState.height );
gEngfuncs.Con_Printf( "\n" );
gEngfuncs.Con_Printf( "VERTICAL SYNC: %s\n", gl_vsync->value ? "enabled" : "disabled" );
gEngfuncs.Con_Printf( "Color %d bits, Alpha %d bits, Depth %d bits, Stencil %d bits\n", glConfig.color_bits,
glConfig.alpha_bits, glConfig.depth_bits, glConfig.stencil_bits );
}
@ -591,7 +587,7 @@ void GL_InitExtensionsBigGL()
if( glConfig.max_3d_texture_size < 32 )
{
GL_SetExtension( GL_TEXTURE_3D_EXT, false );
Con_Printf( S_ERROR "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" );
gEngfuncs.Con_Printf( S_ERROR "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" );
}
}
@ -677,9 +673,9 @@ void GL_InitExtensionsBigGL()
// enable gldebug if allowed
if( GL_Support( GL_DEBUG_OUTPUT ))
{
if( host_developer.value )
if( gpGlobals->developer )
{
Con_Reportf( "Installing GL_DebugOutput...\n");
gEngfuncs.Con_Reportf( "Installing GL_DebugOutput...\n");
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
// force everything to happen in the main thread instead of in a separate driver thread
@ -703,7 +699,7 @@ void GL_InitExtensions( void )
glConfig.renderer_string = pglGetString( GL_RENDERER );
glConfig.version_string = pglGetString( GL_VERSION );
glConfig.extensions_string = pglGetString( GL_EXTENSIONS );
Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
gEngfuncs.Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
#ifdef XASH_GLES
GL_InitExtensionsGLES();
@ -718,7 +714,7 @@ void GL_InitExtensions( void )
Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )));
if( GL_Support( GL_TEXTURE_COMPRESSION_EXT ))
Image_AddCmdFlags( IL_DDS_HARDWARE );
gEngfuncs.Image_AddCmdFlags( IL_DDS_HARDWARE );
// MCD has buffering issues
#ifdef _WIN32
@ -746,9 +742,6 @@ GL_InitCommands
*/
void GL_InitCommands( void )
{
// system screen width and height (don't suppose for change from console at all)
Cvar_Get( "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
Cvar_Get( "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
r_speeds = Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
r_fullbright = Cvar_Get( "r_fullbright", "0", FCVAR_CHEAT, "disable lightmaps, get fullbright for entities" );
r_norefresh = Cvar_Get( "r_norefresh", "0", 0, "disable 3D rendering (use with caution)" );
@ -765,21 +758,19 @@ void GL_InitCommands( void )
r_traceglow = Cvar_Get( "r_traceglow", "1", FCVAR_ARCHIVE, "cull flares behind models" );
r_lightmap = Cvar_Get( "r_lightmap", "0", FCVAR_CHEAT, "lightmap debugging tool" );
r_drawentities = Cvar_Get( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
r_decals = engine.Cvar_Find( "r_decals" );
window_xpos = Cvar_Get( "_window_xpos", "130", FCVAR_RENDERINFO, "window position by horizontal" );
window_ypos = Cvar_Get( "_window_ypos", "48", FCVAR_RENDERINFO, "window position by vertical" );
r_decals = gEngfuncs.pfnGetCvarPointer( "r_decals" );
gl_extensions = Cvar_Get( "gl_allow_extensions", "1", FCVAR_GLCONFIG, "allow gl_extensions" );
gl_texture_nearest = Cvar_Get( "gl_texture_nearest", "0", FCVAR_ARCHIVE, "disable texture filter" );
gl_lightmap_nearest = Cvar_Get( "gl_lightmap_nearest", "0", FCVAR_ARCHIVE, "disable lightmap filter" );
gl_check_errors = Cvar_Get( "gl_check_errors", "1", FCVAR_ARCHIVE, "ignore video engine errors" );
gl_vsync = engine.Cvar_Find( "gl_vsync" );
gl_vsync = gEngfuncs.pfnGetCvarPointer( "gl_vsync" );
gl_detailscale = Cvar_Get( "gl_detailscale", "4.0", FCVAR_ARCHIVE, "default scale applies while auto-generate list of detail textures" );
gl_texture_anisotropy = Cvar_Get( "gl_anisotropy", "8", FCVAR_ARCHIVE, "textures anisotropic filter" );
gl_texture_lodbias = Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_ARCHIVE, "LOD bias for mipmapped textures (perfomance|quality)" );
gl_keeptjunctions = Cvar_Get( "gl_keeptjunctions", "1", FCVAR_ARCHIVE, "removing tjuncs causes blinking pixels" );
gl_emboss_scale = Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" );
gl_showtextures = engine.Cvar_Find( "r_showtextures" );
gl_showtextures = gEngfuncs.pfnGetCvarPointer( "r_showtextures" );
gl_finish = Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" );
gl_nosort = Cvar_Get( "gl_nosort", "0", FCVAR_ARCHIVE, "disable sorting of translucent surfaces" );
gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
@ -795,28 +786,21 @@ void GL_InitCommands( void )
// make sure gl_vsync is checked after vid_restart
SetBits( gl_vsync->flags, FCVAR_CHANGED );
vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
vid_fullscreen = engine.Cvar_Find( "fullscreen" );
vid_displayfrequency = engine.Cvar_Find ( "vid_displayfrequency" );
vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
vid_gamma = gEngfuncs.pfnGetCvarPointer( "gamma" );
vid_brightness = gEngfuncs.pfnGetCvarPointer( "brightness" );
Cmd_AddCommand( "r_info", R_RenderInfo_f, "display renderer info" );
Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
// a1ba: planned to be named vid_mode for compability
// but supported mode list is filled by backends, so numbers are not portable any more
Cmd_AddCommand( "vid_setmode", VID_Mode_f, "display video mode" );
gEngfuncs.Cmd_AddCommand( "r_info", R_RenderInfo_f, "display renderer info" );
gEngfuncs.Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
// give initial OpenGL configuration
host.apply_opengl_config = true;
Cbuf_AddText( "exec opengl.cfg\n" );
Cbuf_Execute();
host.apply_opengl_config = false;
gEngfuncs.Cbuf_SetOpenGLConfigHack( true );
gEngfuncs.Cbuf_AddText( "exec opengl.cfg\n" );
gEngfuncs.Cbuf_Execute();
gEngfuncs.Cbuf_SetOpenGLConfigHack( false );
// apply actual video mode to window
Cbuf_AddText( "exec video.cfg\n" );
Cbuf_Execute();
gEngfuncs.Cbuf_AddText( "exec video.cfg\n" );
gEngfuncs.Cbuf_Execute();
}
/*
@ -863,7 +847,6 @@ static void R_CheckVBO( void )
r_vbo->flags |= FCVAR_ARCHIVE;
}
/*
===============
R_Init
@ -877,24 +860,21 @@ qboolean R_Init( void )
GL_InitCommands();
GL_InitRandomTable();
// Set screen resolution and fullscreen mode if passed in on command line.
// This is done after executing opengl.cfg, as the command line values should take priority.
SetWidthAndHeightFromCommandLine();
SetFullscreenModeFromCommandLine();
GL_SetDefaultState();
// create the window and set up the context
#if 0 // REFTODO: just make it compile
if( !R_Init_Video( ))
{
GL_RemoveCommands();
R_Free_Video();
Sys_Error( "Can't initialize video subsystem\nProbably driver was not installed" );
gEngfuncs.Host_Error( "Can't initialize video subsystem\nProbably driver was not installed" );
return false;
}
host.renderinfo_changed = false;
#endif
r_temppool = Mem_AllocPool( "Render Zone" );
GL_SetDefaults();
@ -906,12 +886,19 @@ qboolean R_Init( void )
R_ClearDecals();
R_ClearScene();
// initialize screen
SCR_Init();
return true;
}
/*
=================
GL_RemoveCommands
=================
*/
void GL_RemoveCommands( void )
{
gEngfuncs.Cmd_RemoveCommand( "r_info" );
}
/*
===============
R_Shutdown
@ -919,27 +906,18 @@ R_Shutdown
*/
void R_Shutdown( void )
{
model_t *mod;
int i;
if( !glw_state.initialized )
return;
// release SpriteTextures
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( !mod->name[0] ) continue;
Mod_UnloadSpriteModel( mod );
}
memset( clgame.sprites, 0, sizeof( clgame.sprites ));
GL_RemoveCommands();
R_ShutdownImages();
Mem_FreePool( &r_temppool );
#if 0 // REFTODO: just make it compile
// shut down OS specific OpenGL stuff like contexts, etc.
R_Free_Video();
#endif // 0
}
/*
@ -985,6 +963,6 @@ void GL_CheckForErrors_( const char *filename, const int fileline )
if(( err = pglGetError( )) == GL_NO_ERROR )
return;
Con_Printf( S_OPENGL_ERROR "%s (called at %s:%i)\n", GL_ErrorString( err ), filename, fileline );
gEngfuncs.Con_Printf( S_OPENGL_ERROR "%s (called at %s:%i)\n", GL_ErrorString( err ), filename, fileline );
}

View File

@ -16,6 +16,8 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "entity_types.h"
#include "studio.h"
#include "common.h"
#include "world.h" // BOX_ON_PLANE_SIDE
/*
===============================================================================
@ -64,8 +66,8 @@ void R_RemoveEfrags( cl_entity_t *ent )
ef = ef->entnext;
// put it on the free list
old->entnext = clgame.free_efrags;
clgame.free_efrags = old;
old->entnext = gEngfuncs.GetEfragsFreeList();
gEngfuncs.SetEfragsFreeList( old );
}
ent->efrag = NULL;
}
@ -93,14 +95,14 @@ static void R_SplitEntityOnNode( mnode_t *node )
leaf = (mleaf_t *)node;
// grab an efrag off the free list
ef = clgame.free_efrags;
ef = gEngfuncs.GetEfragsFreeList();
if( !ef )
{
Con_Printf( S_ERROR "too many efrags!\n" );
gEngfuncs.Con_Printf( S_ERROR "too many efrags!\n" );
return; // no free fragments...
}
clgame.free_efrags = clgame.free_efrags->entnext;
gEngfuncs.SetEfragsFreeList( ef->entnext );
ef->entity = r_addent;
// add the entity link
@ -189,10 +191,10 @@ void R_StoreEfrags( efrag_t **ppefrag, int framecount )
if( pent->visframe != framecount )
{
if( CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
if( gEngfuncs.CL_AddVisibleEntity( pent, ET_FRAGMENTED ))
{
// mark that we've recorded this entity for this frame
pent->curstate.messagenum = cl.parsecount;
pent->curstate.messagenum = gpGlobals->parsecount;
pent->visframe = framecount;
}
}

View File

@ -13,10 +13,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "mathlib.h"
#include "gl_local.h"
#include "pm_local.h"
#include "studio.h"
#include "common.h"
#include "mathlib.h"
#include "ref_params.h"
/*
=============================================================================
@ -45,15 +47,16 @@ void CL_RunLightStyles( void )
// light animations
// 'm' is normal light, 'a' is no light, 'z' is double bright
for( i = 0, ls = cl.lightstyles; i < MAX_LIGHTSTYLES; i++, ls++ )
for( i = 0; i < MAX_LIGHTSTYLES; i++ )
{
ls = gEngfuncs.GetLightStyle( i );
if( !WORLDMODEL->lightdata )
{
tr.lightstylevalue[i] = 256 * 256;
continue;
}
if( !cl.paused && frametime <= 0.1f )
if( !gEngfuncs.CL_GetRenderParm( PARAM_GAMEPAUSED, 0 ) && frametime <= 0.1f )
ls->time += frametime; // evaluate local time
flight = (int)Q_floor( ls->time * 10 );
@ -393,16 +396,19 @@ colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t lspot,
// get light from bmodels too
if( CVAR_TO_BOOL( r_lighting_extended ))
maxEnts = clgame.pmove->numphysent;
maxEnts = MAX_PHYSENTS;
// check all the bsp-models
for( i = 0; i < maxEnts; i++ )
{
physent_t *pe = &clgame.pmove->physents[i];
physent_t *pe = gEngfuncs.EV_GetPhysent( i );
vec3_t offset, start_l, end_l;
mnode_t *pnodes;
matrix4x4 matrix;
if( !pe )
break;
if( !pe->model || pe->model->type != mod_brush )
continue; // skip non-bsp models

View File

@ -196,7 +196,7 @@ R_PushScene
void R_PushScene( void )
{
if( ++tr.draw_stack_pos >= MAX_DRAW_STACK )
Host_Error( "draw stack overflow\n" );
gEngfuncs.Host_Error( "draw stack overflow\n" );
tr.draw_list = &tr.draw_stack[tr.draw_stack_pos];
}
@ -209,7 +209,7 @@ R_PopScene
void R_PopScene( void )
{
if( --tr.draw_stack_pos < 0 )
Host_Error( "draw stack underflow\n" );
gEngfuncs.Host_Error( "draw stack underflow\n" );
tr.draw_list = &tr.draw_stack[tr.draw_stack_pos];
}
@ -278,7 +278,7 @@ static void R_Clear( int bitMask )
{
int bits;
if( CL_IsDevOverviewMode( ))
if( gEngfuncs.CL_IsDevOverviewMode( ))
pglClearColor( 0.0f, 1.0f, 0.0f, 1.0f ); // green background (Valve rules)
else pglClearColor( 0.5f, 0.5f, 0.5f, 1.0f );
@ -329,7 +329,7 @@ void R_SetupFrustum( void )
{
ref_overview_t *ov = gEngfuncs.GetOverviewParms();
if( RP_NORMALPASS() && ( cl.local.waterlevel >= 3 ))
if( RP_NORMALPASS() && ( gEngfuncs.GetWaterLevel() >= 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_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
@ -472,7 +472,7 @@ R_FindViewLeaf
void R_FindViewLeaf( void )
{
RI.oldviewleaf = RI.viewleaf;
RI.viewleaf = Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.pvsorigin, WORLDMODEL->nodes );
}
/*
@ -681,24 +681,24 @@ static void R_CheckFog( void )
RI.fogEnabled = false;
if( RI.onlyClientDraw || cl.local.waterlevel < 3 || !RI.drawWorld || !RI.viewleaf )
if( RI.onlyClientDraw || gEngfuncs.GetWaterLevel() < 3 || !RI.drawWorld || !RI.viewleaf )
{
if( RI.cached_waterlevel == 3 )
{
// in some cases waterlevel jumps from 3 to 1. Catch it
RI.cached_waterlevel = cl.local.waterlevel;
RI.cached_waterlevel = gEngfuncs.GetWaterLevel();
RI.cached_contents = CONTENTS_EMPTY;
if( !RI.fogCustom ) pglDisable( GL_FOG );
}
return;
}
ent = CL_GetWaterEntity( RI.vieworg );
ent = gEngfuncs.CL_GetWaterEntity( RI.vieworg );
if( ent && ent->model && ent->model->type == mod_brush && ent->curstate.skin < 0 )
cnt = ent->curstate.skin;
else cnt = RI.viewleaf->contents;
RI.cached_waterlevel = cl.local.waterlevel;
RI.cached_waterlevel = gEngfuncs.GetWaterLevel();
if( !IsLiquidContents( RI.cached_contents ) && IsLiquidContents( cnt ))
{
@ -935,7 +935,7 @@ R_SetupRefParams must be called right before
void R_RenderScene( void )
{
if( !WORLDMODEL && RI.drawWorld )
Host_Error( "R_RenderView: NULL worldmodel\n" );
gEngfuncs.Host_Error( "R_RenderView: NULL worldmodel\n" );
// frametime is valid only for normal pass
if( RP_NORMALPASS( ))
@ -1012,14 +1012,14 @@ void R_BeginFrame( qboolean clearScene )
{
glConfig.softwareGammaUpdate = false; // in case of possible fails
if(( gl_clear->value || CL_IsDevOverviewMode( )) && clearScene && cls.state != ca_cinematic )
if(( gl_clear->value || gEngfuncs.CL_IsDevOverviewMode( )) && clearScene && gEngfuncs.CL_GetConnState() != ref_ca_cinematic )
{
pglClear( GL_COLOR_BUFFER_BIT );
}
if( R_DoResetGamma( ))
{
BuildGammaTable( 1.8f, 0.0f );
gEngfuncs.BuildGammaTable( 1.8f, 0.0f );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
@ -1030,7 +1030,7 @@ void R_BeginFrame( qboolean clearScene )
}
else if( FBitSet( vid_gamma->flags, FCVAR_CHANGED ) || FBitSet( vid_brightness->flags, FCVAR_CHANGED ))
{
BuildGammaTable( vid_gamma->value, vid_brightness->value );
gEngfuncs.BuildGammaTable( vid_gamma->value, vid_brightness->value );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
@ -1229,8 +1229,6 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_FEATURES:
return host.features;
case PARM_ACTIVE_TMU:
return glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
@ -1276,44 +1274,6 @@ static void R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte
if( density ) *density = glt->fogParams[3];
}
/*
=================
R_EnvShot
=================
*/
static void R_EnvShot( const float *vieworg, const char *name, qboolean skyshot, int shotsize )
{
static vec3_t viewPoint;
if( !COM_CheckString( name ))
return;
if( cls.scrshot_action != scrshot_inactive )
{
if( cls.scrshot_action != scrshot_skyshot && cls.scrshot_action != scrshot_envshot )
Con_Printf( S_ERROR "R_%sShot: subsystem is busy, try for next frame.\n", skyshot ? "Sky" : "Env" );
return;
}
cls.envshot_vieworg = NULL; // use client view
Q_strncpy( cls.shotname, name, sizeof( cls.shotname ));
if( vieworg )
{
// make sure what viewpoint don't temporare
VectorCopy( vieworg, viewPoint );
cls.envshot_vieworg = viewPoint;
cls.envshot_disable_vis = true;
}
// make request for envshot
if( skyshot ) cls.scrshot_action = scrshot_skyshot;
else cls.scrshot_action = scrshot_envshot;
// catch negative values
cls.envshot_viewsize = max( 0, shotsize );
}
static void R_SetCurrentEntity( cl_entity_t *ent )
{
@ -1330,27 +1290,3 @@ static void R_SetCurrentModel( model_t *mod )
{
RI.currentmodel = mod;
}
/*
===============
R_InitRenderAPI
Initialize client external rendering
===============
*/
qboolean R_InitRenderAPI( void )
{
// make sure what render functions is cleared
memset( &gRenderIface, 0, sizeof( gRenderIface ));
if( gEngfuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &gRenderIface ))
{
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
return true;
}
// make sure what render functions is cleared
memset( &gRenderIface, 0, sizeof( gRenderIface ));
return false; // just tell user about problems
}

View File

@ -28,13 +28,13 @@ static void R_ParseDetailTextures( const char *filename )
texture_t *tex;
int i;
afile = FS_LoadFile( filename, NULL, false );
afile = gEngfuncs.COM_LoadFile( filename, NULL, false );
if( !afile ) return;
pfile = afile;
// format: 'texturename' 'detailtexture' 'xScale' 'yScale'
while(( pfile = COM_ParseFile( pfile, token )) != NULL )
while(( pfile = gEngfuncs.COM_ParseFile( pfile, token )) != NULL )
{
texname[0] = '\0';
detail_texname[0] = '\0';
@ -44,26 +44,26 @@ static void R_ParseDetailTextures( const char *filename )
{
// NOTE: COM_ParseFile handled some symbols seperately
// this code will be fix it
pfile = COM_ParseFile( pfile, token );
pfile = gEngfuncs.COM_ParseFile( pfile, token );
Q_strncat( texname, "{", sizeof( texname ));
Q_strncat( texname, token, sizeof( texname ));
}
else Q_strncpy( texname, token, sizeof( texname ));
// read detailtexture name
pfile = COM_ParseFile( pfile, token );
pfile = gEngfuncs.COM_ParseFile( pfile, token );
Q_strncat( detail_texname, token, sizeof( detail_texname ));
// trying the scales or '{'
pfile = COM_ParseFile( pfile, token );
pfile = gEngfuncs.COM_ParseFile( pfile, token );
// read second part of detailtexture name
if( token[0] == '{' )
{
Q_strncat( detail_texname, token, sizeof( detail_texname ));
pfile = COM_ParseFile( pfile, token ); // read scales
pfile = gEngfuncs.COM_ParseFile( pfile, token ); // read scales
Q_strncat( detail_texname, token, sizeof( detail_texname ));
pfile = COM_ParseFile( pfile, token ); // parse scales
pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse scales
}
Q_snprintf( detail_path, sizeof( detail_path ), "gfx/%s", detail_texname );
@ -71,7 +71,7 @@ static void R_ParseDetailTextures( const char *filename )
// read scales
xScale = Q_atof( token );
pfile = COM_ParseFile( pfile, token );
pfile = gEngfuncs.COM_ParseFile( pfile, token );
yScale = Q_atof( token );
if( xScale <= 0.0f || yScale <= 0.0f )

View File

@ -22,6 +22,9 @@ GNU General Public License for more details.
#include "cl_tent.h"
#include "studio.h"
#define PART_SIZE Q_max( 0.5f, cl_draw_particles->value )
static float gTracerSize[11] = { 1.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
/*
================
CL_DrawParticles
@ -32,11 +35,6 @@ update particle color, position, free expired and draw it
void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
{
particle_t *p;
float time3 = 15.0f * frametime;
float time2 = 10.0f * frametime;
float time1 = 5.0f * frametime;
float dvel = 4.0f * frametime;
float grav = frametime * MOVEVARS->gravity * 0.05f;
vec3_t right, up;
color24 *pColor;
int alpha;
@ -77,13 +75,15 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
VectorScale( RI.cull_vup, size, up );
p->color = bound( 0, p->color, 255 );
pColor = &clgame.palette[p->color];
pColor = gEngfuncs.CL_GetPaletteColor( p->color );
alpha = 255 * (p->die - gpGlobals->time) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
pglColor4ub( LightToTexGamma( pColor->r ), LightToTexGamma( pColor->g ), LightToTexGamma( pColor->b ), alpha );
pglColor4ub( gEngfuncs.LightToTexGamma( pColor->r ),
gEngfuncs.LightToTexGamma( pColor->g ),
gEngfuncs.LightToTexGamma( pColor->b ), alpha );
pglTexCoord2f( 0.0f, 1.0f );
pglVertex3f( p->org[0] - right[0] + up[0], p->org[1] - right[1] + up[1], p->org[2] - right[2] + up[2] );
@ -96,79 +96,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles )
r_stats.c_particle_count++;
}
if( p->type != pt_clientcustom )
{
// update position.
VectorMA( p->org, frametime, p->vel, p->org );
}
switch( p->type )
{
case pt_static:
break;
case pt_fire:
p->ramp += time1;
if( p->ramp >= 6.0f ) p->die = -1.0f;
else p->color = ramp3[(int)p->ramp];
p->vel[2] += grav;
break;
case pt_explode:
p->ramp += time2;
if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp1[(int)p->ramp];
VectorMA( p->vel, dvel, p->vel, p->vel );
p->vel[2] -= grav;
break;
case pt_explode2:
p->ramp += time3;
if( p->ramp >= 8.0f ) p->die = -1.0f;
else p->color = ramp2[(int)p->ramp];
VectorMA( p->vel,-frametime, p->vel, p->vel );
p->vel[2] -= grav;
break;
case pt_blob:
if( p->packedColor == 255 )
{
// normal blob explosion
VectorMA( p->vel, dvel, p->vel, p->vel );
p->vel[2] -= grav;
break;
}
case pt_blob2:
if( p->packedColor == 255 )
{
// normal blob explosion
p->vel[0] -= p->vel[0] * dvel;
p->vel[1] -= p->vel[1] * dvel;
p->vel[2] -= grav;
}
else
{
p->ramp += time2;
if( p->ramp >= 9.0f ) p->ramp = 0.0f;
p->color = gSparkRamp[(int)p->ramp];
VectorMA( p->vel, -frametime * 0.5f, p->vel, p->vel );
p->type = COM_RandomLong( 0, 3 ) ? pt_blob : pt_blob2;
p->vel[2] -= grav * 5.0f;
}
break;
case pt_grav:
p->vel[2] -= grav * 20.0f;
break;
case pt_slowgrav:
p->vel[2] -= grav;
break;
case pt_vox_grav:
p->vel[2] -= grav * 8.0f;
break;
case pt_vox_slowgrav:
p->vel[2] -= grav * 4.0f;
break;
case pt_clientcustom:
if( p->callback )
p->callback( p, frametime );
break;
}
gEngfuncs.CL_ThinkParticle( frametime, p );
}
pglEnd();
@ -232,9 +160,10 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
// update tracer color if this is changed
if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED ))
{
gTracerColors[4].r = (byte)(tracerred->value * traceralpha->value * 255);
gTracerColors[4].g = (byte)(tracergreen->value * traceralpha->value * 255);
gTracerColors[4].b = (byte)(tracerblue->value * traceralpha->value * 255);
color24 *customColors = gEngfuncs.GetTracerColors( 4 );
customColors->r = (byte)(tracerred->value * traceralpha->value * 255);
customColors->g = (byte)(tracergreen->value * traceralpha->value * 255);
customColors->b = (byte)(tracerblue->value * traceralpha->value * 255);
ClearBits( tracerred->flags, FCVAR_CHANGED );
ClearBits( tracergreen->flags, FCVAR_CHANGED );
ClearBits( tracerblue->flags, FCVAR_CHANGED );
@ -293,7 +222,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
VectorAdd( verts[0], delta, verts[2] );
VectorAdd( verts[1], delta, verts[3] );
pColor = &gTracerColors[p->color];
pColor = gEngfuncs.GetTracerColors( p->color );
pglColor4ub( pColor->r, pColor->g, pColor->b, p->packedColor );
pglBegin( GL_QUADS );

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "mathlib.h"
#include "mod_local.h"
typedef struct
{
@ -87,9 +88,10 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts
float sample_size;
vec3_t mins, maxs;
glpoly_t *poly;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
if( numverts > ( SUBDIVIDE_SIZE - 4 ))
Host_Error( "Mod_SubdividePolygon: too many vertexes on face ( %i )\n", numverts );
gEngfuncs.Host_Error( "Mod_SubdividePolygon: too many vertexes on face ( %i )\n", numverts );
sample_size = gEngfuncs.Mod_SampleSizeForFace( warpface );
BoundPoly( numverts, verts, mins, maxs );
@ -242,6 +244,7 @@ void GL_SubdivideSurface( msurface_t *fa )
int numverts;
int i, lindex;
float *vec;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
// convert edges back to a normal polygon
numverts = 0;
@ -700,7 +703,7 @@ static void LM_UploadBlock( qboolean dynamic )
tr.lightmapTextures[i] = GL_LoadTextureInternal( lmName, &r_lightmap, TF_FONT|TF_ATLAS_PAGE );
if( ++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS )
Host_Error( "AllocBlock: full\n" );
gEngfuncs.Host_Error( "AllocBlock: full\n" );
}
}
@ -990,7 +993,7 @@ void R_BlendLightmaps( void )
// try uploading the block now
if( !LM_AllocBlock( smax, tmax, &surf->info->dlight_s, &surf->info->dlight_t ))
Host_Error( "AllocBlock: full\n" );
gEngfuncs.Host_Error( "AllocBlock: full\n" );
base = gl_lms.lightmap_buffer;
base += ( surf->info->dlight_t * BLOCK_SIZE + surf->info->dlight_s ) * 4;
@ -1269,7 +1272,7 @@ void R_DrawTextureChains( void )
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model;
if( gEngfuncs.CL)
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) )
{
pglDisable( GL_TEXTURE_2D );
pglColor3f( 1.0f, 1.0f, 1.0f );
@ -1279,7 +1282,7 @@ void R_DrawTextureChains( void )
for( s = skychain; s != NULL; s = s->texturechain )
R_AddSkyBoxSurface( s );
if( FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && !tr.fCustomSkybox )
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) )
{
pglEnable( GL_TEXTURE_2D );
if( skychain )
@ -2429,7 +2432,7 @@ static void R_DrawLightmappedVBO( vboarray_t *vbo, vbotexture_t *vbotex, texture
// try upload the block now
if( !LM_AllocBlock( smax, tmax, &info->dlight_s, &info->dlight_t ))
Host_Error( "AllocBlock: full\n" );
gEngfuncs.Host_Error( "AllocBlock: full\n" );
base = gl_lms.lightmap_buffer;
base += ( info->dlight_t * BLOCK_SIZE + info->dlight_s ) * 4;
@ -3332,7 +3335,7 @@ void R_DrawWorld( void )
R_DrawTextureChains();
if( !CL_IsDevOverviewMode( ))
if( !gEngfuncs.CL_IsDevOverviewMode( ))
{
DrawDecalsBatch();
GL_ResetFogColor();
@ -3389,12 +3392,12 @@ void R_MarkLeaves( void )
if( RI.viewleaf->contents == CONTENTS_EMPTY )
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
leaf = Mod_PointInLeaf( test, WORLDMODEL->nodes );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
else
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
leaf = Mod_PointInLeaf( test, WORLDMODEL->nodes );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
@ -3444,6 +3447,7 @@ void GL_CreateSurfaceLightmap( msurface_t *surf )
int sample_size;
mextrasurf_t *info = surf->info;
byte *base;
model_t *loadmodel = gEngfuncs.Mod_GetCurrentLoadingModel();
if( !loadmodel->lightdata )
return;
@ -3461,7 +3465,7 @@ void GL_CreateSurfaceLightmap( msurface_t *surf )
LM_InitBlock();
if( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ))
Host_Error( "AllocBlock: full\n" );
gEngfuncs.Host_Error( "AllocBlock: full\n" );
}
surf->lightmaptexturenum = gl_lms.current_lightmap_texture;
@ -3486,7 +3490,7 @@ void GL_RebuildLightmaps( void )
int i, j;
model_t *m;
if( !cl.video_prepped )
if( !gpGlobals->video_prepped )
return; // wait for worldmodel
ClearBits( vid_brightness->flags, FCVAR_CHANGED );
@ -3507,15 +3511,15 @@ void GL_RebuildLightmaps( void )
LM_InitBlock();
for( i = 0; i < cl.nummodels; i++ )
for( i = 0; i < gEngfuncs.CL_NumModels(); i++ )
{
if(( m = CL_ModelHandle( i + 1 )) == NULL )
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
continue;
if( m->name[0] == '*' || m->type != mod_brush )
continue;
loadmodel = m;
gEngfuncs.Mod_SetCurrentLoadingModel( m );
for( j = 0; j < m->numsurfaces; j++ )
GL_CreateSurfaceLightmap( m->surfaces + j );
@ -3573,9 +3577,9 @@ void GL_BuildLightmaps( void )
LM_InitBlock();
for( i = 0; i < cl.nummodels; i++ )
for( i = 0; i < gEngfuncs.CL_NumModels(); i++ )
{
if(( m = CL_ModelHandle( i + 1 )) == NULL )
if(( m = gEngfuncs.pfnGetModelByIndex( i + 1 )) == NULL )
continue;
if( m->name[0] == '*' || m->type != mod_brush )
@ -3586,7 +3590,7 @@ void GL_BuildLightmaps( void )
// clearing all decal chains
m->surfaces[j].pdecals = NULL;
m->surfaces[j].visframe = 0;
loadmodel = m;
gEngfuncs.Mod_SetCurrentLoadingModel( m );
GL_CreateSurfaceLightmap( m->surfaces + j );

View File

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "studio.h"
#include "entity_types.h"
#include "cl_tent.h"
#include "common.h"
// it's a Valve default value for LoadMapSprite (probably must be power of two)
#define MAPSPRITE_SIZE 128
@ -152,81 +153,8 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
msprite_t *psprite;
int i, size;
if( loaded ) *loaded = false;
pin = (dsprite_t *)buffer;
mod->type = mod_sprite;
r_texFlags = texFlags;
i = pin->version;
if( pin->ident != IDSPRITEHEADER )
{
Con_DPrintf( S_ERROR "%s has wrong id (%x should be %x)\n", mod->name, pin->ident, IDSPRITEHEADER );
return;
}
if( i != SPRITE_VERSION_Q1 && i != SPRITE_VERSION_HL && i != SPRITE_VERSION_32 )
{
Con_DPrintf( S_ERROR "%s has wrong version number (%i should be %i or %i)\n", mod->name, i, SPRITE_VERSION_Q1, SPRITE_VERSION_HL );
return;
}
mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name ));
sprite_version = i;
if( i == SPRITE_VERSION_Q1 || i == SPRITE_VERSION_32 )
{
pinq1 = (dsprite_q1_t *)buffer;
size = sizeof( msprite_t ) + ( pinq1->numframes - 1 ) * sizeof( psprite->frames );
psprite = Mem_Calloc( mod->mempool, size );
mod->cache.data = psprite; // make link to extradata
psprite->type = pinq1->type;
psprite->texFormat = SPR_ADDITIVE; //SPR_ALPHTEST;
psprite->numframes = mod->numframes = pinq1->numframes;
psprite->facecull = SPR_CULL_FRONT;
psprite->radius = pinq1->boundingradius;
psprite->synctype = pinq1->synctype;
// LordHavoc: hack to allow sprites to be non-fullbright
for( i = 0; i < MAX_QPATH && mod->name[i]; i++ )
if( mod->name[i] == '!' )
psprite->texFormat = SPR_ALPHTEST;
mod->mins[0] = mod->mins[1] = -pinq1->bounds[0] * 0.5f;
mod->maxs[0] = mod->maxs[1] = pinq1->bounds[0] * 0.5f;
mod->mins[2] = -pinq1->bounds[1] * 0.5f;
mod->maxs[2] = pinq1->bounds[1] * 0.5f;
numi = NULL;
}
else if( i == SPRITE_VERSION_HL )
{
pinhl = (dsprite_hl_t *)buffer;
size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
psprite = Mem_Calloc( mod->mempool, size );
mod->cache.data = psprite; // make link to extradata
psprite->type = pinhl->type;
psprite->texFormat = pinhl->texFormat;
psprite->numframes = mod->numframes = pinhl->numframes;
psprite->facecull = pinhl->facetype;
psprite->radius = pinhl->boundingradius;
psprite->synctype = pinhl->synctype;
mod->mins[0] = mod->mins[1] = -pinhl->bounds[0] * 0.5f;
mod->maxs[0] = mod->maxs[1] = pinhl->bounds[0] * 0.5f;
mod->mins[2] = -pinhl->bounds[1] * 0.5f;
mod->maxs[2] = pinhl->bounds[1] * 0.5f;
numi = (short *)(pinhl + 1);
}
if( host.type == HOST_DEDICATED )
{
// skip frames loading
if( loaded ) *loaded = true; // done
psprite->numframes = 0;
return;
}
sprite_version = pin->version;
Q_strncpy( sprite_name, mod->name, sizeof( sprite_name ));
COM_StripExtension( sprite_name );
@ -235,7 +163,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
rgbdata_t *pal;
pal = FS_LoadImage( "#id.pal", (byte *)&i, 768 );
pframetype = (dframetype_t *)(pinq1 + 1);
pframetype = (dframetype_t *)(buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
FS_FreeImage( pal ); // palette installed, no reason to keep this data
}
else if( *numi == 256 )
@ -262,7 +190,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
}
else
{
Con_DPrintf( S_ERROR "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi );
gEngfuncs.Con_DPrintf( S_ERROR "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi );
return;
}
@ -430,41 +358,30 @@ void Mod_UnloadSpriteModel( model_t *mod )
mspriteframe_t *pspriteframe;
int i, j;
Assert( mod != NULL );
psprite = mod->cache.data;
if( mod->type == mod_sprite )
if( psprite )
{
if( host.type != HOST_DEDICATED )
// release all textures
for( i = 0; i < psprite->numframes; i++ )
{
psprite = mod->cache.data;
if( psprite )
if( psprite->frames[i].type == SPR_SINGLE )
{
// release all textures
for( i = 0; i < psprite->numframes; i++ )
{
if( psprite->frames[i].type == SPR_SINGLE )
{
pspriteframe = psprite->frames[i].frameptr;
GL_FreeTexture( pspriteframe->gl_texturenum );
}
else
{
pspritegroup = (mspritegroup_t *)psprite->frames[i].frameptr;
pspriteframe = psprite->frames[i].frameptr;
GL_FreeTexture( pspriteframe->gl_texturenum );
}
else
{
pspritegroup = (mspritegroup_t *)psprite->frames[i].frameptr;
for( j = 0; j < pspritegroup->numframes; j++ )
{
pspriteframe = pspritegroup->frames[i];
GL_FreeTexture( pspriteframe->gl_texturenum );
}
}
for( j = 0; j < pspritegroup->numframes; j++ )
{
pspriteframe = pspritegroup->frames[i];
GL_FreeTexture( pspriteframe->gl_texturenum );
}
}
}
}
Mem_FreePool( &mod->mempool );
memset( mod, 0, sizeof( *mod ));
}
/*
@ -493,7 +410,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
else if( frame >= psprite->numframes )
{
if( frame > psprite->numframes )
Con_Printf( S_WARN "R_GetSpriteFrame: no such frame %d (%s)\n", frame, pModel->name );
gEngfuncs.Con_Printf( S_WARN "R_GetSpriteFrame: no such frame %d (%s)\n", frame, pModel->name );
frame = psprite->numframes - 1;
}
@ -561,7 +478,7 @@ float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **oldframe,
}
else if( frame >= psprite->numframes )
{
Con_Reportf( S_WARN "R_GetSpriteFrameInterpolant: no such frame %d (%s)\n", frame, ent->model->name );
gEngfuncs.Con_Reportf( S_WARN "R_GetSpriteFrameInterpolant: no such frame %d (%s)\n", frame, ent->model->name );
frame = psprite->numframes - 1;
}
@ -906,7 +823,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
{
cl_entity_t *parent;
parent = CL_GetEntityByIndex( e->curstate.aiment );
parent = gEngfuncs.GetEntityByIndex( e->curstate.aiment );
if( parent && parent->model )
{

View File

@ -21,6 +21,8 @@ GNU General Public License for more details.
#include "studio.h"
#include "pm_local.h"
#include "cl_tent.h"
#include "common.h"
#include "client.h"
#define EVENT_CLIENT 5000 // less than this value it's a server-side studio events
#define MAX_LOCALLIGHTS 4
@ -363,12 +365,16 @@ pfnPlayerInfo
*/
player_info_t *pfnPlayerInfo( int index )
{
#if 0
if( !RI.drawWorld )
return &gameui.playerinfo;
if( index < 0 || index > cl.maxclients )
return NULL;
return &cl.players[index];
#else
return gEngfuncs.pfnPlayerInfo( index );
#endif
}
/*
@ -392,11 +398,14 @@ entity_state_t *R_StudioGetPlayerState( int index )
{
if( !RI.drawWorld )
return &RI.currententity->curstate;
#if 0
if( index < 0 || index >= cl.maxclients )
return NULL;
return &cl.frames[cl.parsecountmod].playerstate[index];
#else
return gEngfuncs.pfnGetPlayerState( index );
#endif
}
/*
@ -1355,7 +1364,7 @@ R_StudioDynamicLight
*/
void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
{
movevars_t *mv = &clgame.movevars;
movevars_t *mv = gEngfuncs.pfnGetMoveVars();
vec3_t lightDir, vecSrc, vecEnd;
vec3_t origin, dist, finalLight;
float add, radius, total;
@ -1404,10 +1413,10 @@ void R_StudioDynamicLight( cl_entity_t *ent, alight_t *plight )
vecEnd[2] = origin[2] - mv->skyvec_z * 8192.0f;
}
trace = CL_TraceLine( vecSrc, vecEnd, PM_WORLD_ONLY );
if( trace.ent > 0 ) psurf = PM_TraceSurface( &clgame.pmove->physents[trace.ent], vecSrc, vecEnd );
else psurf = PM_TraceSurface( clgame.pmove->physents, vecSrc, vecEnd );
trace = gEngfuncs.CL_TraceLine( vecSrc, vecEnd, PM_WORLD_ONLY );
if( trace.ent > 0 ) psurf = gEngfuncs.EV_TraceSurface( trace.ent, vecSrc, vecEnd );
else psurf = gEngfuncs.EV_TraceSurface( 0, vecSrc, vecEnd );
if( FBitSet( ent->model->flags, STUDIO_FORCE_SKYLIGHT ) || ( psurf && FBitSet( psurf->flags, SURF_DRAWSKY )))
{
VectorSet( lightDir, mv->skyvec_x, mv->skyvec_y, mv->skyvec_z );
@ -1787,7 +1796,7 @@ static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index )
return;
// NOTE: user may ignore to call StudioRemapColors and remap_info will be unavailable
if( m_fDoRemap ) ptexture = CL_GetRemapInfoForEntity( RI.currententity )->ptexture;
if( m_fDoRemap ) ptexture = gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity )->ptexture;
if( !ptexture ) ptexture = (mstudiotexture_t *)((byte *)ptexturehdr + ptexturehdr->textureindex); // fallback
if( r_lightmap->value && !r_fullbright->value )
@ -1807,11 +1816,11 @@ mstudiotexture_t *R_StudioGetTexture( cl_entity_t *e )
mstudiotexture_t *ptexture;
studiohdr_t *phdr, *thdr;
if(( phdr = Mod_StudioExtradata( e->model )) == NULL )
if(( phdr = gEngfuncs.Mod_Extradata( mod_studio, e->model )) == NULL )
return NULL;
thdr = m_pStudioHeader;
if( !thdr ) return NULL;
if( !thdr ) return NULL;
if( m_fDoRemap ) ptexture = CL_GetRemapInfoForEntity( e )->ptexture;
else ptexture = (mstudiotexture_t *)((byte *)thdr + thdr->textureindex);
@ -1851,7 +1860,7 @@ void R_StudioRenderShadow( int iSprite, float *p1, float *p2, float *p3, float *
if( !p1 || !p2 || !p3 || !p4 )
return;
if( TriSpriteTexture( CL_ModelHandle( iSprite ), 0 ))
if( TriSpriteTexture( gEngfuncs.pfnGetModelByIndex( iSprite ), 0 ))
{
TriRenderMode( kRenderTransAlpha );
TriColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
@ -2387,11 +2396,11 @@ R_StudioSetRemapColors
*/
void R_StudioSetRemapColors( int newTop, int newBottom )
{
CL_AllocRemapInfo( newTop, newBottom );
gEngfuncs.CL_AllocRemapInfo( newTop, newBottom );
if( CL_GetRemapInfoForEntity( RI.currententity ))
if( gEngfuncs.CL_GetRemapInfoForEntity( RI.currententity ))
{
CL_UpdateRemapInfo( newTop, newBottom );
gEngfuncs.CL_UpdateRemapInfo( newTop, newBottom );
m_fDoRemap = true;
}
}
@ -2404,22 +2413,12 @@ R_StudioSetupPlayerModel
*/
static model_t *R_StudioSetupPlayerModel( int index )
{
player_info_t *info;
player_info_t *info = gEngfuncs.pfnPlayerInfo( index );
player_model_t *state;
if( !RI.drawWorld )
{
// we are in gameui.
info = &gameui.playerinfo;
}
else
{
if( index < 0 || index >= cl.maxclients )
return NULL; // bad client ?
info = &cl.players[index];
}
#if 0
state = &cl.player_models[index];
#endif
// g-cont: force for "dev-mode", non-local games and menu preview
if(( host_developer.value || !Host_IsLocalGame( ) || !RI.drawWorld ) && info->model[0] )
@ -2432,7 +2431,7 @@ static model_t *R_StudioSetupPlayerModel( int index )
Q_snprintf( state->modelname, sizeof( state->modelname ), "models/player/%s/%s.mdl", info->model, info->model );
if( gEngfuncs.FS_FileExists( state->modelname, false ))
state->model = Mod_ForName( state->modelname, false, true );
state->model = gEngfuncs.Mod_ForName( state->modelname, false, true );
else state->model = NULL;
if( !state->model )
@ -2473,7 +2472,7 @@ int R_GetEntityRenderMode( cl_entity_t *ent )
RI.currententity = oldent;
if(( phdr = Mod_StudioExtradata( model )) == NULL )
if(( phdr = gEngfuncs.Mod_Extradata( mod_studio, model )) == NULL )
{
if( R_ModelOpaque( ent->curstate.rendermode ))
{
@ -3079,7 +3078,7 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( RI.currentmodel == NULL )
return 0;
R_StudioSetHeader((studiohdr_t *)Mod_StudioExtradata( RI.currentmodel ));
R_StudioSetHeader((studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, RI.currentmodel ));
if( pplayer->gaitsequence )
{
@ -3184,9 +3183,9 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( pplayer->weaponmodel )
{
cl_entity_t saveent = *RI.currententity;
model_t *pweaponmodel = CL_ModelHandle( pplayer->weaponmodel );
model_t *pweaponmodel = gEngfuncs.pfnGetModelByIndex( pplayer->weaponmodel );
m_pStudioHeader = (studiohdr_t *)Mod_StudioExtradata( pweaponmodel );
m_pStudioHeader = (studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, pweaponmodel );
R_StudioMergeBones( RI.currententity, pweaponmodel );
R_StudioSetupLighting( &lighting );
@ -3238,7 +3237,7 @@ static int R_StudioDrawModel( int flags )
return result;
}
R_StudioSetHeader((studiohdr_t *)Mod_StudioExtradata( RI.currentmodel ));
R_StudioSetHeader((studiohdr_t *)gEngfuncs.Mod_Extradata( mod_studio, RI.currentmodel ));
R_StudioSetUpTransform( RI.currententity );
@ -3608,7 +3607,12 @@ void Mod_StudioUnloadTextures( void *data )
GL_FreeTexture( ptexture[i].index );
}
}
static model_t *pfnModelHandle( int modelindex )
{
return gEngfuncs.pfnGetModelByIndex( modelindex );
}
static engine_studio_api_t gStudioAPI =
{
Mod_Calloc,
@ -3616,7 +3620,7 @@ static engine_studio_api_t gStudioAPI =
Mod_LoadCacheFile,
pfnMod_ForName,
Mod_StudioExtradata,
CL_ModelHandle,
pfnModelHandle,
pfnGetCurrentEntity,
pfnPlayerInfo,
R_StudioGetPlayerState,

View File

@ -16,6 +16,12 @@ GNU General Public License for more details.
#include "gl_local.h"
#define VGUI_MAX_TEXTURES ( MAX_TEXTURES / 2 ) // a half of total textures count
static int g_textures[VGUI_MAX_TEXTURES];
static int g_textureId = 0;
static int g_iBoundTexture;
/*
================
VGUI_DrawInit
@ -56,7 +62,7 @@ generate unique texture number
int GAME_EXPORT VGUI_GenerateTexture( void )
{
if( ++g_textureId >= VGUI_MAX_TEXTURES )
Sys_Error( "VGUI_GenerateTexture: VGUI_MAX_TEXTURES limit exceeded\n" );
gEngfuncs.Host_Error( "VGUI_GenerateTexture: VGUI_MAX_TEXTURES limit exceeded\n" );
return g_textureId;
}
@ -74,7 +80,7 @@ void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int width, int
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_DPrintf( S_ERROR "VGUI_UploadTexture: bad texture %i. Ignored\n", id );
gEngfuncs.Con_DPrintf( S_ERROR "VGUI_UploadTexture: bad texture %i. Ignored\n", id );
return;
}
@ -105,7 +111,7 @@ void GAME_EXPORT VGUI_CreateTexture( int id, int width, int height )
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_Reportf( S_ERROR "VGUI_CreateTexture: bad texture %i. Ignored\n", id );
gEngfuncs.Con_Reportf( S_ERROR "VGUI_CreateTexture: bad texture %i. Ignored\n", id );
return;
}
@ -127,7 +133,7 @@ void GAME_EXPORT VGUI_UploadTextureBlock( int id, int drawX, int drawY, const by
{
if( id <= 0 || id >= VGUI_MAX_TEXTURES || g_textures[id] == 0 || g_textures[id] == tr.whiteTexture )
{
Con_Reportf( S_ERROR "VGUI_UploadTextureBlock: bad texture %i. Ignored\n", id );
gEngfuncs.Con_Reportf( S_ERROR "VGUI_UploadTextureBlock: bad texture %i. Ignored\n", id );
return;
}
@ -221,8 +227,13 @@ generic method to fill rectangle
*/
void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
{
float xscale = gpGlobals->width / (float)clgame.scrInfo.iWidth;
float yscale = gpGlobals->height / (float)clgame.scrInfo.iHeight;
int width, height;
float xscale, yscale;
gEngfuncs.CL_GetScreenInfo( &width, &height );
xscale = gpGlobals->width / (float)width;
yscale = gpGlobals->height / (float)height;
ASSERT( ul != NULL && lr != NULL );

View File

@ -16,6 +16,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "wadfile.h"
#include "common.h"
#define SKYCLOUDS_QUALITY 12
#define MAX_CLIP_VERTS 128 // skybox clip vertices
@ -162,7 +163,7 @@ void ClipSkyPolygon( int nump, vec3_t vecs, int stage )
int i, j;
if( nump > MAX_CLIP_VERTS )
Host_Error( "ClipSkyPolygon: MAX_CLIP_VERTS\n" );
gEngfuncs.Host_Error( "ClipSkyPolygon: MAX_CLIP_VERTS\n" );
loc1:
if( stage == 6 )
{
@ -310,7 +311,7 @@ void R_AddSkyBoxSurface( msurface_t *fa )
float *v;
int i;
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE ) && fa->polys && !tr.fCustomSkybox )
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE, 0 ) && fa->polys && !tr.fCustomSkybox )
{
glpoly_t *p = fa->polys;
@ -432,7 +433,7 @@ void R_SetupSky( const char *skyboxname )
// to prevent infinite recursion if default skybox was missed
if( result == SKYBOX_MISSED && Q_stricmp( loadname, DEFAULT_SKYBOX_PATH ))
{
Con_Reportf( S_WARN "missed or incomplete skybox '%s'\n", skyboxname );
gEngfuncs.Con_Reportf( S_WARN "missed or incomplete skybox '%s'\n", skyboxname );
R_SetupSky( "desert" ); // force to default
return;
}
@ -678,7 +679,7 @@ void R_InitSkyClouds( mip_t *mt, texture_t *tx, qboolean custom_palette )
// make sure what sky image is valid
if( !r_sky || !r_sky->palette || r_sky->type != PF_INDEXED_32 || r_sky->height == 0 )
{
Con_Reportf( S_ERROR "R_InitSky: unable to load sky texture %s\n", tx->name );
gEngfuncs.Con_Reportf( S_ERROR "R_InitSky: unable to load sky texture %s\n", tx->name );
if( r_sky ) FS_FreeImage( r_sky );
return;
}