09 Jun 2019

This commit is contained in:
g-cont 2019-06-09 00:00:00 +03:00 committed by Alibek Omarov
parent f696426239
commit 195f207ba5
15 changed files with 97 additions and 27 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 );
@ -264,7 +266,7 @@ typedef struct render_interface_s
// 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 );
void (*CL_UpdateLatchedVars)( struct cl_entity_s *e, qboolean reset );
} render_interface_t;
#endif//RENDER_API_H

View File

@ -227,7 +227,7 @@ void CL_UpdateLatchedVars( cl_entity_t *ent )
// update custom latched vars
if( clgame.drawFuncs.CL_UpdateLatchedVars != NULL )
clgame.drawFuncs.CL_UpdateLatchedVars( ent );
clgame.drawFuncs.CL_UpdateLatchedVars( ent, false );
}
/*
@ -258,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

@ -311,6 +311,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
{
S_StopAllSounds( true );
cl.audio_prepped = false; // don't play ambients
cl.video_prepped = false;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{

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

@ -1679,6 +1679,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 +1688,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 +1714,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

@ -597,6 +597,7 @@ typedef struct
gles_wrapper_t wrapper;
qboolean softwareGammaUpdate;
qboolean fCustomRenderer;
int prev_mode;
} glconfig_t;

View File

@ -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

@ -306,7 +306,7 @@ void CEngineSurface :: drawPrintChar( int x, int y, int wide, int tall, float s0
if( !ClipRect( ul, lr, &clippedRect[0], &clippedRect[1] ))
return;
#if 1
#if 0
// TESTTEST: needs to be more tested
addCharToBuffer( &clippedRect[0], &clippedRect[1], color );
#else

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,7 @@ void Con_Print( const char *txt )
{
static int cr_pending = 0;
static char buf[MAX_PRINT_MSG];
static int lastlength = 0;
static qboolean inupdate;
static int bufpos = 0;
int c, mask = 0;
@ -1048,27 +1066,45 @@ 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 )
// 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;

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

@ -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 );
}