11 Dec 2016

This commit is contained in:
g-cont 2016-12-11 00:00:00 +03:00 committed by Alibek Omarov
parent 102a5f8400
commit 3179cba8ef
10 changed files with 83 additions and 53 deletions

View File

@ -67,6 +67,8 @@ GNU General Public License for more details.
#define PARM_REBUILD_GAMMA 31 // if true lightmaps rebuilding for gamma change
#define PARM_DEDICATED_SERVER 32
#define PARM_SURF_SAMPLESIZE 33 // lightmap resolution per face (second arg interpret as facenumber)
#define PARM_GL_CONTEXT_TYPE 34 // opengl or opengles
#define PARM_GLES_WRAPPER 35 //
enum
{
@ -112,6 +114,19 @@ typedef enum
TF_ARB_16BIT = (1<<28), // keep image as 16-bit (not 24)
} texFlags_t;
typedef enum
{
CONTEXT_TYPE_GL = 0,
CONTEXT_TYPE_GLES_1_X,
CONTEXT_TYPE_GLES_2_x
} gl_context_type_t;
typedef enum
{
GLES_WRAPPER_NONE = 0, // native GLES
GLES_WRAPPER_NANOGL, // used on GLES platforms
} gles_wrapper_t;
typedef struct beam_s BEAM;
typedef struct particle_s particle_t;
@ -194,11 +209,11 @@ typedef struct render_api_s
void (*GL_TexGen)( unsigned int coord, unsigned int mode );
void (*GL_TextureTarget)( unsigned int target ); // change texture unit mode without bind texture
void (*GL_TexCoordArrayMode)( unsigned int texmode );
void* (*GL_GetProcAddress)( const char *name );
void (*GL_Reserved0)( void ); // for potential interface expansion without broken compatibility
void (*GL_Reserved1)( void );
void (*GL_Reserved2)( void );
void (*GL_Reserved3)( void );
// Misc renderer functions
void (*GL_DrawParticles)( const float *vieworg, const float *fwd, const float *rt, const float *up, unsigned int clipFlags );
void (*EnvShot)( const float *vieworg, const char *name, qboolean skyshot, int shotsize ); // creates a cubemap or skybox into gfx\env folder

View File

@ -577,6 +577,9 @@ void CL_WeaponAnim( int iAnim, int body )
view->curstate.frame = 0.0f;
view->curstate.body = body;
view->curstate.rendermode = kRenderNormal;
view->curstate.renderamt = 255;
#if 0 // g-cont. for GlowShell testing
view->curstate.renderfx = kRenderFxGlowShell;
view->curstate.rendercolor.r = 255;

View File

@ -1900,7 +1900,7 @@ void CL_InitLocal( void )
Cvar_Get( "skin", "", CVAR_USERINFO, "player skin" ); // XDM 3.3 want this cvar
cl_updaterate = Cvar_Get( "cl_updaterate", "60", CVAR_USERINFO|CVAR_ARCHIVE, "refresh rate of server messages" );
Cvar_Get( "cl_background", "0", CVAR_READ_ONLY, "indicate what background map is running" );
Cvar_Get( "cl_msglevel", "3", CVAR_USERINFO|CVAR_ARCHIVE, "message filter for server notifications" );
Cvar_Get( "cl_msglevel", "0", CVAR_USERINFO|CVAR_ARCHIVE, "message filter for server notifications" );
// these two added to shut up CS 1.5 about 'unknown' commands
Cvar_Get( "lightgamma", "1", CVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );

View File

