Apply 4511 update

This commit is contained in:
Alibek Omarov 2019-06-17 07:05:36 +03:00
parent c215b89923
commit b16529cc65
20 changed files with 162 additions and 71 deletions

View File

@ -61,6 +61,8 @@ GNU General Public License for more details.
#define PARM_STENCIL_ACTIVE 36
#define PARM_WATER_ALPHA 37
#define PARM_TEX_MEMORY 38 // returns total memory of uploaded texture in bytes
#define PARM_DELUXEDATA 39 // nasty hack, convert int to pointer
#define PARM_SHADOWDATA 40 // nasty hack, convert int to pointer
// skybox ordering
enum
@ -94,7 +96,7 @@ typedef enum
TF_NORMALMAP = (1<<15), // is a normalmap
TF_HAS_ALPHA = (1<<16), // image has alpha (used only for GL_CreateTexture)
TF_FORCE_COLOR = (1<<17), // force upload monochrome textures as RGB (detail textures)
// reserved
TF_UPDATE = (1<<18), // allow to update already loaded texture
TF_BORDER = (1<<19), // zero clamp for projected textures
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
TF_ATLAS_PAGE = (1<<21), // bit who indicate lightmap page or deluxemap page
@ -217,8 +219,8 @@ typedef struct render_api_s
struct mstudiotex_s *( *StudioGetTexture )( struct cl_entity_s *e );
const struct ref_overview_s *( *GetOverviewParms )( void );
const char *( *GetFileByIndex )( int fileindex );
void (*R_Reserved0)( void ); // for potential interface expansion without broken compatibility
void (*R_Reserved1)( void );
int (*pfnSaveFile)( const char *filename, const void *data, long len );
void (*R_Reserved0)( void );
// static allocations
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
@ -263,6 +265,8 @@ typedef struct render_interface_s
void (*R_NewMap)( void );
// clear the render entities before each frame
void (*R_ClearScene)( void );
// shuffle previous & next states for lerping
void (*CL_UpdateLatchedVars)( struct cl_entity_s *e, qboolean reset );
} render_interface_t;
#endif//RENDER_API_H

View File

