2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-22 09:56:22 +01:00

Merge 4511 update

This commit is contained in:
Alibek Omarov 2019-06-17 07:36:46 +03:00
commit f2c927906f
22 changed files with 203 additions and 86 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
@ -220,8 +222,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 );
@ -267,6 +269,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

@ -223,6 +223,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 );
}
/*
@ -280,6 +284,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

@ -162,6 +162,10 @@ int CL_RenderGetParm( const int parm, const int arg, const qboolean checkRef )
return (host.type == HOST_DEDICATED);
case PARM_WATER_ALPHA:
return FBitSet( world.flags, FWORLD_WATERALPHA );
case PARM_DELUXEDATA:
return *(int *)&world.deluxedata;
case PARM_SHADOWDATA:
return *(int *)&world.shadowdata;
default:
// indicates call from client.dll
if( checkRef )
@ -261,7 +265,7 @@ static render_api_t gRenderAPI =
NULL, // R_StudioGetTexture,
GL_GetOverviewParms,
CL_GenericHandle,
NULL,
COM_SaveFile,
NULL,
R_Mem_Alloc,
R_Mem_Free,

View File

@ -341,8 +341,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 )
{
@ -357,12 +361,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

@ -2835,15 +2835,17 @@ 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++ )
{
dl = &cl_dlights[i];
@ -2851,8 +2853,8 @@ void CL_TestLights( void )
r = 64 * ((i % 4) - 1.5f );
f = 64 * ( i / 4) + 128;
VectorMAM( f, refState.vforward, r, refState.vright, dl->origin );
VectorAdd( dl->origin, refState.vieworg, dl->origin );
for( j = 0; j < 3; j++ )
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

@ -292,8 +292,8 @@ qboolean V_PreRender( void )
}
return false;
}
ref.dllFuncs.R_BeginFrame( !cl.paused );
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
GL_UpdateSwapInterval( );

View File

@ -20,6 +20,7 @@ GNU General Public License for more details.
#include "con_nprint.h"
#include "qfont.h"
#include "wadfile.h"
#include "input.h"
convar_t *con_notifytime;
convar_t *scr_conspeed;
@ -117,6 +118,9 @@ typedef struct
notify_t notify[MAX_DBG_NOTIFY]; // for Con_NXPrintf
qboolean draw_notify; // true if we have NXPrint message
// console update
double lastupdate;
} console_t;
static console_t con;
@ -401,7 +405,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;
@ -417,14 +421,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++;
}
}
/*
@ -1211,6 +1228,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;
@ -1227,6 +1246,12 @@ void Con_Print( const char *txt )
txt++;
}
if( txt[0] == 3 )
{
norefresh = true;
txt++;
}
for( ; *txt; txt++ )
{
if( cr_pending )
@ -1242,27 +1267,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;
@ -1976,7 +2021,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

@ -197,6 +197,25 @@ static screenfade_t *pfnRefGetScreenFade( void )
return &clgame.fade;
}
/*
===============
R_DoResetGamma
gamma will be reset for
some type of screenshots
===============
*/
static qboolean R_DoResetGamma( void )
{
switch( cls.scrshot_action )
{
case scrshot_envshot:
case scrshot_skyshot:
return true;
default:
return false;
}
}
static ref_api_t gEngfuncs =
{
pfnEngineGetParm,
@ -319,6 +338,7 @@ static ref_api_t gEngfuncs =
BuildGammaTable,
LightToTexGamma,
R_DoResetGamma,
CL_GetLightStyle,
CL_GetDynamicLight,

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,7 +48,7 @@ int Q_buildnum( void )
return b;
#else
return 4260;
return 4511;
#endif
}

View File

@ -1379,6 +1379,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

@ -2822,6 +2822,8 @@ qboolean Mod_LoadBmodelLumps( const byte *mod_base, qboolean isworld )
loadmodel = mod; // restore pointer to world
#ifndef XASH_DEDICATED
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
#endif // XASH_DEDICATED
}
@ -2926,6 +2928,47 @@ void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded )
if( loaded ) *loaded = true; // all done
}
/*
=================
Mod_UnloadBrushModel
Release all uploaded textures
=================
*/
void Mod_UnloadBrushModel( model_t *mod )
{
texture_t *tx;
int i;
Assert( mod != NULL );
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++ )
{
tx = mod->textures[i];
if( !tx || tx->gl_texturenum == tr.defaultTexture )
continue; // free slot
GL_FreeTexture( tx->gl_texturenum ); // main texture
GL_FreeTexture( tx->fb_texturenum ); // luma texture
}
Mem_FreePool( &mod->mempool );
}
memset( mod, 0, sizeof( *mod ));
}
/*
==================
Mod_CheckLump

View File

@ -96,6 +96,10 @@ typedef struct world_static_s
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

@ -896,7 +896,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, fs_offset_t filesi
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

@ -552,10 +552,10 @@ 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++;
*b = *c = msg[i];
b++, c++;
}
i++;
}

View File

@ -395,6 +395,7 @@ typedef struct ref_api_s
// gamma
void (*BuildGammaTable)( float lightgamma, float brightness );
byte (*LightToTexGamma)( byte color ); // software gamma support
qboolean (*R_DoResetGamma)( void );
// renderapi
lightstyle_t* (*GetLightStyle)( int number );

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" );

View File

@ -539,9 +539,6 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
if( size > gpGlobals->width || size > gpGlobals->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 );
@ -551,6 +548,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
@ -578,8 +577,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

@ -71,12 +71,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;
@ -1680,6 +1681,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;
@ -1688,6 +1690,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;
@ -1713,7 +1716,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

@ -388,6 +388,7 @@ void R_SetupGL( qboolean set_gl_state );
void R_AllowFog( qboolean 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 );
@ -668,6 +669,7 @@ typedef struct
gles_wrapper_t wrapper;
qboolean softwareGammaUpdate;
qboolean fCustomRenderer;
int prev_width;
int prev_height;
} glconfig_t;

View File

@ -986,37 +986,27 @@ void R_RenderScene( void )
/*
===============
R_DoResetGamma
gamma will be reset for
some type of screenshots
R_CheckGamma
===============
*/
qboolean R_DoResetGamma( void )
void R_CheckGamma( void )
{
// FIXME: this looks ugly. apply the backward gamma changes to the output image
return false;
#if 0
switch( cls.scrshot_action )
if( gEngfuncs.R_DoResetGamma( ))
{
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;
// 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;
}
#endif
}
/*
@ -1034,24 +1024,7 @@ void R_BeginFrame( qboolean clearScene )
pglClear( GL_COLOR_BUFFER_BIT );
}
if( R_DoResetGamma( ))
{
gEngfuncs.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 ))
{
gEngfuncs.BuildGammaTable( vid_gamma->value, vid_brightness->value );
glConfig.softwareGammaUpdate = true;
GL_RebuildLightmaps();
glConfig.softwareGammaUpdate = false;
}
R_CheckGamma();
R_Set2DMode( true );

View File

@ -87,7 +87,7 @@ public:
virtual bool isWithin( int x, int y ) { return true; }
virtual bool hasFocus( void );
// now it's not abstract class, yay
virtual void GetMousePos(int &x, int &y) {
virtual void GetMousePos(int &x, int &y) {
g_api->GetCursorPos(&x, &y);
}
void drawPrintChar(int x, int y, int wide, int tall, float s0, float t0, float s1, float t1, int color[]);