@ -33,7 +33,6 @@ typedef struct
vec3_t color;
float texcoord; // Y texture coordinate
float width;
float alpha;
} beamseg_t;
static float rgNoise[NOISE_DIVISIONS+1]; // global noise array
@ -88,24 +87,12 @@ static cl_entity_t *CL_GetBeamEntityByIndex( int index )
return ent;
}
void BeamNormalizeColor( BEAM *pBeam, float r, float g, float b, float brightness )
void BeamNormalizeColor( BEAM *pBeam, int r, int g, int b, float brightness )
{
float max, scale;
max = max( max( r, g ), b );
if( max == 0 )
{
pBeam->r = pBeam->g = pBeam->b = 255.0f;
pBeam->brightness = brightness;
}
scale = 255.0f / max;
pBeam->r = r * scale;
pBeam->g = g * scale;
pBeam->b = b * scale;
pBeam->brightness = brightness * scale * 255.0f;
pBeam->r = (float)r;
pBeam->g = (float)g;
pBeam->b = (float)b;
pBeam->brightness = brightness;
}
static qboolean ComputeBeamEntPosition( int beamEnt, vec3_t pt )
@ -269,7 +256,6 @@ static void CL_DrawSegs( int modelIndex, float frame, int rendermode, const vec3
vec3_t vPoint1, vPoint2;
ASSERT( noiseIndex < ( NOISE_DIVISIONS << 16 ));
nextSeg.alpha = 1.0f;
fraction = i * div;
@ -350,12 +336,12 @@ static void CL_DrawSegs( int modelIndex, float frame, int rendermode, const vec3
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vAveNormal, vPoint1 );
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vAveNormal, vPoint2 );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], curSeg.alpha );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], 1.0f );
pglTexCoord2f( 0.0f, curSeg.texcoord );
pglNormal3fv( vAveNormal );
pglVertex3fv( vPoint1 );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], curSeg.alpha );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], 1.0f );
pglTexCoord2f( 1.0f, curSeg.texcoord );
pglNormal3fv( vAveNormal );
pglVertex3fv( vPoint2 );
@ -371,12 +357,12 @@ static void CL_DrawSegs( int modelIndex, float frame, int rendermode, const vec3
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vLastNormal, vPoint2 );
// specify the points.
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], curSeg.alpha );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], 1.0f );
pglTexCoord2f( 0.0f, curSeg.texcoord );
pglNormal3fv( vLastNormal );
pglVertex3fv( vPoint1 );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], curSeg.alpha );
pglColor4f( curSeg.color[0], curSeg.color[1], curSeg.color[2], 1.0f );
pglTexCoord2f( 1.0f, curSeg.texcoord );
pglNormal3fv( vLastNormal );
pglVertex3fv( vPoint2 );
@ -1442,10 +1428,10 @@ void CL_DrawBeam( BEAM *pbeam )
pStart = CL_GetBeamEntityByIndex( pbeam->startEntity );
if( pStart && pStart->curstate.rendermode != kRenderNormal )
pbeam->brightness = pStart->curstate.renderamt;
}
VectorScale( color, ( pbeam->brightness / 255.0f ), color );
VectorScale( color, ( 1.0f / 255.0f ), color );
VectorScale( color, ( pbeam->brightness / 255.0f ), color );
VectorScale( color, ( 1.0f / 255.0f ), color );
}
switch( pbeam->type )
{
@ -1514,9 +1500,9 @@ void CL_DrawCustomBeam( cl_entity_t *pbeam )
beam.width = pbeam->curstate.scale;
beam.amplitude = (float)(pbeam->curstate.body * 0.1f);
beam.brightness = pbeam->curstate.renderamt;
beam.r = pbeam->curstate.rendercolor.r;
beam.g = pbeam->curstate.rendercolor.g;
beam.b = pbeam->curstate.rendercolor.b;
beam.r = pbeam->curstate.rendercolor.r / 255.0f;
beam.g = pbeam->curstate.rendercolor.g / 255.0f;
beam.b = pbeam->curstate.rendercolor.b / 255.0f;
beam.flags = 0;
VectorSubtract( beam.target, beam.source, beam.delta );
@ -1982,9 +1968,9 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.1f);
r = (float)MSG_ReadByte( msg );
g = (float)MSG_ReadByte( msg );
b = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
brightness = (float)MSG_ReadByte( msg );
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
CL_BeamPoints( start, end, modelIndex, life, width, noise, brightness, speed, startFrame,
@ -2001,9 +1987,9 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
r = (float)MSG_ReadByte( msg );
g = (float)MSG_ReadByte( msg );
b = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
brightness = (float)MSG_ReadByte( msg );
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
CL_BeamEntPoint( startEnt, end, modelIndex, life, width, noise, brightness, speed, startFrame,
@ -2031,9 +2017,9 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.01f);
r = (float)MSG_ReadByte( msg );
g = (float)MSG_ReadByte( msg );
b = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
brightness = (float)MSG_ReadByte( msg );
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
CL_BeamEnts( startEnt, endEnt, modelIndex, life, width, noise, brightness, speed, startFrame,
@ -2068,9 +2054,9 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)MSG_ReadByte( msg );
noise = (float)(MSG_ReadByte( msg ) * 0.1f);
r = (float)MSG_ReadByte( msg );
g = (float)MSG_ReadByte( msg );
b = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
brightness = (float)MSG_ReadByte( msg );
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
CL_BeamCirclePoints( beamType, start, end, modelIndex, life, width, noise, brightness, speed,
@ -2096,9 +2082,9 @@ void CL_ParseViewBeam( sizebuf_t *msg, int beamType )
life = (float)(MSG_ReadByte( msg ) * 0.1f);
width = (float)(MSG_ReadByte( msg ) * 0.1f);
noise = (float)(MSG_ReadByte( msg ) * 0.1f);
r = (float)MSG_ReadByte( msg );
g = (float)MSG_ReadByte( msg );
b = (float)MSG_ReadByte( msg );
r = (float)MSG_ReadByte( msg ) / 255.0f;
g = (float)MSG_ReadByte( msg ) / 255.0f;
b = (float)MSG_ReadByte( msg ) / 255.0f;
brightness = (float)MSG_ReadByte( msg );
speed = (float)(MSG_ReadByte( msg ) * 0.1f);
CL_BeamRing( startEnt, endEnt, modelIndex, life, width, noise, brightness, speed, startFrame,

View File

@ -433,6 +433,7 @@ void EmitWaterPolys( glpoly_t *polys, qboolean noCull, qboolean direction );
//
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
void *GL_GetProcAddress( const char *name );
void GL_UpdateSwapInterval( void );
void GL_UpdateGammaRamp( void );
qboolean GL_DeleteContext( void );
@ -578,6 +579,9 @@ typedef struct
int depth_bits;
int stencil_bits;
gl_context_type_t context;
gles_wrapper_t wrapper;
qboolean softwareGammaUpdate;
qboolean deviceSupportsGamma;
int prev_mode;

View File

@ -1449,6 +1449,10 @@ static int GL_RenderGetParm( int parm, int arg )
if( arg >= 0 && arg < cl.worldmodel->numsurfaces )
return Mod_SampleSizeForFace( &cl.worldmodel->surfaces[arg] );
return LM_SAMPLE_SIZE;
case PARM_GL_CONTEXT_TYPE:
return glConfig.context;
case PARM_GLES_WRAPPER:
return glConfig.wrapper;
}
return 0;
}
@ -1604,6 +1608,7 @@ static void *R_Mem_Alloc( size_t cb, const char *filename, const int fileline )
static void R_Mem_Free( void *mem, const char *filename, const int fileline )
{
if( !mem ) return;
_Mem_Free( mem, filename, fileline );
}
@ -1671,7 +1676,7 @@ static render_api_t gRenderAPI =
GL_TexGen,
GL_TextureTarget,
GL_SetTexCoordArrayMode,
NULL,
GL_GetProcAddress,
NULL,
NULL,
NULL,

View File

@ -258,10 +258,22 @@ static qboolean R_StudioComputeBBox( cl_entity_t *e, vec3_t bbox[8] )
// rotate the bounding box
VectorCopy( e->angles, angles );
#if 0
if( e->player ) angles[PITCH] = 0.0f; // don't rotate player model, only aim
AngleVectors( angles, vectors[0], vectors[1], vectors[2] );
#else
vectors[0][0] = g_rotationmatrix[0][0];
vectors[0][1] = g_rotationmatrix[1][0];
vectors[0][2] = g_rotationmatrix[2][0];
vectors[1][0] = g_rotationmatrix[0][1];
vectors[1][1] = g_rotationmatrix[1][1];
vectors[1][2] = g_rotationmatrix[2][1];
vectors[2][0] = g_rotationmatrix[0][2];
vectors[2][1] = g_rotationmatrix[1][2];
vectors[2][2] = g_rotationmatrix[2][2];
#endif
// compute a full bounding box
for( i = 0; i < 8; i++ )
{
@ -271,7 +283,7 @@ static qboolean R_StudioComputeBBox( cl_entity_t *e, vec3_t bbox[8] )
// rotate by YAW
p2[0] = DotProduct( p1, vectors[0] );
p2[1] = DotProduct( p1, vectors[1] );
p2[1] = -DotProduct( p1, vectors[1] );
p2[2] = DotProduct( p1, vectors[2] );
if( bbox ) VectorAdd( p2, e->origin, bbox[i] );

View File

@ -1817,6 +1817,10 @@ void GL_InitExtensions( void )
glConfig.extensions_string = pglGetString( GL_EXTENSIONS );
MsgDev( D_INFO, "Video: %s\n", glConfig.renderer_string );
// intialize wrapper type
glConfig.context = CONTEXT_TYPE_GL;
glConfig.wrapper = GLES_WRAPPER_NONE;
if( Q_stristr( glConfig.renderer_string, "geforce" ))
glConfig.hardware_type = GLHW_NVIDIA;
else if( Q_stristr( glConfig.renderer_string, "quadro fx" ))

View File

@ -701,7 +701,7 @@ qboolean SND_CheckPHS( channel_t *ch )
{
mleaf_t *leaf;
if( !ch->dist_mult )
if( !ch->dist_mult || !s_phs->integer )
return true; // no attenuation
leaf = Mod_PointInLeaf( ch->origin, cl.worldmodel->nodes );

View File

@ -873,7 +873,7 @@ static edict_t *SV_PushMove( edict_t *pusher, float movetime )
sv_pushed_t *p, *pushed_p;
edict_t *check;
if( VectorIsNull( pusher->v.velocity ))
if( svgame.globals->changelevel || VectorIsNull( pusher->v.velocity ))
{
pusher->v.ltime += movetime;
return NULL;
@ -991,7 +991,7 @@ static edict_t *SV_PushRotate( edict_t *pusher, float movetime )
vec3_t org, org2, temp;
edict_t *check;
if( VectorIsNull( pusher->v.avelocity ))
if( svgame.globals->changelevel || VectorIsNull( pusher->v.avelocity ))
{
pusher->v.ltime += movetime;
return NULL;
@ -1928,6 +1928,7 @@ static void *pfnMem_Alloc( size_t cb, const char *filename, const int fileline )
static void pfnMem_Free( void *mem, const char *filename, const int fileline )
{
if( !mem ) return;
_Mem_Free( mem, filename, fileline );
}