@ -224,6 +224,10 @@ void CL_UpdateLatchedVars( cl_entity_t *ent )
memcpy( ent->latched.prevcontroller, ent->prevstate.controller, sizeof( ent->latched.prevcontroller ));
memcpy( ent->latched.prevblending, ent->prevstate.blending, sizeof( ent->latched.prevblending ));
// update custom latched vars
if( clgame.drawFuncs.CL_UpdateLatchedVars != NULL )
clgame.drawFuncs.CL_UpdateLatchedVars( ent, false );
}
/*
@ -254,6 +258,10 @@ void CL_ResetLatchedVars( cl_entity_t *ent, qboolean full_reset )
VectorCopy( ent->curstate.origin, ent->latched.prevorigin );
VectorCopy( ent->curstate.angles, ent->latched.prevangles );
ent->latched.prevsequence = ent->curstate.sequence;
// update custom latched vars
if( clgame.drawFuncs.CL_UpdateLatchedVars != NULL )
clgame.drawFuncs.CL_UpdateLatchedVars( ent, true );
}
/*

View File

@ -309,8 +309,12 @@ SCR_BeginLoadingPlaque
*/
void SCR_BeginLoadingPlaque( qboolean is_background )
{
float oldclear;
S_StopAllSounds( true );
cl.audio_prepped = false; // don't play ambients
cl.video_prepped = false;
oldclear = gl_clear->value;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{
@ -325,12 +329,14 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
if( cls.key_dest == key_console )
return;
gl_clear->value = 0.0f;
if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background;
SCR_UpdateScreen();
cls.disable_screen = host.realtime;
cls.disable_servercount = cl.servercount;
cl.background = is_background; // set right state before svc_serverdata is came
gl_clear->value = oldclear;
// SNDDMA_LockSound();
}

View File

@ -2938,14 +2938,16 @@ if cl_testlights is set, create 32 lights models
*/
void CL_TestLights( void )
{
int i, j;
int i, j, numLights;
vec3_t forward, right;
float f, r;
int numLights;
dlight_t *dl;
if( !cl_testlights->value ) return;
if( !CVAR_TO_BOOL( cl_testlights ))
return;
numLights = bound( 1, cl_testlights->value, MAX_DLIGHTS );
AngleVectors( cl.viewangles, forward, right, NULL );
for( i = 0; i < numLights; i++ )
{
@ -2955,7 +2957,7 @@ void CL_TestLights( void )
f = 64 * ( i / 4) + 128;
for( j = 0; j < 3; j++ )
dl->origin[j] = RI.vieworg[j] + RI.vforward[j] * f + RI.vright[j] * r;
dl->origin[j] = cl.simorg[j] + forward[j] * f + right[j] * r;
dl->color.r = ((((i % 6) + 1) & 1)>>0) * 255;
dl->color.g = ((((i % 6) + 1) & 2)>>1) * 255;

View File

@ -293,7 +293,7 @@ qboolean V_PreRender( void )
return false;
}
R_BeginFrame( !cl.paused );
R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
return true;
}

View File

@ -570,9 +570,6 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
if( size > glState.width || size > glState.height )
return false;
// setup refdef
RI.params |= RP_ENVVIEW; // do not render non-bmodel entities
// alloc space
temp = Mem_Malloc( r_temppool, size * size * 3 );
buffer = Mem_Malloc( r_temppool, size * size * 3 * 6 );
@ -582,6 +579,8 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
// use client vieworg
if( !vieworg ) vieworg = RI.vieworg;
R_CheckGamma();
for( i = 0; i < 6; i++ )
{
// go into 3d mode
@ -609,8 +608,6 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
memcpy( buffer + (size * size * 3 * i), r_side->buffer, size * size * 3 );
}
RI.params &= ~RP_ENVVIEW;
r_shot->flags = IMAGE_HAS_COLOR;
r_shot->flags |= (skyshot) ? IMAGE_SKYBOX : IMAGE_CUBEMAP;
r_shot->width = size;

View File

@ -72,12 +72,13 @@ void GL_Bind( GLint tmu, GLenum texnum )
gl_texture_t *texture;
GLuint glTarget;
Assert( texnum >= 0 && texnum < MAX_TEXTURES );
// missed or invalid texture?
if( texnum <= 0 || texnum >= MAX_TEXTURES )
{
if( texnum != 0 )
Con_DPrintf( S_ERROR "GL_Bind: invalid texturenum %d\n", texnum );
texnum = tr.defaultTexture;
}
if( tmu != GL_KEEP_UNIT )
GL_SelectTexture( tmu );
else tmu = glState.activeTMU;
@ -1679,6 +1680,7 @@ creates texture from buffer
*/
int GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags )
{
qboolean update = FBitSet( flags, TF_UPDATE ) ? true : false;
int datasize = 1;
rgbdata_t r_empty;
@ -1687,6 +1689,7 @@ int GL_CreateTexture( const char *name, int width, int height, const void *buffe
else if( FBitSet( flags, TF_ARB_FLOAT ))
datasize = 4;
ClearBits( flags, TF_UPDATE );
memset( &r_empty, 0, sizeof( r_empty ));
r_empty.width = width;
r_empty.height = height;
@ -1712,7 +1715,7 @@ int GL_CreateTexture( const char *name, int width, int height, const void *buffe
r_empty.size *= 6;
}
return GL_LoadTextureInternal( name, &r_empty, flags );
return GL_LoadTextureFromBuffer( name, &r_empty, flags, update );
}
/*

View File

@ -365,6 +365,7 @@ qboolean R_InitRenderAPI( void );
void R_AllowFog( int allowed );
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
void R_CheckGamma( void );
void R_PushScene( void );
void R_PopScene( void );
void R_DrawFog( void );
@ -597,6 +598,7 @@ typedef struct
gles_wrapper_t wrapper;
qboolean softwareGammaUpdate;
qboolean fCustomRenderer;
int prev_mode;
} glconfig_t;

View File

@ -985,30 +985,41 @@ some type of screenshots
*/
qboolean R_DoResetGamma( void )
{
// FIXME: this looks ugly. apply the backward gamma changes to the output image
return false;
switch( cls.scrshot_action )
{
case scrshot_normal:
if( CL_IsDevOverviewMode( ))
return true;
return false;
case scrshot_snapshot:
if( CL_IsDevOverviewMode( ))
return true;
return false;
case scrshot_plaque:
case scrshot_savegame:
case scrshot_envshot:
case scrshot_skyshot:
case scrshot_mapshot:
return true;
default:
return false;
}
}
/*
===============
R_CheckGamma
===============
*/
void R_CheckGamma( void )
{
if( R_DoResetGamma( ))
{
// paranoia cubemaps uses this
BuildGammaTable( 1.8f, 0.0f );
// paranoia cubemap rendering
if( clgame.drawFuncs.GL_BuildLightmaps )
clgame.drawFuncs.GL_BuildLightmaps( );
}
else if( FBitSet( vid_gamma->flags, FCVAR_CHANGED ) || FBitSet( vid_brightness->flags, FCVAR_CHANGED ))
{
BuildGammaTable( vid_gamma->value, vid_brightness->value );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
}
}
/*
===============
R_BeginFrame
@ -1023,24 +1034,7 @@ void R_BeginFrame( qboolean clearScene )
pglClear( GL_COLOR_BUFFER_BIT );
}
if( R_DoResetGamma( ))
{
BuildGammaTable( 1.8f, 0.0f );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
// next frame will be restored gamma
SetBits( vid_brightness->flags, FCVAR_CHANGED );
SetBits( vid_gamma->flags, FCVAR_CHANGED );
}
else if( FBitSet( vid_gamma->flags, FCVAR_CHANGED ) || FBitSet( vid_brightness->flags, FCVAR_CHANGED ))
{
BuildGammaTable( vid_gamma->value, vid_brightness->value );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
}
R_CheckGamma();
R_Set2DMode( true );
@ -1072,8 +1066,14 @@ void R_SetupRefParams( const ref_viewpass_t *rvp )
RI.farClip = 0;
if( !FBitSet( rvp->flags, RF_DRAW_CUBEMAP ))
{
RI.drawOrtho = FBitSet( rvp->flags, RF_DRAW_OVERVIEW );
else RI.drawOrtho = false;
}
else
{
SetBits( RI.params, RP_ENVVIEW );
RI.drawOrtho = false;
}
// setup viewport
RI.viewport[0] = rvp->viewport[0];
@ -1276,6 +1276,10 @@ static int GL_RenderGetParm( int parm, int arg )
return FBitSet( world.flags, FWORLD_WATERALPHA );
case PARM_TEX_MEMORY:
return GL_TexMemory();
case PARM_DELUXEDATA:
return *(int *)&world.deluxedata;
case PARM_SHADOWDATA:
return *(int *)&world.shadowdata;
}
return 0;
}
@ -1514,7 +1518,7 @@ static render_api_t gRenderAPI =
R_StudioGetTexture,
GL_GetOverviewParms,
CL_GenericHandle,
NULL,
COM_SaveFile,
NULL,
R_Mem_Alloc,
R_Mem_Free,
@ -1540,12 +1544,14 @@ qboolean R_InitRenderAPI( void )
{
// make sure what render functions is cleared
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
glConfig.fCustomRenderer = false;
if( clgame.dllFuncs.pfnGetRenderInterface )
{
if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs ))
{
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
glConfig.fCustomRenderer = true;
return true;
}

View File

@ -58,6 +58,7 @@ public:
virtual void GetMousePos( int &x, int &y ) { }
#endif
virtual bool hasFocus( void ) { return true; }
virtual void flushBuffer( void );
protected:
virtual int createNewTextureID( void );
virtual void drawSetColor( int r, int g, int b, int a );
@ -83,7 +84,6 @@ protected:
virtual void setAsTopMost( bool state ) { }
virtual void applyChanges( void ) { }
virtual void swapBuffers( void ) { }
virtual void flushBuffer( void );
protected:
int _drawTextPos[2];
int _drawColor[4];

View File

@ -23,7 +23,7 @@ static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int Q_buildnum( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
#if 1
#if 0
int m = 0, d = 0, y = 0;
static int b = 0;
@ -48,6 +48,6 @@ int Q_buildnum( void )
return b;
#else
return 4260;
return 4511;
#endif
}

View File

@ -21,6 +21,7 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "qfont.h"
#include "wadfile.h"
#include "input.h"
convar_t *con_notifytime;
convar_t *scr_conspeed;
@ -128,6 +129,9 @@ typedef struct
char *completionBuffer;
char *cmds[CON_MAXCMDS];
int matchCount;
// console update
double lastupdate;
} console_t;
static console_t con;
@ -429,7 +433,7 @@ Con_AddLine
Appends a given string as a new line to the console.
================
*/
void Con_AddLine( const char *line, int length )
void Con_AddLine( const char *line, int length, qboolean newline )
{
byte *putpos;
con_lineinfo_t *p;
@ -445,14 +449,27 @@ void Con_AddLine( const char *line, int length )
while( !( putpos = Con_BytesLeft( length )) || con.lines_count >= con.maxlines )
Con_DeleteLine();
memcpy( putpos, line, length );
putpos[length - 1] = '\0';
con.lines_count++;
if( newline )
{
memcpy( putpos, line, length );
putpos[length - 1] = '\0';
con.lines_count++;
p = &CON_LINES_LAST();
p->start = putpos;
p->length = length;
p->addtime = cl.time;
p = &CON_LINES_LAST();
p->start = putpos;
p->length = length;
p->addtime = cl.time;
}
else
{
p = &CON_LINES_LAST();
putpos = p->start + Q_strlen( p->start );
memcpy( putpos, line, length - 1 );
p->length = Q_strlen( p->start );
putpos[p->length] = '\0';
p->addtime = cl.time;
p->length++;
}
}
/*
@ -1017,6 +1034,8 @@ void Con_Print( const char *txt )
{
static int cr_pending = 0;
static char buf[MAX_PRINT_MSG];
qboolean norefresh = false;
static int lastlength = 0;
static qboolean inupdate;
static int bufpos = 0;
int c, mask = 0;
@ -1033,6 +1052,12 @@ void Con_Print( const char *txt )
txt++;
}
if( txt[0] == 3 )
{
norefresh = true;
txt++;
}
for( ; *txt; txt++ )
{
if( cr_pending )
@ -1048,27 +1073,47 @@ void Con_Print( const char *txt )
case '\0':
break;
case '\r':
Con_AddLine( buf, bufpos );
Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length;
cr_pending = 1;
bufpos = 0;
break;
case '\n':
Con_AddLine( buf, bufpos );
Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length;
bufpos = 0;
break;
default:
buf[bufpos++] = c | mask;
if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 ))
{
Con_AddLine( buf, bufpos );
Con_AddLine( buf, bufpos, true );
lastlength = CON_LINES_LAST().length;
bufpos = 0;
}
break;
}
}
if( cls.state != ca_disconnected && cls.state < ca_active && !cl.video_prepped && !cls.disable_screen )
if( norefresh ) return;
// custom renderer cause problems while updates screen on-loading
if( SV_Active() && cls.state < ca_active && !cl.video_prepped && !cls.disable_screen )
{
if( bufpos != 0 )
{
Con_AddLine( buf, bufpos, lastlength != 0 );
lastlength = 0;
bufpos = 0;
}
// pump messages to avoid window hanging
if( con.lastupdate < Sys_DoubleTime( ))
{
con.lastupdate = Sys_DoubleTime() + 1.0;
Host_InputFrame();
}
if( !inupdate )
{
inupdate = true;
@ -2035,7 +2080,7 @@ int Con_DrawConsoleLine( int y, int lineno )
{
con_lineinfo_t *li = &CON_LINES( lineno );
if( *li->start == '\1' )
if( !li || !li->start || *li->start == '\1' )
return 0; // this string will be shown only at notify
if( y >= con.curFont->charHeight )

View File

@ -1380,6 +1380,9 @@ static void Image_ApplyFilter( rgbdata_t *pic, float factor )
uint *fin, *fout;
size_t size;
// don't waste time
if( factor <= 0.0f ) return;
// first expand the image into 32-bit buffer
pic = Image_DecompressInternal( pic );
factor = bound( 0.0f, factor, 1.0f );

View File

@ -2802,6 +2802,8 @@ qboolean Mod_LoadBmodelLumps( const byte *mod_base, qboolean isworld )
{
loadmodel = mod; // restore pointer to world
Mod_InitDebugHulls(); // FIXME: build hulls for separate bmodels (shells, medkits etc)
world.deluxedata = bmod->deluxedata_out; // deluxemap data pointer
world.shadowdata = bmod->shadowdata_out; // occlusion data pointer
}
for( i = 0; i < bmod->wadlist.count; i++ )
@ -2922,6 +2924,13 @@ void Mod_UnloadBrushModel( model_t *mod )
if( mod->type != mod_brush )
return; // not a bmodel
// invalidate pointers
if( FBitSet( mod->flags, MODEL_WORLD ))
{
world.deluxedata = NULL;
world.shadowdata = NULL;
}
if( mod->name[0] != '*' )
{
for( i = 0; i < mod->numtextures; i++ )

View File

@ -139,6 +139,10 @@ typedef struct
hull_model_t *hull_models;
int num_hull_models;
// out pointers to light data
color24 *deluxedata; // deluxemap data pointer
byte *shadowdata; // occlusion data pointer
// visibility info
size_t visbytes; // cluster size
size_t fatbytes; // fatpvs size

View File

@ -879,7 +879,7 @@ int Delta_ClampIntegerField( delta_t *pField, int iValue, qboolean bSigned, int
{
#ifdef _DEBUG
if( numbits < 32 && abs( iValue ) >= (uint)BIT( numbits ))
Msg( "%s %d overflow %d\n", pField->name, abs( iValue ), (uint)BIT( numbits ));
Con_Reportf( "%s %d overflow %d\n", pField->name, abs( iValue ), (uint)BIT( numbits ));
#endif
if( numbits < 32 )
{

View File

@ -254,7 +254,7 @@ qboolean Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize )
if( sound.samples <= 0 )
{
Con_DPrintf( S_ERROR "Sound_LoadWAV: file with %i samples (%s)\n", sound.samples, name );
Con_Reportf( S_ERROR "Sound_LoadWAV: file with %i samples (%s)\n", sound.samples, name );
return false;
}

View File

@ -535,6 +535,6 @@ void Sys_CloseLog( void )
void Sys_PrintLog( const char *pMsg )
{
if( !s_wcd.logfile ) return;
fprintf( s_wcd.logfile, pMsg );
fprintf( s_wcd.logfile, "%s", pMsg );
fflush( s_wcd.logfile );
}

View File

@ -611,7 +611,7 @@ void Sys_Print( const char *pMsg )
}
else
{
if( msg[i] == '\1' || msg[i] == '\2' )
if( msg[i] == '\1' || msg[i] == '\2' || msg[i] == '\3' )
i++;
*b = *c = msg[i];
b++, c++;

View File

@ -285,6 +285,8 @@ void SV_NextMap_f( void )
search_t *t;
t = FS_Search( "maps\\*.bsp", true, CVAR_TO_BOOL( con_gamemaps )); // only in gamedir
if( !t ) t = FS_Search( "maps/*.bsp", true, CVAR_TO_BOOL( con_gamemaps )); // only in gamedir
if( !t )
{
Con_Printf( "next map can't be found\n" );