ref: soft: as an experiment, reformat ref_soft as it's easier to notice config inaccuracies

This commit is contained in:
Alibek Omarov 2024-11-06 02:41:38 +03:00
parent fbbafb45a3
commit a52c8aa291
23 changed files with 5299 additions and 5018 deletions

View file

@ -23,15 +23,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static finalvert_t fv[2][8];
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv);
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out);
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out);
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out);
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out);
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv );
void R_Alias_clip_top( finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out );
void R_Alias_clip_bottom( finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out );
void R_Alias_clip_left( finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out );
void R_Alias_clip_right( finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out );
/*
@ -41,169 +41,169 @@ R_Alias_clip_z
pfv0 is the unclipped vertex, pfv1 is the z-clipped vertex
================
*/
static void R_Alias_clip_z (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
static void R_Alias_clip_z( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
{
float scale;
scale = (ALIAS_Z_CLIP_PLANE - pfv0->xyz[2]) /
(pfv1->xyz[2] - pfv0->xyz[2]);
scale = ( ALIAS_Z_CLIP_PLANE - pfv0->xyz[2] )
/ ( pfv1->xyz[2] - pfv0->xyz[2] );
out->xyz[0] = pfv0->xyz[0] + (pfv1->xyz[0] - pfv0->xyz[0]) * scale;
out->xyz[1] = pfv0->xyz[1] + (pfv1->xyz[1] - pfv0->xyz[1]) * scale;
out->xyz[0] = pfv0->xyz[0] + ( pfv1->xyz[0] - pfv0->xyz[0] ) * scale;
out->xyz[1] = pfv0->xyz[1] + ( pfv1->xyz[1] - pfv0->xyz[1] ) * scale;
out->xyz[2] = ALIAS_Z_CLIP_PLANE;
out->s = pfv0->s + (pfv1->s - pfv0->s) * scale;
out->t = pfv0->t + (pfv1->t - pfv0->t) * scale;
out->l = pfv0->l + (pfv1->l - pfv0->l) * scale;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale;
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale;
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale;
R_AliasProjectAndClipTestFinalVert (out);
R_AliasProjectAndClipTestFinalVert( out );
}
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
void R_Alias_clip_left( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
{
float scale;
if (pfv0->v >= pfv1->v )
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrect.x - pfv0->u) /
(pfv1->u - pfv0->u);
scale = (float)( RI.aliasvrect.x - pfv0->u )
/ ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
}
else
{
scale = (float)(RI.aliasvrect.x - pfv1->u) /
(pfv0->u - pfv1->u);
scale = (float)( RI.aliasvrect.x - pfv1->u )
/ ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
}
}
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
void R_Alias_clip_right( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
{
float scale;
if ( pfv0->v >= pfv1->v )
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrectright - pfv0->u ) /
(pfv1->u - pfv0->u );
scale = (float)( RI.aliasvrectright - pfv0->u )
/ ( pfv1->u - pfv0->u );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
}
else
{
scale = (float)(RI.aliasvrectright - pfv1->u ) /
(pfv0->u - pfv1->u );
scale = (float)( RI.aliasvrectright - pfv1->u )
/ ( pfv0->u - pfv1->u );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
}
}
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
void R_Alias_clip_top( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out )
{
float scale;
if (pfv0->v >= pfv1->v)
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrect.y - pfv0->v) /
(pfv1->v - pfv0->v);
scale = (float)( RI.aliasvrect.y - pfv0->v )
/ ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
}
else
{
scale = (float)(RI.aliasvrect.y - pfv1->v) /
(pfv0->v - pfv1->v);
scale = (float)( RI.aliasvrect.y - pfv1->v )
/ ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
}
}
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out)
void R_Alias_clip_bottom( finalvert_t *pfv0, finalvert_t *pfv1,
finalvert_t *out )
{
float scale;
if (pfv0->v >= pfv1->v)
if( pfv0->v >= pfv1->v )
{
scale = (float)(RI.aliasvrectbottom - pfv0->v) /
(pfv1->v - pfv0->v);
scale = (float)( RI.aliasvrectbottom - pfv0->v )
/ ( pfv1->v - pfv0->v );
out->u = pfv0->u + ( pfv1->u - pfv0->u ) * scale + 0.5f;
out->v = pfv0->v + ( pfv1->v - pfv0->v ) * scale + 0.5f;
out->s = pfv0->s + ( pfv1->s - pfv0->s ) * scale + 0.5f;
out->t = pfv0->t + ( pfv1->t - pfv0->t ) * scale + 0.5f;
out->l = pfv0->l + ( pfv1->l - pfv0->l ) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi) * scale + 0.5f;
out->zi = pfv0->zi + ( pfv1->zi - pfv0->zi ) * scale + 0.5f;
}
else
{
scale = (float)(RI.aliasvrectbottom - pfv1->v) /
(pfv0->v - pfv1->v);
scale = (float)( RI.aliasvrectbottom - pfv1->v )
/ ( pfv0->v - pfv1->v );
out->u = pfv1->u + ( pfv0->u - pfv1->u ) * scale + 0.5f;
out->v = pfv1->v + ( pfv0->v - pfv1->v ) * scale + 0.5f;
out->s = pfv1->s + ( pfv0->s - pfv1->s ) * scale + 0.5f;
out->t = pfv1->t + ( pfv0->t - pfv1->t ) * scale + 0.5f;
out->l = pfv1->l + ( pfv0->l - pfv1->l ) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi) * scale + 0.5f;
out->zi = pfv1->zi + ( pfv0->zi - pfv1->zi ) * scale + 0.5f;
}
}
static int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
void(*clip)(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out) )
static int R_AliasClip( finalvert_t *in, finalvert_t *out, int flag, int count,
void ( *clip )( finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out ))
{
int i,j,k;
int i, j, k;
int flags, oldflags;
j = count-1;
j = count - 1;
k = 0;
for (i=0 ; i<count ; j = i, i++)
for( i = 0; i < count; j = i, i++ )
{
oldflags = in[j].flags & flag;
flags = in[i].flags & flag;
if (flags && oldflags)
if( flags && oldflags )
continue;
if (oldflags ^ flags)
if( oldflags ^ flags )
{
clip (&in[j], &in[i], &out[k]);
clip( &in[j], &in[i], &out[k] );
out[k].flags = 0;
if (out[k].u < RI.aliasvrect.x)
if( out[k].u < RI.aliasvrect.x )
out[k].flags |= ALIAS_LEFT_CLIP;
if (out[k].v < RI.aliasvrect.y)
if( out[k].v < RI.aliasvrect.y )
out[k].flags |= ALIAS_TOP_CLIP;
if (out[k].u > RI.aliasvrectright)
if( out[k].u > RI.aliasvrectright )
out[k].flags |= ALIAS_RIGHT_CLIP;
if (out[k].v > RI.aliasvrectbottom)
if( out[k].v > RI.aliasvrectbottom )
out[k].flags |= ALIAS_BOTTOM_CLIP;
k++;
}
if (!flags)
if( !flags )
{
out[k] = in[i];
k++;
@ -218,7 +218,7 @@ static int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
R_AliasClipTriangle
================
*/
void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t *index2 )
{
int i, k, pingpong;
unsigned clipflags;
@ -231,10 +231,10 @@ void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t
// clip
clipflags = fv[0][0].flags | fv[0][1].flags | fv[0][2].flags;
if (clipflags & ALIAS_Z_CLIP)
if( clipflags & ALIAS_Z_CLIP )
{
k = R_AliasClip (fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z);
if (k == 0)
k = R_AliasClip( fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z );
if( k == 0 )
return;
pingpong = 1;
@ -246,67 +246,67 @@ void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t
k = 3;
}
if (clipflags & ALIAS_LEFT_CLIP)
if( clipflags & ALIAS_LEFT_CLIP )
{
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
ALIAS_LEFT_CLIP, k, R_Alias_clip_left);
if (k == 0)
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
ALIAS_LEFT_CLIP, k, R_Alias_clip_left );
if( k == 0 )
return;
pingpong ^= 1;
}
if (clipflags & ALIAS_RIGHT_CLIP)
if( clipflags & ALIAS_RIGHT_CLIP )
{
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
ALIAS_RIGHT_CLIP, k, R_Alias_clip_right);
if (k == 0)
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
ALIAS_RIGHT_CLIP, k, R_Alias_clip_right );
if( k == 0 )
return;
pingpong ^= 1;
}
if (clipflags & ALIAS_BOTTOM_CLIP)
if( clipflags & ALIAS_BOTTOM_CLIP )
{
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
ALIAS_BOTTOM_CLIP, k, R_Alias_clip_bottom);
if (k == 0)
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
ALIAS_BOTTOM_CLIP, k, R_Alias_clip_bottom );
if( k == 0 )
return;
pingpong ^= 1;
}
if (clipflags & ALIAS_TOP_CLIP)
if( clipflags & ALIAS_TOP_CLIP )
{
k = R_AliasClip (fv[pingpong], fv[pingpong ^ 1],
ALIAS_TOP_CLIP, k, R_Alias_clip_top);
if (k == 0)
k = R_AliasClip( fv[pingpong], fv[pingpong ^ 1],
ALIAS_TOP_CLIP, k, R_Alias_clip_top );
if( k == 0 )
return;
pingpong ^= 1;
}
for (i=0 ; i<k ; i++)
for( i = 0; i < k; i++ )
{
if (fv[pingpong][i].u < RI.aliasvrect.x)
if( fv[pingpong][i].u < RI.aliasvrect.x )
fv[pingpong][i].u = RI.aliasvrect.x;
else if (fv[pingpong][i].u > RI.aliasvrectright)
else if( fv[pingpong][i].u > RI.aliasvrectright )
fv[pingpong][i].u = RI.aliasvrectright;
if (fv[pingpong][i].v < RI.aliasvrect.y)
if( fv[pingpong][i].v < RI.aliasvrect.y )
fv[pingpong][i].v = RI.aliasvrect.y;
else if (fv[pingpong][i].v > RI.aliasvrectbottom)
else if( fv[pingpong][i].v > RI.aliasvrectbottom )
fv[pingpong][i].v = RI.aliasvrectbottom;
fv[pingpong][i].flags = 0;
}
// draw triangles
for (i=1 ; i<k-1 ; i++)
for( i = 1; i < k - 1; i++ )
{
aliastriangleparms.a = &fv[pingpong][0];
aliastriangleparms.b = &fv[pingpong][i];
aliastriangleparms.c = &fv[pingpong][i+1];
aliastriangleparms.c = &fv[pingpong][i + 1];
R_DrawTriangle();
}
}

View file

@ -39,7 +39,7 @@ FRACTAL NOISE
==============================================================
*/
static float rgNoise[NOISE_DIVISIONS+1]; // global noise array
static float rgNoise[NOISE_DIVISIONS + 1]; // global noise array
// freq2 += step * 0.1;
// Fractal noise generator, power of 2 wavelength
@ -48,7 +48,8 @@ static void FracNoise( float *noise, int divs )
int div2;
div2 = divs >> 1;
if( divs < 2 ) return;
if( divs < 2 )
return;
// noise is normalized to +/- scale
noise[div2] = ( noise[0] + noise[divs] ) * 0.5f + divs * gEngfuncs.COM_RandomFloat( -0.125f, 0.125f );
@ -200,7 +201,8 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
vec3_t perp1, vLastNormal = { 0.0f };
beamseg_t curSeg;
if( segments < 2 ) return;
if( segments < 2 )
return;
length = VectorLength( delta );
flMaxWidth = width * 0.5f;
@ -210,13 +212,14 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
{
// here, we have too many segments; we could get overlap... so lets have less segments
segments = (int)( length / ( flMaxWidth * 1.414f )) + 1.0f;
if( segments < 2 ) segments = 2;
if( segments < 2 )
segments = 2;
}
if( segments > NOISE_DIVISIONS )
segments = NOISE_DIVISIONS;
div = 1.0f / (segments - 1);
div = 1.0f / ( segments - 1 );
length *= 0.01f;
vStep = length * div; // Texture length texels per space pixel
@ -267,17 +270,17 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
// distort using noise
if( scale != 0 )
{
factor = rgNoise[noiseIndex>>16] * scale;
factor = rgNoise[noiseIndex >> 16] * scale;
if( FBitSet( flags, FBEAM_SINENOISE ))
{
float s, c;
SinCos( fraction * M_PI_F * length + freq, &s, &c );
VectorMA( nextSeg.pos, (factor * s), RI.vup, nextSeg.pos );
VectorMA( nextSeg.pos, ( factor * s ), RI.vup, nextSeg.pos );
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
VectorMA( nextSeg.pos, (factor * c), RI.vright, nextSeg.pos );
VectorMA( nextSeg.pos, ( factor * c ), RI.vright, nextSeg.pos );
}
else
{
@ -313,16 +316,16 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
// draw regular segment
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vAveNormal, vPoint1 );
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vAveNormal, vPoint2 );
VectorMA( curSeg.pos, ( -curSeg.width * 0.5f ), vAveNormal, vPoint2 );
TriTexCoord2f( 0.0f, curSeg.texcoord );
TriBrightness( brightness );
//pglNormal3fv( vAveNormal );
// pglNormal3fv( vAveNormal );
TriVertex3fv( vPoint1 );
TriTexCoord2f( 1.0f, curSeg.texcoord );
TriBrightness( brightness );
//pflNormal3fv( vAveNormal );
// pflNormal3fv( vAveNormal );
TriVertex3fv( vPoint2 );
}
@ -331,8 +334,10 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
if( FBitSet( flags, FBEAM_SHADEIN ) && FBitSet( flags, FBEAM_SHADEOUT ))
{
if( fraction < 0.5f ) brightness = fraction;
else brightness = ( 1.0f - fraction );
if( fraction < 0.5f )
brightness = fraction;
else
brightness = ( 1.0f - fraction );
}
else if( FBitSet( flags, FBEAM_SHADEIN ))
{
@ -347,17 +352,17 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
{
// draw the last segment
VectorMA( curSeg.pos, ( curSeg.width * 0.5f ), vLastNormal, vPoint1 );
VectorMA( curSeg.pos, (-curSeg.width * 0.5f ), vLastNormal, vPoint2 );
VectorMA( curSeg.pos, ( -curSeg.width * 0.5f ), vLastNormal, vPoint2 );
// specify the points.
TriTexCoord2f( 0.0f, curSeg.texcoord );
TriBrightness( brightness );
//pglNormal3fv( vLastNormal );
// pglNormal3fv( vLastNormal );
TriVertex3fv( vPoint1 );
TriTexCoord2f( 1.0f, curSeg.texcoord );
TriBrightness( brightness );
//pglNormal3fv( vLastNormal );
// pglNormal3fv( vLastNormal );
TriVertex3fv( vPoint2 );
}
@ -386,9 +391,10 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
if( length < 0.5f )
length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
div = 1.0f / ( segments - 1 );
vStep = length * div; // Texture length texels per space pixel
@ -416,11 +422,11 @@ static void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale,
{
if(( noiseIndex >> 16 ) < NOISE_DIVISIONS )
{
factor = rgNoise[noiseIndex>>16] * scale;
factor = rgNoise[noiseIndex >> 16] * scale;
VectorMA( point, factor, RI.vup, point );
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
factor = rgNoise[noiseIndex>>16] * scale * cos( fraction * M_PI_F * 3 + freq );
factor = rgNoise[noiseIndex >> 16] * scale * cos( fraction *M_PI_F * 3 + freq );
VectorMA( point, factor, RI.vright, point );
}
}
@ -476,9 +482,10 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
if( length < 0.5f )
length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
div = 1.0f / ( segments - 1 );
vStep = length * div; // Texture length texels per space pixel
// scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
@ -534,16 +541,17 @@ static void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scal
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
if( length < 0.5f )
length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
div = 1.0f / ( segments - 1 );
vStep = length * div; // texture length texels per space pixel
// Scroll speed 3.5 -- initial texture position, scrolls 3.5/sec (1.0 is entire texture)
vLast = fmod( freq * speed, 1 );
scale = scale * length;
for ( i = 0; i < segments; i++ )
for( i = 0; i < segments; i++ )
{
float s, c;
@ -620,7 +628,8 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
}
// nothing to draw
if( !particles ) return;
if( !particles )
return;
if( !pnew && div != 0 )
{
@ -694,7 +703,7 @@ static void R_DrawBeamFollow( BEAM *pbeam, float frametime )
if( particles->next != NULL )
{
fraction = (particles->die - gp_cl->time) * div;
fraction = ( particles->die - gp_cl->time ) * div;
}
else
{
@ -755,7 +764,8 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
segments = NOISE_DIVISIONS * 8;
length = VectorLength( delta ) * 0.01f * M_PI_F;
if( length < 0.5f ) length = 0.5f; // Don't lose all of the noise/texture on short beams
if( length < 0.5f )
length = 0.5f; // Don't lose all of the noise/texture on short beams
div = 1.0f / ( segments - 1 );
@ -786,7 +796,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
return;
// is that box in PVS && frustum?
if( !gEngfuncs.Mod_BoxVisible( screen, tmp, Mod_GetCurrentVis( )) ) //|| R_CullBox( screen, tmp ))
if( !gEngfuncs.Mod_BoxVisible( screen, tmp, Mod_GetCurrentVis( ))) // || R_CullBox( screen, tmp ))
{
return;
}
@ -805,11 +815,11 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
// distort using noise
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
VectorMA( point, factor, RI.vup, point );
// Rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
factor = rgNoise[( noiseIndex >> 16 ) & ( NOISE_DIVISIONS - 1 )] * scale;
factor *= cos( fraction * M_PI_F * 24 + freq );
VectorMA( point, factor, RI.vright, point );
@ -868,7 +878,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
if( beamEnt < 0 )
attach = BEAMENT_ATTACHMENT( -beamEnt );
else attach = BEAMENT_ATTACHMENT( beamEnt );
else
attach = BEAMENT_ATTACHMENT( beamEnt );
if( !ent )
{
@ -882,7 +893,8 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
VectorCopy( ent->attachment[attach - 1], pt );
else if( ent->index == ( gp_cl->playernum + 1 ))
VectorCopy( gp_cl->simorg, pt );
else VectorCopy( ent->origin, pt );
else
VectorCopy( ent->origin, pt );
return true;
}
@ -976,11 +988,12 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
{
if( FBitSet( pbeam->flags, FBEAM_SINENOISE ))
SineNoise( rgNoise, NOISE_DIVISIONS );
else FracNoise( rgNoise, NOISE_DIVISIONS );
else
FracNoise( rgNoise, NOISE_DIVISIONS );
}
// update end points
if( FBitSet( pbeam->flags, FBEAM_STARTENTITY|FBEAM_ENDENTITY ))
if( FBitSet( pbeam->flags, FBEAM_STARTENTITY | FBEAM_ENDENTITY ))
{
// makes sure attachment[0] + attachment[1] are valid
if( !R_BeamRecomputeEndpoints( pbeam ))
@ -998,7 +1011,8 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( pbeam->amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
else
pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
}
if( pbeam->type == TE_BEAMPOINTS && R_BeamCull( pbeam->source, pbeam->target, 0 ))
@ -1013,11 +1027,12 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
return;
}
if( pbeam->flags & ( FBEAM_FADEIN|FBEAM_FADEOUT ))
if( pbeam->flags & ( FBEAM_FADEIN | FBEAM_FADEOUT ))
{
// update life cycle
pbeam->t = pbeam->freq + ( pbeam->die - gp_cl->time );
if( pbeam->t != 0.0f ) pbeam->t = 1.0f - pbeam->freq / pbeam->t;
if( pbeam->t != 0.0f )
pbeam->t = 1.0f - pbeam->freq / pbeam->t;
}
if( pbeam->type == TE_BEAMHOSE )
@ -1050,8 +1065,10 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
if( flDistance > 30 )
{
flDistance = 1.0f - (( flDistance - 30.0f ) / 64.0f );
if( flDistance <= 0 ) flFade = 0;
else flFade *= pow( flDistance, 3 );
if( flDistance <= 0 )
flFade = 0;
else
flFade *= pow( flDistance, 3 );
}
if( flFade < ( 1.0f / 255.0f ))
@ -1064,7 +1081,7 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
TriRenderMode( FBitSet( pbeam->flags, FBEAM_SOLID ) ? kRenderNormal : kRenderTransAdd );
if( !TriSpriteTexture( model, (int)(pbeam->frame + pbeam->frameRate * gp_cl->time) % pbeam->frameCount ))
if( !TriSpriteTexture( model, (int)( pbeam->frame + pbeam->frameRate * gp_cl->time ) % pbeam->frameCount ))
{
ClearBits( pbeam->flags, FBEAM_ISACTIVE );
return;
@ -1084,24 +1101,25 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->t * pbeam->brightness );
else if( FBitSet( pbeam->flags, FBEAM_FADEOUT ))
TriColor4f( pbeam->r, pbeam->g, pbeam->b, ( 1.0f - pbeam->t ) * pbeam->brightness );
else TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
else
TriColor4f( pbeam->r, pbeam->g, pbeam->b, pbeam->brightness );
switch( pbeam->type )
{
case TE_BEAMTORUS:
//GL_Cull( GL_NONE );
// GL_Cull( GL_NONE );
TriBegin( TRI_TRIANGLE_STRIP );
R_DrawTorus( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
TriEnd();
break;
case TE_BEAMDISK:
//GL_Cull( GL_NONE );
// GL_Cull( GL_NONE );
TriBegin( TRI_TRIANGLE_STRIP );
R_DrawDisk( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
TriEnd();
break;
case TE_BEAMCYLINDER:
//GL_Cull( GL_NONE );
// GL_Cull( GL_NONE );
TriBegin( TRI_TRIANGLE_STRIP );
R_DrawCylinder( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
TriEnd();
@ -1118,14 +1136,14 @@ static void R_BeamDraw( BEAM *pbeam, float frametime )
TriEnd();
break;
case TE_BEAMRING:
//GL_Cull( GL_NONE );
// GL_Cull( GL_NONE );
TriBegin( TRI_TRIANGLE_STRIP );
R_DrawRing( pbeam->source, pbeam->delta, pbeam->width, pbeam->amplitude, pbeam->freq, pbeam->speed, pbeam->segments );
TriEnd();
break;
}
//GL_Cull( GL_FRONT );
// GL_Cull( GL_FRONT );
r_stats.c_view_beams_count++;
}
@ -1157,7 +1175,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
{
model_t *sprite = CL_ModelHandle( modelIndex );
if( !sprite ) return;
if( !sprite )
return;
pbeam->type = BEAM_POINTS;
pbeam->modelIndex = modelIndex;
@ -1178,7 +1197,8 @@ static void R_BeamSetup( BEAM *pbeam, vec3_t start, vec3_t end, int modelIndex,
if( amplitude >= 0.50f )
pbeam->segments = VectorLength( pbeam->delta ) * 0.25f + 3.0f; // one per 4 pixels
else pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
else
pbeam->segments = VectorLength( pbeam->delta ) * 0.075f + 3.0f; // one per 16 pixels
pbeam->pFollowModel = NULL;
pbeam->flags = 0;
@ -1269,8 +1289,8 @@ void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
BEAM *pBeam;
int i, flags;
//pglShadeModel( GL_SMOOTH );
//pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );
// pglShadeModel( GL_SMOOTH );
// pglDepthMask( fTrans ? GL_FALSE : GL_TRUE );
// server beams don't allocate beam chains
// all params are stored in cl_entity_t
@ -1303,6 +1323,6 @@ void GAME_EXPORT CL_DrawBeams( int fTrans, BEAM *active_beams )
R_BeamDraw( pBeam, gp_cl->time - gp_cl->oldtime );
}
//pglShadeModel( GL_FLAT );
//pglDepthMask( GL_TRUE );
// pglShadeModel( GL_FLAT );
// pglDepthMask( GL_TRUE );
}

View file

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// current entity info
//
vec3_t r_entorigin; // the currently rendering entity in world
// coordinates
// coordinates
float entity_rotation[3][3];
@ -51,44 +51,44 @@ static qboolean makeclippededge;
R_ConcatRotations
================
*/
static void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
static void R_ConcatRotations( float in1[3][3], float in2[3][3], float out[3][3] )
{
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
in1[0][2] * in2[2][2];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
in1[1][2] * in2[2][2];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
in1[2][2] * in2[2][2];
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0]
+ in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1]
+ in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2]
+ in1[0][2] * in2[2][2];
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0]
+ in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1]
+ in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2]
+ in1[1][2] * in2[2][2];
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0]
+ in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1]
+ in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2]
+ in1[2][2] * in2[2][2];
}
//===========================================================================
// ===========================================================================
/*
================
R_EntityRotate
================
*/
static void R_EntityRotate (vec3_t vec)
static void R_EntityRotate( vec3_t vec )
{
vec3_t tvec;
VectorCopy (vec, tvec);
vec[0] = DotProduct (entity_rotation[0], tvec);
vec[1] = DotProduct (entity_rotation[1], tvec);
vec[2] = DotProduct (entity_rotation[2], tvec);
VectorCopy( vec, tvec );
vec[0] = DotProduct( entity_rotation[0], tvec );
vec[1] = DotProduct( entity_rotation[1], tvec );
vec[2] = DotProduct( entity_rotation[2], tvec );
}
@ -97,7 +97,7 @@ static void R_EntityRotate (vec3_t vec)
R_RotateBmodel
================
*/
void R_RotateBmodel (void)
void R_RotateBmodel( void )
{
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
@ -109,8 +109,8 @@ void R_RotateBmodel (void)
// yaw
angle = RI.currententity->angles[YAW];
angle = angle * M_PI_F * 2 / 360.0f;
s = sin(angle);
c = cos(angle);
s = sin( angle );
c = cos( angle );
temp1[0][0] = c;
temp1[0][1] = s;
@ -126,8 +126,8 @@ void R_RotateBmodel (void)
// pitch
angle = RI.currententity->angles[PITCH];
angle = angle * M_PI_F * 2 / 360.0f;
s = sin(angle);
c = cos(angle);
s = sin( angle );
c = cos( angle );
temp2[0][0] = c;
temp2[0][1] = 0;
@ -139,13 +139,13 @@ void R_RotateBmodel (void)
temp2[2][1] = 0;
temp2[2][2] = c;
R_ConcatRotations (temp2, temp1, temp3);
R_ConcatRotations( temp2, temp1, temp3 );
// roll
angle = RI.currententity->angles[ROLL];
angle = angle * M_PI_F*2 / 360.0f;
s = sin(angle);
c = cos(angle);
angle = angle * M_PI_F * 2 / 360.0f;
s = sin( angle );
c = cos( angle );
temp1[0][0] = 1;
temp1[0][1] = 0;
@ -157,17 +157,17 @@ void R_RotateBmodel (void)
temp1[2][1] = -s;
temp1[2][2] = c;
R_ConcatRotations (temp1, temp3, entity_rotation);
R_ConcatRotations( temp1, temp3, entity_rotation );
//
// rotate modelorg and the transformation matrix
//
R_EntityRotate (tr.modelorg);
R_EntityRotate (RI.vforward);
R_EntityRotate (RI.vright);
R_EntityRotate (RI.vup);
R_EntityRotate( tr.modelorg );
R_EntityRotate( RI.vforward );
R_EntityRotate( RI.vright );
R_EntityRotate( RI.vup );
R_TransformFrustum ();
R_TransformFrustum();
}
/*
@ -175,7 +175,7 @@ void R_RotateBmodel (void)
R_RecursiveClipBPoly
================
*/
static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
static void R_RecursiveClipBPoly( bedge_t *pedges, mnode_t *pnode, msurface_t *psurf )
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
@ -191,62 +191,62 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// transform the BSP plane into model space
// FIXME: cache these?
splitplane = pnode->plane;
tplane.dist = splitplane->dist -
DotProduct(r_entorigin, splitplane->normal);
tplane.normal[0] = DotProduct (entity_rotation[0], splitplane->normal);
tplane.normal[1] = DotProduct (entity_rotation[1], splitplane->normal);
tplane.normal[2] = DotProduct (entity_rotation[2], splitplane->normal);
tplane.dist = splitplane->dist
- DotProduct( r_entorigin, splitplane->normal );
tplane.normal[0] = DotProduct( entity_rotation[0], splitplane->normal );
tplane.normal[1] = DotProduct( entity_rotation[1], splitplane->normal );
tplane.normal[2] = DotProduct( entity_rotation[2], splitplane->normal );
// clip edges to BSP plane
for ( ; pedges ; pedges = pnextedge)
for( ; pedges; pedges = pnextedge )
{
pnextedge = pedges->pnext;
// set the status for the last point as the previous point
// FIXME: cache this stuff somehow?
plastvert = pedges->v[0];
lastdist = DotProduct (plastvert->position, tplane.normal) -
tplane.dist;
lastdist = DotProduct( plastvert->position, tplane.normal )
- tplane.dist;
if (lastdist > 0)
if( lastdist > 0 )
lastside = 0;
else
lastside = 1;
pvert = pedges->v[1];
dist = DotProduct (pvert->position, tplane.normal) - tplane.dist;
dist = DotProduct( pvert->position, tplane.normal ) - tplane.dist;
if (dist > 0)
if( dist > 0 )
side = 0;
else
side = 1;
if (side != lastside)
if( side != lastside )
{
// clipped
if (numbverts >= MAX_BMODEL_VERTS)
if( numbverts >= MAX_BMODEL_VERTS )
return;
// generate the clipped vertex
frac = lastdist / (lastdist - dist);
frac = lastdist / ( lastdist - dist );
ptvert = &pbverts[numbverts++];
ptvert->position[0] = plastvert->position[0] +
frac * (pvert->position[0] -
plastvert->position[0]);
ptvert->position[1] = plastvert->position[1] +
frac * (pvert->position[1] -
plastvert->position[1]);
ptvert->position[2] = plastvert->position[2] +
frac * (pvert->position[2] -
plastvert->position[2]);
ptvert->position[0] = plastvert->position[0]
+ frac * ( pvert->position[0]
- plastvert->position[0] );
ptvert->position[1] = plastvert->position[1]
+ frac * ( pvert->position[1]
- plastvert->position[1] );
ptvert->position[2] = plastvert->position[2]
+ frac * ( pvert->position[2]
- plastvert->position[2] );
// split into two edges, one on each side, and remember entering
// and exiting points
// FIXME: share the clip edge by having a winding direction flag?
if (numbedges >= (MAX_BMODEL_EDGES - 1))
if( numbedges >= ( MAX_BMODEL_EDGES - 1 ))
{
//gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
// gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
return;
}
@ -264,7 +264,7 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
numbedges += 2;
if (side == 0)
if( side == 0 )
{
// entering for front, exiting for back
pfrontenter = ptvert;
@ -286,11 +286,11 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
// if anything was clipped, reconstitute and add the edges along the clip
// plane to both sides (but in opposite directions)
if (makeclippededge)
if( makeclippededge )
{
if (numbedges >= (MAX_BMODEL_EDGES - 2))
if( numbedges >= ( MAX_BMODEL_EDGES - 2 ))
{
//gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
// gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
return;
}
@ -310,30 +310,30 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
}
// draw or recurse further
for (i=0 ; i<2 ; i++)
for( i = 0; i < 2; i++ )
{
if (psideedges[i])
if( psideedges[i] )
{
// draw if we've reached a non-solid leaf, done if all that's left is a
// solid leaf, and continue down the tree if it's not a leaf
pn = pnode->children[i];
// we're done with this branch if the node or leaf isn't in the PVS
if (pn->visframe == tr.visframecount)
if( pn->visframe == tr.visframecount )
{
if (pn->contents < 0)
if( pn->contents < 0 )
{
if (pn->contents != CONTENTS_SOLID)
if( pn->contents != CONTENTS_SOLID )
{
//r_currentbkey = ((mleaf_t *)pn)->cluster;
r_currentbkey = LEAF_KEY (((mleaf_t *)pn));
R_RenderBmodelFace (psideedges[i], psurf);
// r_currentbkey = ((mleaf_t *)pn)->cluster;
r_currentbkey = LEAF_KEY(((mleaf_t *)pn ));
R_RenderBmodelFace( psideedges[i], psurf );
}
}
else
{
R_RecursiveClipBPoly (psideedges[i], pnode->children[i],
psurf);
R_RecursiveClipBPoly( psideedges[i], pnode->children[i],
psurf );
}
}
}
@ -347,7 +347,7 @@ R_DrawSolidClippedSubmodelPolygons
Bmodel crosses multiple leafs
================
*/
void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode )
{
int i, j, lindex;
vec_t dot;
@ -364,7 +364,7 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
numsurfaces = pmodel->nummodelsurfaces;
pedges = pmodel->edges;
for (i=0 ; i<numsurfaces ; i++, psurf++)
for( i = 0; i < numsurfaces; i++, psurf++ )
{
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{
@ -376,11 +376,11 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
// find which side of the node we are on
pplane = psurf->plane;
dot = DotProduct (tr.modelorg, pplane->normal) - pplane->dist;
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon
if (( !(psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
((psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
if(( !( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|| (( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
continue;
// FIXME: use bounding-box-based frustum clipping info?
@ -395,11 +395,11 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
pbedge = &bedges[numbedges];
numbedges += psurf->numedges;
for (j=0 ; j<psurf->numedges ; j++)
for( j = 0; j < psurf->numedges; j++ )
{
lindex = pmodel->surfedges[psurf->firstedge+j];
lindex = pmodel->surfedges[psurf->firstedge + j];
if (lindex > 0)
if( lindex > 0 )
{
pedge = &pedges[lindex];
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[0]];
@ -413,14 +413,14 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode)
pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[0]];
}
pbedge[j].pnext = &pbedge[j+1];
pbedge[j].pnext = &pbedge[j + 1];
}
pbedge[j-1].pnext = NULL; // mark end of edges
pbedge[j - 1].pnext = NULL; // mark end of edges
//if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
R_RecursiveClipBPoly (pbedge, topnode, psurf);
//else
// if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ) )
R_RecursiveClipBPoly( pbedge, topnode, psurf );
// else
// R_RenderBmodelFace( pbedge, psurf );
}
}
@ -433,7 +433,7 @@ R_DrawSubmodelPolygons
All in one leaf
================
*/
void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
void R_DrawSubmodelPolygons( model_t *pmodel, int clipflags, mnode_t *topnode )
{
int i;
vec_t dot;
@ -446,7 +446,7 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;
for (i=0 ; i<numsurfaces ; i++, psurf++)
for( i = 0; i < numsurfaces; i++, psurf++ )
{
if( FBitSet( psurf->flags, SURF_DRAWTURB ) && !ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{
@ -458,16 +458,16 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
// find which side of the node we are on
pplane = psurf->plane;
dot = DotProduct (tr.modelorg, pplane->normal) - pplane->dist;
dot = DotProduct( tr.modelorg, pplane->normal ) - pplane->dist;
// draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
if((( psurf->flags & SURF_PLANEBACK ) && ( dot < -BACKFACE_EPSILON ))
|| ( !( psurf->flags & SURF_PLANEBACK ) && ( dot > BACKFACE_EPSILON )))
{
r_currentkey = LEAF_KEY(((mleaf_t *)topnode));
r_currentkey = LEAF_KEY(((mleaf_t *)topnode ));
// FIXME: use bounding-box-based frustum clipping info?
R_RenderFace (psurf, clipflags);
R_RenderFace( psurf, clipflags );
}
}
}
@ -482,7 +482,7 @@ int r_leafkeys[MAX_MAP_LEAFS];
R_RecursiveWorldNode
================
*/
static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
static void R_RecursiveWorldNode( mnode_t *node, int clipflags )
{
int i, c, side, *pindex;
vec3_t acceptpt, rejectpt;
@ -491,20 +491,20 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
mleaf_t *pleaf;
double d, dot;
if (node->contents == CONTENTS_SOLID)
if( node->contents == CONTENTS_SOLID )
return; // solid
if (node->visframe != tr.visframecount)
if( node->visframe != tr.visframecount )
return;
// cull the clipping planes if not trivial accept
// FIXME: the compiler is doing a lousy job of optimizing here; it could be
// twice as fast in ASM
if (clipflags)
if( clipflags )
{
for (i=0 ; i<4 ; i++)
for( i = 0; i < 4; i++ )
{
if (! (clipflags & (1<<i)) )
if( !( clipflags & ( 1 << i )))
continue; // don't need to clip against it
// generate accept and reject points
@ -517,50 +517,51 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
rejectpt[1] = (float)node->minmaxs[pindex[1]];
rejectpt[2] = (float)node->minmaxs[pindex[2]];
d = DotProduct (rejectpt, qfrustum.view_clipplanes[i].normal);
d = DotProduct( rejectpt, qfrustum.view_clipplanes[i].normal );
d -= qfrustum.view_clipplanes[i].dist;
if (d <= 0)
if( d <= 0 )
return;
acceptpt[0] = (float)node->minmaxs[pindex[3+0]];
acceptpt[1] = (float)node->minmaxs[pindex[3+1]];
acceptpt[2] = (float)node->minmaxs[pindex[3+2]];
acceptpt[0] = (float)node->minmaxs[pindex[3 + 0]];
acceptpt[1] = (float)node->minmaxs[pindex[3 + 1]];
acceptpt[2] = (float)node->minmaxs[pindex[3 + 2]];
d = DotProduct (acceptpt, qfrustum.view_clipplanes[i].normal);
d = DotProduct( acceptpt, qfrustum.view_clipplanes[i].normal );
d -= qfrustum.view_clipplanes[i].dist;
if (d >= 0)
clipflags &= ~(1<<i); // node is entirely on screen
if( d >= 0 )
clipflags &= ~( 1 << i ); // node is entirely on screen
}
}
// if a leaf node, draw stuff
if (node->contents < 0)
if( node->contents < 0 )
{
pleaf = (mleaf_t *)node;
mark = pleaf->firstmarksurface;
c = pleaf->nummarksurfaces;
if (c)
if( c )
{
do
{
(*mark)->visframe = tr.framecount;
( *mark )->visframe = tr.framecount;
mark++;
} while (--c);
}
while( --c );
}
// deal with model fragments in this leaf
if (pleaf->efrags)
if( pleaf->efrags )
{
gEngfuncs.R_StoreEfrags(&pleaf->efrags,tr.realframecount);
gEngfuncs.R_StoreEfrags( &pleaf->efrags, tr.realframecount );
}
// pleaf->cluster
LEAF_KEY(pleaf) = r_currentkey;
LEAF_KEY( pleaf ) = r_currentkey;
r_currentkey++; // all bmodels in a leaf share the same key
}
else
@ -570,7 +571,7 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
// find which side of the node we are on
plane = node->plane;
switch (plane->type)
switch( plane->type )
{
case PLANE_X:
dot = tr.modelorg[0] - plane->dist;
@ -582,50 +583,52 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
dot = tr.modelorg[2] - plane->dist;
break;
default:
dot = DotProduct (tr.modelorg, plane->normal) - plane->dist;
dot = DotProduct( tr.modelorg, plane->normal ) - plane->dist;
break;
}
if (dot >= 0)
if( dot >= 0 )
side = 0;
else
side = 1;
// recurse down the children, front side first
R_RecursiveWorldNode (node->children[side], clipflags);
R_RecursiveWorldNode( node->children[side], clipflags );
// draw stuff
c = node->numsurfaces;
if (c)
if( c )
{
surf = WORLDMODEL->surfaces + node->firstsurface;
if (dot < -BACKFACE_EPSILON)
if( dot < -BACKFACE_EPSILON )
{
do
{
if ((surf->flags & SURF_PLANEBACK) &&
(surf->visframe == tr.framecount))
if(( surf->flags & SURF_PLANEBACK )
&& ( surf->visframe == tr.framecount ))
{
R_RenderFace (surf, clipflags);
R_RenderFace( surf, clipflags );
}
surf++;
} while (--c);
}
else if (dot > BACKFACE_EPSILON)
while( --c );
}
else if( dot > BACKFACE_EPSILON )
{
do
{
if (!(surf->flags & SURF_PLANEBACK) &&
(surf->visframe == tr.framecount))
if( !( surf->flags & SURF_PLANEBACK )
&& ( surf->visframe == tr.framecount ))
{
R_RenderFace (surf, clipflags);
R_RenderFace( surf, clipflags );
}
surf++;
} while (--c);
}
while( --c );
}
// all surfaces on the same node share the same sequence number
@ -633,7 +636,7 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
}
// recurse down the back side
R_RecursiveWorldNode (node->children[!side], clipflags);
R_RecursiveWorldNode( node->children[!side], clipflags );
}
}
@ -642,18 +645,18 @@ static void R_RecursiveWorldNode (mnode_t *node, int clipflags)
R_RenderWorld
================
*/
void R_RenderWorld (void)
void R_RenderWorld( void )
{
if ( !RI.drawWorld )
if( !RI.drawWorld )
return;
// auto cycle the world frame for texture animation
RI.currententity = CL_GetEntityByIndex(0);
//RI.currententity->frame = (int)(gp_cl->time*2);
RI.currententity = CL_GetEntityByIndex( 0 );
// RI.currententity->frame = (int)(gp_cl->time*2);
VectorCopy (RI.vieworg, tr.modelorg);
VectorCopy( RI.vieworg, tr.modelorg );
RI.currentmodel = WORLDMODEL;
r_pcurrentvertbase = RI.currentmodel->vertexes;
R_RecursiveWorldNode (RI.currentmodel->nodes, 15);
R_RecursiveWorldNode( RI.currentmodel->nodes, 15 );
}

View file

@ -58,8 +58,8 @@ CL_FillRGBA
static void GAME_EXPORT CL_FillRGBA( int rendermode, float _x, float _y, float _w, float _h, byte r, byte g, byte b, byte a )
{
vid.rendermode = rendermode;
_TriColor4ub(r,g,b,a);
Draw_Fill(_x,_y,_w,_h);
_TriColor4ub( r, g, b, a );
Draw_Fill( _x, _y, _w, _h );
}
void Mod_UnloadTextures( model_t *mod );
@ -73,13 +73,13 @@ static qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create
switch( mod->type )
{
case mod_studio:
//Mod_LoadStudioModel( mod, buf, loaded );
// Mod_LoadStudioModel( mod, buf, loaded );
break;
case mod_sprite:
Mod_LoadSpriteModel( mod, buf, &loaded, mod->numtexinfo );
break;
case mod_alias:
//Mod_LoadAliasModel( mod, buf, &loaded );
// Mod_LoadAliasModel( mod, buf, &loaded );
break;
case mod_brush:
// Mod_LoadBrushModel( mod, buf, loaded );
@ -118,10 +118,10 @@ static int GL_RefGetParm( int parm, int arg )
return glt->srcHeight;
case PARM_TEX_GLFORMAT:
glt = R_GetTexture( arg );
return 0; //glt->format;
return 0; // glt->format;
case PARM_TEX_ENCODE:
glt = R_GetTexture( arg );
return 0; //glt->encode;
return 0; // glt->encode;
case PARM_TEX_MIPCOUNT:
glt = R_GetTexture( arg );
return glt->numMips;
@ -132,36 +132,36 @@ static int GL_RefGetParm( int parm, int arg )
Assert( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
case PARM_TEX_SKYTEXNUM:
return 0; //tr.skytexturenum;
return 0; // tr.skytexturenum;
case PARM_TEX_LIGHTMAP:
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
return tr.lightmapTextures[arg];
case PARM_TEX_TARGET:
glt = R_GetTexture( arg );
return 0; //glt->target;
return 0; // glt->target;
case PARM_TEX_TEXNUM:
glt = R_GetTexture( arg );
return 0; //glt->texnum;
return 0; // glt->texnum;
case PARM_TEX_FLAGS:
glt = R_GetTexture( arg );
return glt->flags;
case PARM_TEX_MEMORY:
return R_TexMemory();
case PARM_ACTIVE_TMU:
return 0; //glState.activeTMU;
return 0; // glState.activeTMU;
case PARM_LIGHTSTYLEVALUE:
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
return tr.lightstylevalue[arg];
case PARM_MAX_IMAGE_UNITS:
return 0; //GL_MaxTextureUnits();
return 0; // GL_MaxTextureUnits();
case PARM_REBUILD_GAMMA:
return 0;
case PARM_GL_CONTEXT_TYPE:
return 0; //glConfig.context;
return 0; // glConfig.context;
case PARM_GLES_WRAPPER:
return 0; //glConfig.wrapper;
return 0; // glConfig.wrapper;
case PARM_STENCIL_ACTIVE:
return 0; //glState.stencilEnabled;
return 0; // glState.stencilEnabled;
case PARM_SKY_SPHERE:
return 0; // ref_soft doesn't support sky sphere
case PARM_TEX_FILTERING:
@ -176,18 +176,24 @@ static void GAME_EXPORT R_GetDetailScaleForTexture( int texture, float *xScale,
{
image_t *glt = R_GetTexture( texture );
if( xScale ) *xScale = glt->xscale;
if( yScale ) *yScale = glt->yscale;
if( xScale )
*xScale = glt->xscale;
if( yScale )
*yScale = glt->yscale;
}
static void GAME_EXPORT R_GetExtraParmsForTexture( int texture, byte *red, byte *green, byte *blue, byte *density )
{
image_t *glt = R_GetTexture( texture );
if( red ) *red = glt->fogParams[0];
if( green ) *green = glt->fogParams[1];
if( blue ) *blue = glt->fogParams[2];
if( density ) *density = glt->fogParams[3];
if( red )
*red = glt->fogParams[0];
if( green )
*green = glt->fogParams[1];
if( blue )
*blue = glt->fogParams[2];
if( density )
*density = glt->fogParams[3];
}
@ -231,7 +237,7 @@ static void Mod_BrushUnloadTextures( model_t *mod )
int i;
gEngfuncs.Con_Printf("Unloading world\n");
gEngfuncs.Con_Printf( "Unloading world\n" );
tr.map_unload = true;
for( i = 0; i < mod->numtextures; i++ )
@ -254,10 +260,10 @@ void Mod_UnloadTextures( model_t *mod )
switch( mod->type )
{
case mod_studio:
//Mod_StudioUnloadTextures( mod->cache.data );
// Mod_StudioUnloadTextures( mod->cache.data );
break;
case mod_alias:
//Mod_AliasUnloadTextures( mod->cache.data );
// Mod_AliasUnloadTextures( mod->cache.data );
break;
case mod_brush:
Mod_BrushUnloadTextures( mod );
@ -298,7 +304,7 @@ static void GAME_EXPORT GL_BackendEndFrame( void )
}
void GAME_EXPORT GL_SetRenderMode(int mode)
void GAME_EXPORT GL_SetRenderMode( int mode )
{
vid.rendermode = mode;
/// TODO: table shading/blending???
@ -322,7 +328,7 @@ static void GAME_EXPORT R_SetupSky( int *skyboxTextures )
tr.skyboxTextures[i] = skyboxTextures[i];
}
qboolean GAME_EXPORT VID_CubemapShot(const char *base, uint size, const float *vieworg, qboolean skyshot)
qboolean GAME_EXPORT VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot )
{
// cubemaps? in my softrender???
return false;
@ -339,17 +345,17 @@ static void GAME_EXPORT GL_SubdivideSurface( model_t *mod, msurface_t *fa )
}
static void GAME_EXPORT DrawSingleDecal(decal_t *pDecal, msurface_t *fa)
static void GAME_EXPORT DrawSingleDecal( decal_t *pDecal, msurface_t *fa )
{
}
static void GAME_EXPORT GL_SelectTexture(int texture)
static void GAME_EXPORT GL_SelectTexture( int texture )
{
}
static void GAME_EXPORT GL_LoadTexMatrixExt(const float *glmatrix)
static void GAME_EXPORT GL_LoadTexMatrixExt( const float *glmatrix )
{
}
@ -359,27 +365,27 @@ static void GAME_EXPORT GL_LoadIdentityTexMatrix( void )
}
static void GAME_EXPORT GL_CleanUpTextureUnits(int last)
static void GAME_EXPORT GL_CleanUpTextureUnits( int last )
{
}
static void GAME_EXPORT GL_TexGen(unsigned int coord, unsigned int mode)
static void GAME_EXPORT GL_TexGen( unsigned int coord, unsigned int mode )
{
}
static void GAME_EXPORT GL_TextureTarget(uint target)
static void GAME_EXPORT GL_TextureTarget( uint target )
{
}
void GAME_EXPORT Mod_SetOrthoBounds(const float *mins, const float *maxs)
void GAME_EXPORT Mod_SetOrthoBounds( const float *mins, const float *maxs )
{
}
qboolean GAME_EXPORT R_SpeedsMessage(char *out, size_t size)
qboolean GAME_EXPORT R_SpeedsMessage( char *out, size_t size )
{
return false;
}
@ -410,7 +416,7 @@ static const char *R_GetConfigName( void )
return "ref_soft"; // software specific cvars will go to ref_soft.cfg
}
static void* GAME_EXPORT R_GetProcAddress( const char *name )
static void * GAME_EXPORT R_GetProcAddress( const char *name )
{
return gEngfuncs.GL_GetProcAddress( name );
}

View file

@ -74,7 +74,8 @@ static void R_DecalUnlink( decal_t *pdecal )
else
{
tmp = pdecal->psurface->pdecals;
if( !tmp ) gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
if( !tmp )
gEngfuncs.Host_Error( "%s: bad decal list\n", __func__ );
while( tmp->pnext )
{
@ -105,7 +106,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
if( r_decals->value < limit )
limit = r_decals->value;
if( !limit ) return NULL;
if( !limit )
return NULL;
if( !pdecal )
{
@ -120,7 +122,8 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
pdecal = &gDecalPool[gDecalCount]; // reuse next decal
gDecalCount++;
count++;
} while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
}
while( FBitSet( pdecal->flags, FDECAL_PERMANENT ) && count < limit );
}
// if decal is already linked to a surface, unlink it.
@ -129,20 +132,22 @@ static decal_t *R_DecalAlloc( decal_t *pdecal )
return pdecal;
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// find decal image and grab size from it
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static void R_GetDecalDimensions( int texture, int *width, int *height )
{
if( width ) *width = 1; // to avoid divide by zero
if( height ) *height = 1;
if( width )
*width = 1; // to avoid divide by zero
if( height )
*height = 1;
R_GetTextureParms( width, height, texture );
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// compute the decal basis based on surface normal
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[3] )
{
vec3_t surfaceNormal;
@ -150,7 +155,8 @@ void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[
// setup normal
if( surf->flags & SURF_PLANEBACK )
VectorNegate( surf->plane->normal, surfaceNormal );
else VectorCopy( surf->plane->normal, surfaceNormal );
else
VectorCopy( surf->plane->normal, surfaceNormal );
VectorNormalize2( surfaceNormal, textureSpaceBasis[2] );
VectorNormalize2( surf->texinfo->vecs[0], textureSpaceBasis[0] );
@ -250,36 +256,36 @@ static void R_ClipIntersect( float *one, float *two, float *out, int edge )
if( edge == LEFT_EDGE )
{
// left
t = ((one[3] - 0.0f) / (one[3] - two[3]));
t = (( one[3] - 0.0f ) / ( one[3] - two[3] ));
out[3] = out[5] = 0.0f;
}
else
{
// right
t = ((one[3] - 1.0f) / (one[3] - two[3]));
t = (( one[3] - 1.0f ) / ( one[3] - two[3] ));
out[3] = out[5] = 1.0f;
}
out[4] = one[4] + (two[4] - one[4]) * t;
out[6] = one[6] + (two[6] - one[6]) * t;
out[4] = one[4] + ( two[4] - one[4] ) * t;
out[6] = one[6] + ( two[6] - one[6] ) * t;
}
else
{
if( edge == TOP_EDGE )
{
// top
t = ((one[4] - 0.0f) / (one[4] - two[4]));
t = (( one[4] - 0.0f ) / ( one[4] - two[4] ));
out[4] = out[6] = 0.0f;
}
else
{
// bottom
t = ((one[4] - 1.0f) / (one[4] - two[4]));
t = (( one[4] - 1.0f ) / ( one[4] - two[4] ));
out[4] = out[6] = 1.0f;
}
out[3] = one[3] + (two[3] - one[3]) * t;
out[5] = one[5] + (two[4] - one[5]) * t;
out[3] = one[3] + ( two[3] - one[3] ) * t;
out[5] = one[5] + ( two[4] - one[5] ) * t;
}
VectorLerp( one, t, two, out );
@ -292,7 +298,7 @@ static int SHClip( float *vert, int vertCount, float *out, int edge )
outCount = 0;
s = &vert[(vertCount - 1) * VERTEXSIZE];
s = &vert[( vertCount - 1 ) * VERTEXSIZE];
for( j = 0; j < vertCount; j++ )
{
@ -351,9 +357,9 @@ static float *R_DoDecalSHClip( float *pInVerts, decal_t *pDecal, int nStartVerts
return pOutVerts;
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Generate clipped vertex list for decal pdecal projected onto polygon psurf
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static float *R_DecalVertsClip( decal_t *pDecal, msurface_t *surf, int texture, int *pVertCount )
{
float decalWorldScale[2];
@ -388,12 +394,12 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
s = DotProduct( v, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
s += surf->light_s * sample_size;
s += sample_size * 0.5f;
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
s /= BLOCK_SIZE * sample_size; // fa->texinfo->texture->width;
t = DotProduct( v, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
t += surf->light_t * sample_size;
t += sample_size * 0.5f;
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
t /= BLOCK_SIZE * sample_size; // fa->texinfo->texture->height;
v[5] = s;
v[6] = t;
@ -417,8 +423,8 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
// precalculate the extents of decalinfo's decal in world space.
R_GetDecalDimensions( texture, &mapSize[0], &mapSize[1] );
VectorScale( decalinfo->m_Basis[0], ((mapSize[0] / decalinfo->m_scale) * 0.5f), decalExtents[0] );
VectorScale( decalinfo->m_Basis[1], ((mapSize[1] / decalinfo->m_scale) * 0.5f), decalExtents[1] );
VectorScale( decalinfo->m_Basis[0], (( mapSize[0] / decalinfo->m_scale ) * 0.5f ), decalExtents[0] );
VectorScale( decalinfo->m_Basis[1], (( mapSize[1] / decalinfo->m_scale ) * 0.5f ), decalExtents[1] );
pDecal = surf->pdecals;
@ -463,7 +469,7 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
{
// Figure out how much of this intersects the (0,0) - (1,1) bbox.
float flArea = (vUnionMax[0] - vUnionMin[1]) * (vUnionMax[1] - vUnionMin[1]);
float flArea = ( vUnionMax[0] - vUnionMin[1] ) * ( vUnionMax[1] - vUnionMin[1] );
if( flArea > 0.6f )
{
@ -501,7 +507,8 @@ static glpoly2_t *R_DecalCreatePoly( decalinfo_t *decalinfo, decal_t *pdecal, ms
return pdecal->polys;
v = R_DecalSetupVerts( pdecal, surf, pdecal->texture, &lnumverts );
if( !lnumverts ) return NULL; // probably this never happens
if( !lnumverts )
return NULL; // probably this never happens
// allocate glpoly
// REFTODO: com_studiocache pool!
@ -554,7 +561,7 @@ static void R_AddDecalToSurface( decal_t *pdecal, msurface_t *surf, decalinfo_t
// alloc clipped poly for decal
R_DecalCreatePoly( decalinfo, pdecal, surf );
//R_AddDecalVBO( pdecal, surf );
// R_AddDecalVBO( pdecal, surf );
}
static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, float y )
@ -562,13 +569,16 @@ static void R_DecalCreate( decalinfo_t *decalinfo, msurface_t *surf, float x, fl
decal_t *pdecal, *pold;
int count, vertCount;
if( !surf ) return; // ???
if( !surf )
return; // ???
pold = R_DecalIntersect( decalinfo, surf, &count );
if( count < MAX_OVERLAP_DECALS ) pold = NULL;
if( count < MAX_OVERLAP_DECALS )
pold = NULL;
pdecal = R_DecalAlloc( pold );
if( !pdecal ) return; // r_decals == 0 ???
if( !pdecal )
return; // r_decals == 0 ???
pdecal->flags = decalinfo->m_Flags;
@ -643,18 +653,18 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
// (decalWidth * decalBasis[0], decalHeight * decalBasis[1])
// in texture coordinates:
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] )) +
fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
w = fabs( decalinfo->m_decalWidth * DotProduct( textureU, decalinfo->m_Basis[0] ))
+ fabs( decalinfo->m_decalHeight * DotProduct( textureU, decalinfo->m_Basis[1] ));
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] )) +
fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
h = fabs( decalinfo->m_decalWidth * DotProduct( textureV, decalinfo->m_Basis[0] ))
+ fabs( decalinfo->m_decalHeight * DotProduct( textureV, decalinfo->m_Basis[1] ));
// move s,t to upper left corner
s -= ( w * 0.5f );
t -= ( h * 0.5f );
// Is this rect within the surface? -- tex width & height are unsigned
if( s <= -w || t <= -h || s > (surf->extents[0] + w) || t > (surf->extents[1] + h))
if( s <= -w || t <= -h || s > ( surf->extents[0] + w ) || t > ( surf->extents[1] + h ))
{
return; // nope
}
@ -663,9 +673,9 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
R_DecalCreate( decalinfo, surf, s, t );
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// iterate over all surfaces on a node, looking for surfaces to decal
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
{
// iterate over all surfaces in the node
@ -677,22 +687,22 @@ static void R_DecalNodeSurfaces( model_t *model, mnode_t *node, decalinfo_t *dec
for( i = 0; i < node->numsurfaces; i++, surf++ )
{
// never apply decals on the water or sky surfaces
if( surf->flags & (SURF_DRAWTURB|SURF_DRAWSKY|SURF_CONVEYOR))
if( surf->flags & ( SURF_DRAWTURB | SURF_DRAWSKY | SURF_CONVEYOR ))
continue;
// we can implement alpha testing without stencil
//if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
//continue;
// if( surf->flags & SURF_TRANSPARENT && !glState.stencilEnabled )
// continue;
R_DecalSurface( surf, decalinfo );
}
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Recursive routine to find surface to apply a decal to. World coordinates of
// the decal are passed in r_recalpos like the rest of the engine. This should
// be called through R_DecalShoot()
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static void R_DecalNode( model_t *model, mnode_t *node, decalinfo_t *decalinfo )
{
mplane_t *splitplane;
@ -754,15 +764,20 @@ void GAME_EXPORT R_DecalShoot( int textureIndex, int entityIndex, int modelIndex
{
ent = CL_GetEntityByIndex( entityIndex );
if( modelIndex > 0 ) model = CL_ModelHandle( modelIndex );
else if( ent != NULL ) model = CL_ModelHandle( ent->curstate.modelindex );
else return;
if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex );
else if( ent != NULL )
model = CL_ModelHandle( ent->curstate.modelindex );
else
return;
}
else if( modelIndex > 0 )
model = CL_ModelHandle( modelIndex );
else model = WORLDMODEL;
else
model = WORLDMODEL;
if( !model ) return;
if( !model )
return;
if( model->type != mod_brush )
{
@ -884,17 +899,18 @@ static qboolean R_DecalUnProject( decal_t *pdecal, decallist_t *entry )
// Grab surface plane equation
if( pdecal->psurface->flags & SURF_PLANEBACK )
VectorNegate( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
else VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
else
VectorCopy( pdecal->psurface->plane->normal, entry->impactPlaneNormal );
return true;
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Purpose:
// Input : *pList -
// count -
// Output : static int
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static int DecalListAdd( decallist_t *pList, int count )
{
vec3_t tmp;
@ -933,11 +949,11 @@ static int DecalDepthCompare( const void *a, const void *b )
return 0;
}
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Purpose: Called by CSaveRestore::SaveClientState
// Input : *pList -
// Output : int
//-----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
int GAME_EXPORT R_CreateDecalList( decallist_t *pList )
{
int total = 0;

View file

@ -25,8 +25,10 @@ void R_GetTextureParms( int *w, int *h, int texnum )
image_t *glt;
glt = R_GetTexture( texnum );
if( w ) *w = glt->srcWidth;
if( h ) *h = glt->srcHeight;
if( w )
*w = glt->srcWidth;
if( h )
*h = glt->srcHeight;
}
/*
@ -41,12 +43,16 @@ void GAME_EXPORT R_GetSpriteParms( int *frameWidth, int *frameHeight, int *numFr
{
mspriteframe_t *pFrame;
if( !pSprite || pSprite->type != mod_sprite ) return; // bad model ?
if( !pSprite || pSprite->type != mod_sprite )
return; // bad model ?
pFrame = R_GetSpriteFrame( pSprite, currentFrame, 0.0f );
if( frameWidth ) *frameWidth = pFrame->width;
if( frameHeight ) *frameHeight = pFrame->height;
if( numFrames ) *numFrames = pSprite->numframes;
if( frameWidth )
*frameWidth = pFrame->width;
if( frameHeight )
*frameHeight = pFrame->height;
if( numFrames )
*numFrames = pSprite->numframes;
}
int GAME_EXPORT R_GetSpriteTexture( const model_t *m_pSpriteModel, int frame )
@ -72,24 +78,24 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
if( x < 0 )
{
s1 += (-x)*(s2-s1) / w;
s1 += ( -x ) * ( s2 - s1 ) / w;
x = 0;
}
if( x + w > vid.width )
{
s2 -= (x + w - vid.width) * (s2 - s1)/ w ;
s2 -= ( x + w - vid.width ) * ( s2 - s1 ) / w;
w = vid.width - x;
}
if( y + h > vid.height )
{
t2 -= (y + h - vid.height) * (t2 - t1) / h;
t2 -= ( y + h - vid.height ) * ( t2 - t1 ) / h;
h = vid.height - y;
}
if( !pic->pixels[0] || s1 >= s2 || t1 >= t2 )
return;
//gEngfuncs.Con_Printf ("pixels is %p\n", pic->pixels[0] );
// gEngfuncs.Con_Printf ("pixels is %p\n", pic->pixels[0] );
height = h;
@ -115,20 +121,20 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
#pragma omp parallel for schedule(static)
for (v=0 ; v<height ; v++)
for( v = 0; v < height; v++ )
{
int alpha1 = vid.alpha;
pixel_t *dest = vid.buffer + (y + v) * vid.rowbytes + x;
uint sv = (skip + v)*(t2-t1)/h + t1;
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
uint sv = ( skip + v ) * ( t2 - t1 ) / h + t1;
uint u, f, fstep;
pixel_t *source = buffer + sv*pic->width + s1;
pixel_t *source = buffer + sv * pic->width + s1;
f = 0;
fstep = ((s2-s1) << 16)/w;
fstep = (( s2 - s1 ) << 16 ) / w;
for (u=0 ; u<w ; u++)
for( u = 0; u < w; u++ )
{
pixel_t src = source[f>>16];
pixel_t src = source[f >> 16];
int alpha = alpha1;
f += fstep;
@ -142,22 +148,22 @@ static void R_DrawStretchPicImplementation( int x, int y, int w, int h, int s1,
continue;
if( vid.color != COLOR_WHITE )
src = vid.modmap[(src & 0xff00)|(vid.color>>8)] << 8 | (src & vid.color & 0xff) | ((src & 0xff) >> 3);
src = vid.modmap[( src & 0xff00 ) | ( vid.color >> 8 )] << 8 | ( src & vid.color & 0xff ) | (( src & 0xff ) >> 3 );
if( vid.rendermode == kRenderTransAdd)
if( vid.rendermode == kRenderTransAdd )
{
pixel_t screen = dest[u];
dest[u] = vid.addmap[(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0);
dest[u] = vid.addmap[( src & 0xff00 ) | ( screen >> 8 )] << 8 | ( screen & 0xff ) | (( src & 0xff ) >> 0 );
}
else if( vid.rendermode == kRenderScreenFadeModulate )
{
pixel_t screen = dest[u];
dest[u] = BLEND_COLOR( screen, vid.color );
}
else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
else if( alpha < 7 ) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
{
pixel_t screen = dest[u]; // | 0xff & screen & src ;
dest[u] = BLEND_ALPHA( alpha, src, screen );//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
dest[u] = BLEND_ALPHA( alpha, src, screen ); // vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
}
else
dest[u] = src;
@ -174,7 +180,7 @@ R_DrawStretchPic
*/
void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum )
{
image_t *pic = R_GetTexture(texnum);
image_t *pic = R_GetTexture( texnum );
int width = pic->width, height = pic->height;
// GL_Bind( XASH_TEXTURE0, texnum );
if( s2 > 1.0f || t2 > 1.0f )
@ -183,10 +189,10 @@ void GAME_EXPORT R_DrawStretchPic( float x, float y, float w, float h, float s1,
return;
if( w < 1.0f || h < 1.0f )
return;
R_DrawStretchPicImplementation(x,y,w,h, width * s1, height * t1, width * s2, height * t2, pic);
R_DrawStretchPicImplementation( x, y, w, h, width * s1, height * t1, width * s2, height * t2, pic );
}
void Draw_Fill (int x, int y, int w, int h)
void Draw_Fill( int x, int y, int w, int h )
{
unsigned int height;
int v;
@ -218,25 +224,25 @@ void Draw_Fill (int x, int y, int w, int h)
}
#pragma omp parallel for schedule(static)
for (v=0 ; v<height ; v++)
for( v = 0; v < height; v++ )
{
pixel_t *dest = vid.buffer + (y + v) * vid.rowbytes + x;
pixel_t *dest = vid.buffer + ( y + v ) * vid.rowbytes + x;
uint u;
for (u=0 ; u<w ; u++)
for( u = 0; u < w; u++ )
{
if( alpha == 0 )
continue;
if( vid.rendermode == kRenderTransAdd)
if( vid.rendermode == kRenderTransAdd )
{
pixel_t screen = dest[u];
dest[u] = vid.addmap[(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0);
dest[u] = vid.addmap[( src & 0xff00 ) | ( screen >> 8 )] << 8 | ( screen & 0xff ) | (( src & 0xff ) >> 0 );
}
else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
else if( alpha < 7 ) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
{
pixel_t screen = dest[u]; // | 0xff & screen & src ;
dest[u] = BLEND_ALPHA( alpha, src, screen);//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
dest[u] = BLEND_ALPHA( alpha, src, screen ); // vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
}
else
dest[u] = src;
@ -256,9 +262,9 @@ void GAME_EXPORT R_DrawStretchRaw( float x, float y, float w, float h, int cols,
raw = (byte *)data;
//pglDisable( GL_BLEND );
//pglDisable( GL_ALPHA_TEST );
//pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
// pglDisable( GL_BLEND );
// pglDisable( GL_ALPHA_TEST );
// pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
tex = R_GetTexture( tr.cinTexture );
GL_Bind( XASH_TEXTURE0, tr.cinTexture );

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@ struct swblit_s
uint rmask, gmask, bmask;
void *(*pLockBuffer)( void );
void (*pUnlockBuffer)( void );
qboolean(*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
qboolean (*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
uint rotate;
qboolean gl1;
} swblit;
@ -20,7 +20,7 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
qboolean ret = true;
if( rotate > 1 )
{
gEngfuncs.Con_Printf("only 0-1 rotation supported\n");
gEngfuncs.Con_Printf( "only 0-1 rotation supported\n" );
ret = false;
}
else
@ -29,14 +29,14 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
if( offset_x || offset_y )
{
// it is possible implement for offset > 0
gEngfuncs.Con_Printf("offset transform not supported\n");
gEngfuncs.Con_Printf( "offset transform not supported\n" );
ret = false;
}
if( scale_x != 1.0f || scale_y != 1.0f )
{
// maybe implement 2x2?
gEngfuncs.Con_Printf("scale transform not supported\n");
gEngfuncs.Con_Printf( "scale transform not supported\n" );
ret = false;
}
@ -76,8 +76,8 @@ static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLui
static unsigned short *glbuf;
static int tex;
#define LOAD(x) p##x = gEngfuncs.GL_GetProcAddress(#x); \
gEngfuncs.Con_Printf(#x " : %p\n",p##x)
#define LOAD( x ) p ## x = gEngfuncs.GL_GetProcAddress(#x ); \
gEngfuncs.Con_Printf(#x " : %p\n", p ## x )
void GAME_EXPORT GL_SetupAttributes( int safegl )
@ -108,14 +108,14 @@ void GAME_EXPORT GL_SetupAttributes( int safegl )
gEngfuncs.GL_SetAttribute( REF_GL_BLUE_SIZE, 5 );
}
void (*pglOrthof)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
void GL_FUNCTION( glBindBuffer)(GLenum target, GLuint buffer);
void (*pglOrthof)( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar );
void GL_FUNCTION( glBindBuffer )( GLenum target, GLuint buffer );
void GL_FUNCTION( glBufferData )(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
void GL_FUNCTION( glGenBuffers )(GLsizei n, GLuint *buffers);
void GL_FUNCTION( glDeleteBuffers )(GLsizei n, const GLuint *buffers);
GLvoid* GL_FUNCTION( glMapBufferOES )(GLenum target, GLenum access);
GLboolean GL_FUNCTION( glUnmapBufferOES )(GLenum target);
void GL_FUNCTION( glBufferData )( GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage );
void GL_FUNCTION( glGenBuffers )( GLsizei n, GLuint *buffers );
void GL_FUNCTION( glDeleteBuffers )( GLsizei n, const GLuint *buffers );
GLvoid * GL_FUNCTION( glMapBufferOES )( GLenum target, GLenum access );
GLboolean GL_FUNCTION( glUnmapBufferOES )( GLenum target );
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
#define GL_FRAMEBUFFER 0x8D40
#define GL_COLOR_ATTACHMENT0 0x8CE0
@ -123,54 +123,54 @@ GLboolean GL_FUNCTION( glUnmapBufferOES )(GLenum target);
#define GL_DRAW_FRAMEBUFFER 0x8CA9
void GAME_EXPORT GL_InitExtensions( void )
{
LOAD(glBegin);
LOAD(glEnd);
LOAD(glTexCoord2f);
LOAD(glVertex2f);
LOAD(glEnable);
LOAD(glDisable);
LOAD(glTexImage2D);
LOAD(glOrtho);
LOAD(glOrthof);
LOAD(glMatrixMode);
LOAD(glLoadIdentity);
LOAD(glViewport);
LOAD(glBindTexture);
LOAD(glDebugMessageCallbackARB);
LOAD(glDebugMessageControlARB);
LOAD(glGetError);
LOAD(glGenTextures);
LOAD(glTexParameteri);
LOAD(glEnableClientState);
LOAD(glDisableClientState);
LOAD(glVertexPointer);
LOAD(glTexCoordPointer);
LOAD(glDrawElements);
LOAD(glClear);
LOAD(glClearColor);
LOAD(glGetString);
LOAD(glColor4f);
LOAD(glDrawArrays);
LOAD(glBindBuffer);
LOAD(glBufferData);
LOAD(glGenBuffers);
LOAD(glDeleteBuffers);
LOAD(glMapBufferOES);
LOAD( glBegin );
LOAD( glEnd );
LOAD( glTexCoord2f );
LOAD( glVertex2f );
LOAD( glEnable );
LOAD( glDisable );
LOAD( glTexImage2D );
LOAD( glOrtho );
LOAD( glOrthof );
LOAD( glMatrixMode );
LOAD( glLoadIdentity );
LOAD( glViewport );
LOAD( glBindTexture );
LOAD( glDebugMessageCallbackARB );
LOAD( glDebugMessageControlARB );
LOAD( glGetError );
LOAD( glGenTextures );
LOAD( glTexParameteri );
LOAD( glEnableClientState );
LOAD( glDisableClientState );
LOAD( glVertexPointer );
LOAD( glTexCoordPointer );
LOAD( glDrawElements );
LOAD( glClear );
LOAD( glClearColor );
LOAD( glGetString );
LOAD( glColor4f );
LOAD( glDrawArrays );
LOAD( glBindBuffer );
LOAD( glBufferData );
LOAD( glGenBuffers );
LOAD( glDeleteBuffers );
LOAD( glMapBufferOES );
if( !pglMapBufferOES )
pglMapBufferOES = gEngfuncs.GL_GetProcAddress("glMapBuffer");
LOAD(glUnmapBufferOES);
pglMapBufferOES = gEngfuncs.GL_GetProcAddress( "glMapBuffer" );
LOAD( glUnmapBufferOES );
if( !pglUnmapBufferOES )
pglUnmapBufferOES = gEngfuncs.GL_GetProcAddress("glUnmapBuffer");
LOAD(glGenFramebuffers);
LOAD(glBindFramebuffer);
LOAD(glFramebufferTexture2D);
LOAD(glBlitFramebuffer);
LOAD(glGenTextures);
gEngfuncs.Con_Printf("version:%s\n",pglGetString(GL_VERSION));
pglUnmapBufferOES = gEngfuncs.GL_GetProcAddress( "glUnmapBuffer" );
LOAD( glGenFramebuffers );
LOAD( glBindFramebuffer );
LOAD( glFramebufferTexture2D );
LOAD( glBlitFramebuffer );
LOAD( glGenTextures );
gEngfuncs.Con_Printf( "version:%s\n", pglGetString( GL_VERSION ));
#if GLDEBUG
if( gpGlobals->developer )
{
gEngfuncs.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
@ -196,7 +196,7 @@ static void R_Unlock_GL1( void )
{
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
//gEngfuncs.Con_Printf("%d\n",pglGetError());
// gEngfuncs.Con_Printf("%d\n",pglGetError());
pglBegin( GL_QUADS );
pglTexCoord2f( 0, 0 );
pglVertex2f( 0, 0 );
@ -217,7 +217,7 @@ static void R_Unlock_GL1( void )
static void R_Unlock_GLES1( void )
{
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
pglDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
gEngfuncs.GL_SwapBuffers();
}
@ -232,19 +232,19 @@ static qboolean R_CreateBuffer_GL1( int width, int height, uint *stride, uint *b
pglLoadIdentity();
pglEnable( GL_TEXTURE_2D );
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
if( glbuf )
Mem_Free(glbuf);
Mem_Free( glbuf );
glbuf = Mem_Malloc( r_temppool, width*height*2 );
glbuf = Mem_Malloc( r_temppool, width * height * 2 );
*stride = width;
*bpp = 2;
*r = MASK(5) << (6 + 5);
*g = MASK(6) << 5;
*b = MASK(5);
*r = MASK( 5 ) << ( 6 + 5 );
*g = MASK( 6 ) << 5;
*b = MASK( 5 );
return true;
}
@ -272,32 +272,32 @@ static qboolean R_CreateBuffer_GLES1( int width, int height, uint *stride, uint
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
pglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
//if( vbo )
// if( vbo )
// pglDeleteBuffers( 1,&vbo );
pglGenBuffers( 1,&vbo );
pglGenBuffers( 1, &vbo );
pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof( data ), data, GL_STATIC_DRAW_ARB );
pglEnableClientState( GL_VERTEX_ARRAY );
pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
pglVertexPointer( 2, GL_FLOAT, 8, 0 );
pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 ) ;
pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
pglColor4f( 1, 1, 1, 1 );
if( glbuf )
Mem_Free( glbuf );
glbuf = Mem_Malloc( r_temppool, width*height*2 );
glbuf = Mem_Malloc( r_temppool, width * height * 2 );
*stride = width;
*bpp = 2;
*r = MASK(5) << (6 + 5);
*g = MASK(6) << 5;
*b = MASK(5);
*r = MASK( 5 ) << ( 6 + 5 );
*g = MASK( 6 ) << 5;
*b = MASK( 5 );
return true;
}
@ -320,7 +320,7 @@ static void *R_Lock_GLES3( void )
if( pglUnmapBufferOES )
pglUnmapBufferOES( GL_PIXEL_UNPACK_BUFFER );
pglBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
glbuf = Mem_Malloc( r_temppool, vid.width*vid.height*2 );
glbuf = Mem_Malloc( r_temppool, vid.width * vid.height * 2 );
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf );
return glbuf;
}
@ -340,7 +340,7 @@ static void R_Unlock_GLES3( void )
pglUnmapBufferOES( GL_PIXEL_UNPACK_BUFFER );
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 );
}
//pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
// pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
pglBlitFramebuffer( 0, vid.height, vid.width, 0, 0, 0, vid.width, vid.height, GL_COLOR_BUFFER_BIT, GL_NEAREST );
}
@ -378,35 +378,35 @@ static qboolean R_CreateBuffer_GLES3( int width, int height, uint *stride, uint
pglDeleteBuffers( 1,&pbo );
*/
//pglGenBuffers( 1,&vbo );
// pglGenBuffers( 1,&vbo );
pglGenBuffers( 1, &pbo );
//pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
//pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
// pglBindBuffer( GL_ARRAY_BUFFER_ARB, vbo );
// pglBufferData( GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB );
//pglEnableClientState( GL_VERTEX_ARRAY );
//pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
// pglEnableClientState( GL_VERTEX_ARRAY );
// pglEnableClientState( GL_TEXTURE_COORD_ARRAY );
//pglVertexPointer( 2, GL_FLOAT, 8, 0 );
//pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
//pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
// pglVertexPointer( 2, GL_FLOAT, 8, 0 );
// pglTexCoordPointer( 2, GL_FLOAT, 8, 0 );
// pglBindBuffer( GL_ARRAY_BUFFER_ARB, 0 );
pglBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo );
pglBufferData( GL_PIXEL_UNPACK_BUFFER, width * height * 2, 0, GL_STREAM_DRAW_ARB );
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 );
pglGenFramebuffers(1, &fbo);
pglBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
pglFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, to, 0);
pglBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
pglGenFramebuffers( 1, &fbo );
pglBindFramebuffer( GL_READ_FRAMEBUFFER, fbo );
pglFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, to, 0 );
pglBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
//pglColor4f( 1, 1, 1, 1 );
// pglColor4f( 1, 1, 1, 1 );
*stride = width;
*bpp = 2;
*r = MASK(5) << (6 + 5);
*g = MASK(6) << 5;
*b = MASK(5);
*r = MASK( 5 ) << ( 6 + 5 );
*g = MASK( 6 ) << 5;
*b = MASK( 5 );
return true;
}
@ -417,7 +417,8 @@ static int FIRST_BIT( uint mask )
{
uint i;
for( i = 0; !(BIT(i) & mask); i++ );
for( i = 0; !( BIT( i ) & mask ); i++ )
;
return i;
}
@ -435,59 +436,59 @@ static int COUNT_BITS( uint mask )
static void R_BuildScreenMap( void )
{
int i;
uint rshift = FIRST_BIT(swblit.rmask), gshift = FIRST_BIT(swblit.gmask), bshift = FIRST_BIT(swblit.bmask);
uint rbits = COUNT_BITS(swblit.rmask), gbits = COUNT_BITS(swblit.gmask), bbits = COUNT_BITS(swblit.bmask);
uint rmult = BIT(rbits), gmult = BIT(gbits), bmult = BIT(bbits);
uint rdiv = MASK(5), gdiv = MASK(6), bdiv = MASK(5);
uint rshift = FIRST_BIT( swblit.rmask ), gshift = FIRST_BIT( swblit.gmask ), bshift = FIRST_BIT( swblit.bmask );
uint rbits = COUNT_BITS( swblit.rmask ), gbits = COUNT_BITS( swblit.gmask ), bbits = COUNT_BITS( swblit.bmask );
uint rmult = BIT( rbits ), gmult = BIT( gbits ), bmult = BIT( bbits );
uint rdiv = MASK( 5 ), gdiv = MASK( 6 ), bdiv = MASK( 5 );
gEngfuncs.Con_Printf("Blit table: %d %d %d %d %d %d\n", rmult, gmult, bmult, rdiv, gdiv, bdiv );
gEngfuncs.Con_Printf( "Blit table: %d %d %d %d %d %d\n", rmult, gmult, bmult, rdiv, gdiv, bdiv );
#ifdef SEPARATE_BLIT
for( i = 0; i < 256; i++ )
{
unsigned int r,g,b;
unsigned int r, g, b;
// 332 to 565
r = ((i >> (8 - 3) )<< 2 ) & MASK(5);
g = ((i >> (8 - 3 - 3)) << 3) & MASK(6);
b = ((i >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
vid.screen_major[i] = r << (6 + 5) | (g << 5) | b;
r = (( i >> ( 8 - 3 )) << 2 ) & MASK( 5 );
g = (( i >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
b = (( i >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
vid.screen_major[i] = r << ( 6 + 5 ) | ( g << 5 ) | b;
// restore minor GBRGBRGB
r = MOVE_BIT(i, 5, 1) | MOVE_BIT(i, 2, 0);
g = MOVE_BIT(i, 7, 2) | MOVE_BIT(i, 4, 1) | MOVE_BIT(i, 1, 0);
b = MOVE_BIT(i, 6, 2) | MOVE_BIT(i, 3, 1) | MOVE_BIT(i, 0, 0);
vid.screen_minor[i] = r << (6 + 5) | (g << 5) | b;
r = MOVE_BIT( i, 5, 1 ) | MOVE_BIT( i, 2, 0 );
g = MOVE_BIT( i, 7, 2 ) | MOVE_BIT( i, 4, 1 ) | MOVE_BIT( i, 1, 0 );
b = MOVE_BIT( i, 6, 2 ) | MOVE_BIT( i, 3, 1 ) | MOVE_BIT( i, 0, 0 );
vid.screen_minor[i] = r << ( 6 + 5 ) | ( g << 5 ) | b;
}
#else
for( i = 0; i < 256; i++ )
{
unsigned int r,g,b , major, j;
unsigned int r, g, b, major, j;
// 332 to 565
r = ((i >> (8 - 3) )<< 2 ) & MASK(5);
g = ((i >> (8 - 3 - 3)) << 3) & MASK(6);
b = ((i >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
//major = r << (6 + 5) | (g << 5) | b;
major = (r * rmult / rdiv) << rshift | (g * gmult / gdiv) << gshift | (b * bmult / bdiv) << bshift;
r = (( i >> ( 8 - 3 )) << 2 ) & MASK( 5 );
g = (( i >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
b = (( i >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
// major = r << (6 + 5) | (g << 5) | b;
major = ( r * rmult / rdiv ) << rshift | ( g * gmult / gdiv ) << gshift | ( b * bmult / bdiv ) << bshift;
for( j = 0; j < 256; j++ )
{
uint minor;
// restore minor GBRGBRGB
r = MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
g = MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
b = MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
//vid.screen[(i<<8)|j] = r << (6 + 5) | (g << 5) | b | major;
minor = (r * rmult / rdiv) << rshift | (g * gmult / gdiv) << gshift | (b * bmult / bdiv) << bshift;
r = MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
g = MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
b = MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
// vid.screen[(i<<8)|j] = r << (6 + 5) | (g << 5) | b | major;
minor = ( r * rmult / rdiv ) << rshift | ( g * gmult / gdiv ) << gshift | ( b * bmult / bdiv ) << bshift;
if( swblit.bpp == 2 )
vid.screen[(i<<8)|j] = major | minor;
vid.screen[( i << 8 ) | j] = major | minor;
else
vid.screen32[(i<<8)|j] = major | minor;
vid.screen32[( i << 8 ) | j] = major | minor;
}
@ -495,7 +496,7 @@ static void R_BuildScreenMap( void )
#endif
}
#define FOR_EACH_COLOR(x) for( r##x = 0; r##x < BIT(3); r##x++ ) for( g##x = 0; g##x < BIT(3); g##x++ ) for( b##x = 0; b##x < BIT(2); b##x++ )
#define FOR_EACH_COLOR( x ) for( r ## x = 0; r ## x < BIT( 3 ); r ## x++ ) for( g ## x = 0; g ## x < BIT( 3 ); g ## x++ ) for( b ## x = 0; b ## x < BIT( 2 ); b ## x++ )
static void R_BuildBlendMaps( void )
{
@ -503,30 +504,30 @@ static void R_BuildBlendMaps( void )
unsigned int r2, g2, b2;
unsigned int i, j;
FOR_EACH_COLOR(1)FOR_EACH_COLOR(2)
FOR_EACH_COLOR( 1 ) FOR_EACH_COLOR( 2 )
{
unsigned int r, g, b;
unsigned short index1 = r1 << (2 + 3) | g1 << 2 | b1;
unsigned short index2 = (r2 << (2 + 3) | g2 << 2 | b2) << 8;
unsigned short index1 = r1 << ( 2 + 3 ) | g1 << 2 | b1;
unsigned short index2 = ( r2 << ( 2 + 3 ) | g2 << 2 | b2 ) << 8;
unsigned int a;
r = r1 + r2;
g = g1 + g2;
b = b1 + b2;
if( r > MASK(3) )
r = MASK(3);
if( g > MASK(3) )
g = MASK(3);
if( b > MASK(2) )
b = MASK(2);
ASSERT(!vid.addmap[index2|index1]);
if( r > MASK( 3 ))
r = MASK( 3 );
if( g > MASK( 3 ))
g = MASK( 3 );
if( b > MASK( 2 ))
b = MASK( 2 );
ASSERT( !vid.addmap[index2 | index1] );
vid.addmap[index2|index1] = r << (2 + 3) | g << 2 | b;
r = r1 * r2 / MASK(3);
g = g1 * g2 / MASK(3);
b = b1 * b2 / MASK(2);
vid.addmap[index2 | index1] = r << ( 2 + 3 ) | g << 2 | b;
r = r1 * r2 / MASK( 3 );
g = g1 * g2 / MASK( 3 );
b = b1 * b2 / MASK( 2 );
vid.modmap[index2|index1] = r << (2 + 3) | g << 2 | b;
vid.modmap[index2 | index1] = r << ( 2 + 3 ) | g << 2 | b;
}
for( i = 0; i < 8192; i++ )
{
@ -536,49 +537,49 @@ static void R_BuildBlendMaps( void )
uint j = color & 0xff;
unsigned short index1 = i;
r1 = ((m >> (8 - 3) )<< 2 ) & MASK(5);
g1 = ((m >> (8 - 3 - 3)) << 3) & MASK(6);
b1 = ((m >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
r1 |= MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
g1 |= MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
b1 |= MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
r1 = (( m >> ( 8 - 3 )) << 2 ) & MASK( 5 );
g1 = (( m >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
b1 = (( m >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
r1 |= MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
g1 |= MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
b1 |= MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
for( j = 0; j < 32; j++)
for( j = 0; j < 32; j++ )
{
unsigned int index2 = j << 13;
unsigned int major, minor;
r = r1 * j / 32;
g = g1 * j / 32;
b = b1 * j / 32;
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
// save minor GBRGBRGB
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
vid.colormap[index2|index1] = major << 8 | (minor & 0xFF);
vid.colormap[index2 | index1] = major << 8 | ( minor & 0xFF );
}
}
for( i = 0; i < 1024; i++ )
{
unsigned int r, g, b;
uint color = i << 6 | BIT(5) | BIT(4) | BIT(3);
uint color = i << 6 | BIT( 5 ) | BIT( 4 ) | BIT( 3 );
uint m = color >> 8;
uint j = color & 0xff;
unsigned short index1 = i;
r1 = ((m >> (8 - 3) )<< 2 ) & MASK(5);
g1 = ((m >> (8 - 3 - 3)) << 3) & MASK(6);
b1 = ((m >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
r1 |= MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
g1 |= MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
b1 |= MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
r1 = (( m >> ( 8 - 3 )) << 2 ) & MASK( 5 );
g1 = (( m >> ( 8 - 3 - 3 )) << 3 ) & MASK( 6 );
b1 = (( m >> ( 8 - 3 - 3 - 2 )) << 3 ) & MASK( 5 );
r1 |= MOVE_BIT( j, 5, 1 ) | MOVE_BIT( j, 2, 0 );
g1 |= MOVE_BIT( j, 7, 2 ) | MOVE_BIT( j, 4, 1 ) | MOVE_BIT( j, 1, 0 );
b1 |= MOVE_BIT( j, 6, 2 ) | MOVE_BIT( j, 3, 1 ) | MOVE_BIT( j, 0, 0 );
FOR_EACH_COLOR(2)
FOR_EACH_COLOR( 2 )
{
unsigned int index2 = (r2 << (2 + 3) | g2 << 2 | b2) << 10;
unsigned int index2 = ( r2 << ( 2 + 3 ) | g2 << 2 | b2 ) << 10;
unsigned int k;
for( k = 0; k < 3; k++ )
{
@ -586,25 +587,25 @@ static void R_BuildBlendMaps( void )
unsigned int a = k + 2;
r = r1 * (7 - a) / 7 + (r2 << 2 | BIT(2)) * a / 7;
g = g1 * (7 - a) / 7 + (g2 << 3 | MASK(2)) * a / 7;
b = b1 * (7 - a) / 7 + (b2 << 3 | MASK(2)) * a / 7;
if( r > MASK(5) )
r = MASK(5);
if( g > MASK(6) )
g = MASK(6);
if( b > MASK(5) )
b = MASK(5);
r = r1 * ( 7 - a ) / 7 + ( r2 << 2 | BIT( 2 )) * a / 7;
g = g1 * ( 7 - a ) / 7 + ( g2 << 3 | MASK( 2 )) * a / 7;
b = b1 * ( 7 - a ) / 7 + ( b2 << 3 | MASK( 2 )) * a / 7;
if( r > MASK( 5 ))
r = MASK( 5 );
if( g > MASK( 6 ))
g = MASK( 6 );
if( b > MASK( 5 ))
b = MASK( 5 );
ASSERT( b < 32 );
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
// save minor GBRGBRGB
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
minor = minor & ~0x3f;
vid.alphamap[k << 18|index2|index1] = major << 8 | (minor & 0xFF);
vid.alphamap[k << 18 | index2 | index1] = major << 8 | ( minor & 0xFF );
}
}
}
@ -670,11 +671,11 @@ static qboolean R_AllocScreen( void )
vid.rowbytes = gpGlobals->width; // rowpixels
if( d_pzbuffer )
free( d_pzbuffer );
d_pzbuffer = malloc( vid.width*vid.height*2 + 64 );
d_pzbuffer = malloc( vid.width * vid.height * 2 + 64 );
if( vid.buffer )
free( vid.buffer );
vid.buffer = malloc( vid.width * vid.height*sizeof( pixel_t ) );
vid.buffer = malloc( vid.width * vid.height * sizeof( pixel_t ));
return true;
}
@ -684,26 +685,26 @@ void R_BlitScreen( void )
int u, v;
void *buffer = swblit.pLockBuffer();
// gEngfuncs.Con_Printf("blit begin\n");
//memset( vid.buffer, 10, vid.width * vid.height );
// memset( vid.buffer, 10, vid.width * vid.height );
if( !buffer || gpGlobals->width != vid.width || gpGlobals->height != vid.height )
{
gEngfuncs.Con_Printf("pre allocscrn\n");
gEngfuncs.Con_Printf( "pre allocscrn\n" );
R_AllocScreen();
gEngfuncs.Con_Printf("post allocscrn\n");
gEngfuncs.Con_Printf( "post allocscrn\n" );
return;
}
//return;
//byte *buf = vid.buffer;
// return;
// byte *buf = vid.buffer;
//#pragma omp parallel for schedule(static)
//gEngfuncs.Con_Printf("swblit %d %d", swblit.bpp, vid.height );
// #pragma omp parallel for schedule(static)
// gEngfuncs.Con_Printf("swblit %d %d", swblit.bpp, vid.height );
if( swblit.rotate )
{
if( swblit.bpp == 2 )
{
unsigned short *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint d = swblit.stride - v - 1;
@ -720,7 +721,7 @@ void R_BlitScreen( void )
{
unsigned int *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint d = swblit.stride - v - 1;
@ -736,7 +737,7 @@ void R_BlitScreen( void )
else if( swblit.bpp == 3 )
{
byte *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint d = swblit.stride - v - 1;
@ -744,11 +745,11 @@ void R_BlitScreen( void )
for( u = 0; u < vid.width; u++ )
{
unsigned int s = vid.screen32[vid.buffer[start + u]];
pbuf[(d)*3] = s;
pbuf[( d ) * 3] = s;
s = s >> 8;
pbuf[(d)*3+1] = s;
pbuf[( d ) * 3 + 1] = s;
s = s >> 8;
pbuf[(d)*3+2] = s;
pbuf[( d ) * 3 + 2] = s;
d += swblit.stride;
}
}
@ -759,7 +760,7 @@ void R_BlitScreen( void )
if( swblit.bpp == 2 )
{
unsigned short *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint dstart = swblit.stride * v;
@ -775,7 +776,7 @@ void R_BlitScreen( void )
{
unsigned int *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint dstart = swblit.stride * v;
@ -790,7 +791,7 @@ void R_BlitScreen( void )
else if( swblit.bpp == 3 )
{
byte *pbuf = buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * v;
uint dstart = swblit.stride * v;
@ -798,11 +799,11 @@ void R_BlitScreen( void )
for( u = 0; u < vid.width; u++ )
{
unsigned int s = vid.screen32[vid.buffer[start + u]];
pbuf[(dstart+u)*3] = s;
pbuf[( dstart + u ) * 3] = s;
s = s >> 8;
pbuf[(dstart+u)*3+1] = s;
pbuf[( dstart + u ) * 3 + 1] = s;
s = s >> 8;
pbuf[(dstart+u)*3+2] = s;
pbuf[( dstart + u ) * 3 + 2] = s;
}
}
}
@ -845,8 +846,8 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
qboolean result;
r_shot = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
r_shot->width = (vid.width + 3) & ~3;
r_shot->height = (vid.height + 3) & ~3;
r_shot->width = ( vid.width + 3 ) & ~3;
r_shot->height = ( vid.height + 3 ) & ~3;
r_shot->flags = IMAGE_HAS_COLOR;
r_shot->type = PF_BGRA_32; // was RGBA
r_shot->size = r_shot->width * r_shot->height * gEngfuncs.Image_GetPFDesc( r_shot->type )->bpp;
@ -874,7 +875,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
{
uint32_t *pbuf = (uint32_t *)r_shot->buffer;
for( v = 0; v < vid.height;v++)
for( v = 0; v < vid.height; v++ )
{
uint start = vid.rowbytes * ( vid.height - v );
uint dstart = swblit.stride * v;
@ -900,7 +901,7 @@ qboolean GAME_EXPORT VID_ScreenShot( const char *filename, int shot_type )
width = Q_rint( height * ((double)r_shot->width / r_shot->height ));
break;
case VID_MAPSHOT:
flags |= IMAGE_RESAMPLE|IMAGE_QUANTIZE; // GoldSrc request overviews in 8-bit format
flags |= IMAGE_RESAMPLE | IMAGE_QUANTIZE; // GoldSrc request overviews in 8-bit format
height = 768;
width = 1024;
break;

View file

@ -15,10 +15,10 @@ GNU General Public License for more details.
#include "r_local.h"
#define TEXTURES_HASH_SIZE (MAX_TEXTURES >> 2)
#define TEXTURES_HASH_SIZE ( MAX_TEXTURES >> 2 )
static image_t r_images[MAX_TEXTURES];
static image_t* r_imagesHashTable[TEXTURES_HASH_SIZE];
static image_t *r_imagesHashTable[TEXTURES_HASH_SIZE];
static uint r_numImages;
#define IsLightMap( tex ) ( FBitSet(( tex )->flags, TF_ATLAS_PAGE ))
@ -45,14 +45,14 @@ void GAME_EXPORT GL_Bind( int tmu, unsigned int texnum )
image_t *image;
image = &r_images[texnum];
//vid.rendermode = kRenderNormal;
// vid.rendermode = kRenderNormal;
if( vid.rendermode == kRenderNormal )
{
r_affinetridesc.pskin = image->pixels[0];
d_pdrawspans = R_PolysetFillSpans8 ;
d_pdrawspans = R_PolysetFillSpans8;
}
else if( vid.rendermode == kRenderTransAdd)
else if( vid.rendermode == kRenderTransAdd )
{
r_affinetridesc.pskin = image->pixels[0];
d_pdrawspans = R_PolysetDrawSpansAdditive;
@ -99,7 +99,8 @@ static void GL_UpdateTextureParams( int iTexture )
Assert( tex != NULL );
if( !tex->pixels) return; // free slot
if( !tex->pixels )
return; // free slot
GL_Bind( XASH_TEXTURE0, iTexture );
}
@ -142,12 +143,12 @@ static size_t GL_CalcImageSize( pixformat_t format, int width, int height, int d
size = width * height * depth * 4;
break;
case PF_DXT1:
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 8) * depth;
size = ((( width + 3 ) >> 2 ) * (( height + 3 ) >> 2 ) * 8 ) * depth;
break;
case PF_DXT3:
case PF_DXT5:
case PF_ATI2:
size = (((width + 3) >> 2) * ((height + 3) >> 2) * 16) * depth;
size = ((( width + 3 ) >> 2 ) * (( height + 3 ) >> 2 ) * 16 ) * depth;
break;
}
@ -250,7 +251,7 @@ static void GL_SetTextureFormat( image_t *tex, pixformat_t format, int channelMa
qboolean haveAlpha = ( channelMask & IMAGE_HAS_ALPHA );
Assert( tex != NULL );
//tex->transparent = !!( channelMask & IMAGE_HAS_ALPHA );
// tex->transparent = !!( channelMask & IMAGE_HAS_ALPHA );
}
/*
@ -271,7 +272,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
vec3_t normal;
int i, x, y;
if( !source ) return NULL;
if( !source )
return NULL;
scaledImage = Mem_Realloc( r_temppool, scaledImage, outWidth * outHeight * 4 );
fracStep = inWidth * 0x10000 / outWidth;
@ -280,14 +282,14 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
frac = fracStep >> 2;
for( i = 0; i < outWidth; i++ )
{
p1[i] = 4 * (frac >> 16);
p1[i] = 4 * ( frac >> 16 );
frac += fracStep;
}
frac = (fracStep >> 2) * 3;
frac = ( fracStep >> 2 ) * 3;
for( i = 0; i < outWidth; i++ )
{
p2[i] = 4 * (frac >> 16);
p2[i] = 4 * ( frac >> 16 );
frac += fracStep;
}
@ -295,8 +297,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
{
for( y = 0; y < outHeight; y++, out += outWidth )
{
inRow1 = in + inWidth * (int)(((float)y + 0.25f) * inHeight / outHeight);
inRow2 = in + inWidth * (int)(((float)y + 0.75f) * inHeight / outHeight);
inRow1 = in + inWidth * (int)(((float)y + 0.25f ) * inHeight / outHeight );
inRow2 = in + inWidth * (int)(((float)y + 0.75f ) * inHeight / outHeight );
for( x = 0; x < outWidth; x++ )
{
@ -312,10 +314,10 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
if( !VectorNormalizeLength( normal ))
VectorSet( normal, 0.5f, 0.5f, 1.0f );
((byte *)(out+x))[0] = 128 + (byte)(127.0f * normal[0]);
((byte *)(out+x))[1] = 128 + (byte)(127.0f * normal[1]);
((byte *)(out+x))[2] = 128 + (byte)(127.0f * normal[2]);
((byte *)(out+x))[3] = 255;
((byte *)( out + x ))[0] = 128 + (byte)( 127.0f * normal[0] );
((byte *)( out + x ))[1] = 128 + (byte)( 127.0f * normal[1] );
((byte *)( out + x ))[2] = 128 + (byte)( 127.0f * normal[2] );
((byte *)( out + x ))[3] = 255;
}
}
}
@ -323,8 +325,8 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
{
for( y = 0; y < outHeight; y++, out += outWidth )
{
inRow1 = in + inWidth * (int)(((float)y + 0.25f) * inHeight / outHeight);
inRow2 = in + inWidth * (int)(((float)y + 0.75f) * inHeight / outHeight);
inRow1 = in + inWidth * (int)(((float)y + 0.25f ) * inHeight / outHeight );
inRow2 = in + inWidth * (int)(((float)y + 0.75f ) * inHeight / outHeight );
for( x = 0; x < outWidth; x++ )
{
@ -333,10 +335,10 @@ byte *GL_ResampleTexture( const byte *source, int inWidth, int inHeight, int out
pix3 = (byte *)inRow2 + p1[x];
pix4 = (byte *)inRow2 + p2[x];
((byte *)(out+x))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0]) >> 2;
((byte *)(out+x))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1]) >> 2;
((byte *)(out+x))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2]) >> 2;
((byte *)(out+x))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3]) >> 2;
((byte *)( out + x ))[0] = ( pix1[0] + pix2[0] + pix3[0] + pix4[0] ) >> 2;
((byte *)( out + x ))[1] = ( pix1[1] + pix2[1] + pix3[1] + pix4[1] ) >> 2;
((byte *)( out + x ))[2] = ( pix1[2] + pix2[2] + pix3[2] + pix4[2] ) >> 2;
((byte *)( out + x ))[3] = ( pix1[3] + pix2[3] + pix3[3] + pix4[3] ) >> 2;
}
}
}
@ -404,7 +406,7 @@ static byte *GL_ApplyFilter( const byte *source, int width, int height )
byte *out = (byte *)source;
int i;
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ) )
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
return in;
for( i = 0; source && i < width * height; i++, in += 4 )
@ -431,7 +433,8 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
int row, x, y, z;
vec3_t normal;
if( !in ) return;
if( !in )
return;
mipWidth = Q_max( 1, ( srcWidth >> 1 ));
mipHeight = Q_max( 1, ( srcHeight >> 1 ));
@ -456,26 +459,26 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
{
if((( x << 1 ) + 1 ) < srcWidth )
{
normal[0] = MAKE_SIGNED( in[row+0] ) + MAKE_SIGNED( in[row+4] )
+ MAKE_SIGNED( next[row+0] ) + MAKE_SIGNED( next[row+4] );
normal[1] = MAKE_SIGNED( in[row+1] ) + MAKE_SIGNED( in[row+5] )
+ MAKE_SIGNED( next[row+1] ) + MAKE_SIGNED( next[row+5] );
normal[2] = MAKE_SIGNED( in[row+2] ) + MAKE_SIGNED( in[row+6] )
+ MAKE_SIGNED( next[row+2] ) + MAKE_SIGNED( next[row+6] );
normal[0] = MAKE_SIGNED( in[row + 0] ) + MAKE_SIGNED( in[row + 4] )
+ MAKE_SIGNED( next[row + 0] ) + MAKE_SIGNED( next[row + 4] );
normal[1] = MAKE_SIGNED( in[row + 1] ) + MAKE_SIGNED( in[row + 5] )
+ MAKE_SIGNED( next[row + 1] ) + MAKE_SIGNED( next[row + 5] );
normal[2] = MAKE_SIGNED( in[row + 2] ) + MAKE_SIGNED( in[row + 6] )
+ MAKE_SIGNED( next[row + 2] ) + MAKE_SIGNED( next[row + 6] );
}
else
{
normal[0] = MAKE_SIGNED( in[row+0] ) + MAKE_SIGNED( next[row+0] );
normal[1] = MAKE_SIGNED( in[row+1] ) + MAKE_SIGNED( next[row+1] );
normal[2] = MAKE_SIGNED( in[row+2] ) + MAKE_SIGNED( next[row+2] );
normal[0] = MAKE_SIGNED( in[row + 0] ) + MAKE_SIGNED( next[row + 0] );
normal[1] = MAKE_SIGNED( in[row + 1] ) + MAKE_SIGNED( next[row + 1] );
normal[2] = MAKE_SIGNED( in[row + 2] ) + MAKE_SIGNED( next[row + 2] );
}
if( !VectorNormalizeLength( normal ))
VectorSet( normal, 0.5f, 0.5f, 1.0f );
out[0] = 128 + (byte)(127.0f * normal[0]);
out[1] = 128 + (byte)(127.0f * normal[1]);
out[2] = 128 + (byte)(127.0f * normal[2]);
out[0] = 128 + (byte)( 127.0f * normal[0] );
out[1] = 128 + (byte)( 127.0f * normal[1] );
out[2] = 128 + (byte)( 127.0f * normal[2] );
out[3] = 255;
}
}
@ -489,17 +492,17 @@ static void GL_BuildMipMap( byte *in, int srcWidth, int srcHeight, int srcDepth,
{
if((( x << 1 ) + 1 ) < srcWidth )
{
out[0] = (in[row+0] + in[row+4] + next[row+0] + next[row+4]) >> 2;
out[1] = (in[row+1] + in[row+5] + next[row+1] + next[row+5]) >> 2;
out[2] = (in[row+2] + in[row+6] + next[row+2] + next[row+6]) >> 2;
out[3] = (in[row+3] + in[row+7] + next[row+3] + next[row+7]) >> 2;
out[0] = ( in[row + 0] + in[row + 4] + next[row + 0] + next[row + 4] ) >> 2;
out[1] = ( in[row + 1] + in[row + 5] + next[row + 1] + next[row + 5] ) >> 2;
out[2] = ( in[row + 2] + in[row + 6] + next[row + 2] + next[row + 6] ) >> 2;
out[3] = ( in[row + 3] + in[row + 7] + next[row + 3] + next[row + 7] ) >> 2;
}
else
{
out[0] = (in[row+0] + next[row+0]) >> 1;
out[1] = (in[row+1] + next[row+1]) >> 1;
out[2] = (in[row+2] + next[row+2]) >> 1;
out[3] = (in[row+3] + next[row+3]) >> 1;
out[0] = ( in[row + 0] + next[row + 0] ) >> 1;
out[1] = ( in[row + 1] + next[row + 1] ) >> 1;
out[2] = ( in[row + 2] + next[row + 2] ) >> 1;
out[3] = ( in[row + 3] + next[row + 3] ) >> 1;
}
}
}
@ -532,7 +535,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
GL_SetTextureDimensions( tex, pic->width, pic->height, pic->depth );
GL_SetTextureFormat( tex, pic->type, pic->flags );
//gEngfuncs.Con_Printf("%s %d %d\n", tex->name, tex->width, tex->height );
// gEngfuncs.Con_Printf("%s %d %d\n", tex->name, tex->width, tex->height );
Assert( pic != NULL );
Assert( tex != NULL );
@ -542,14 +545,15 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
buf = pic->buffer;
mipCount = 4;//GL_CalcMipmapCount( tex, ( buf != NULL ));
mipCount = 4; // GL_CalcMipmapCount( tex, ( buf != NULL ));
// NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
if((( pic->width != tex->width ) || ( pic->height != tex->height )))
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf;
else
data = buf;
//if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
// if( !ImageCompressed( pic->type ) && !FBitSet( tex->flags, TF_NOMIPMAP ) && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
// data = GL_ApplyFilter( data, tex->width, tex->height );
// mips will be auto-generated if desired
@ -560,40 +564,40 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( width, height, tex->depth );
size = GL_CalcImageSize( pic->type, width, height, tex->depth );
//GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, data );
// GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, data );
// increase size to workaround triangle renderer bugs
// it seems to assume memory readable. maybe it was pointed to WAD?
//tex->pixels[j] = (byte*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 1024 ) + 512;
tex->pixels[j] = (pixel_t*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) );
// tex->pixels[j] = (byte*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) + 1024 ) + 512;
tex->pixels[j] = (pixel_t *)Mem_Calloc( r_temppool, width * height * sizeof( pixel_t ));
//memset( (byte*)tex->pixels[j] - 512, 0xFF, 512 );
//memset( (byte*)tex->pixels[j] + width * height * sizeof(pixel_t), 0xFF, 512 );
// memset( (byte*)tex->pixels[j] - 512, 0xFF, 512 );
// memset( (byte*)tex->pixels[j] + width * height * sizeof(pixel_t), 0xFF, 512 );
if( j == 0 && tex->flags & TF_HAS_ALPHA )
tex->alpha_pixels = (pixel_t*)Mem_Calloc( r_temppool, width * height * sizeof(pixel_t) );
tex->alpha_pixels = (pixel_t *)Mem_Calloc( r_temppool, width * height * sizeof( pixel_t ));
for(i = 0; i < height * width; i++ )
for( i = 0; i < height * width; i++ )
{
unsigned int r, g, b, major, minor;
// seems to look better
r = data[i * 4 + 0] * BIT(5) / 256;
g = data[i * 4 + 1] * BIT(6) / 256;
b = data[i * 4 + 2] * BIT(5) / 256;
r = data[i * 4 + 0] * BIT( 5 ) / 256;
g = data[i * 4 + 1] * BIT( 6 ) / 256;
b = data[i * 4 + 2] * BIT( 5 ) / 256;
// 565 to 332
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
// save minor GBRGBRGB
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
tex->pixels[j][i] = major << 8 | (minor & 0xFF);
tex->pixels[j][i] = major << 8 | ( minor & 0xFF );
if( j == 0 && tex->alpha_pixels )
{
unsigned int alpha = (data[i * 4 + 3] * 8 / 256) << (16 - 3);
tex->alpha_pixels[i] = (tex->pixels[j][i] >> 3) | alpha;
if( !sw_noalphabrushes.value && data[i * 4 + 3] < 128 && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ) )
tex->pixels[j][i] = TRANSPARENT_COLOR; //0000 0011 0100 1001;
unsigned int alpha = ( data[i * 4 + 3] * 8 / 256 ) << ( 16 - 3 );
tex->alpha_pixels[i] = ( tex->pixels[j][i] >> 3 ) | alpha;
if( !sw_noalphabrushes.value && data[i * 4 + 3] < 128 && FBitSet( pic->flags, IMAGE_ONEBIT_ALPHA ))
tex->pixels[j][i] = TRANSPARENT_COLOR; // 0000 0011 0100 1001;
}
}
@ -604,7 +608,7 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
tex->size += texsize;
tex->numMips++;
//GL_CheckTexImageError( tex );
// GL_CheckTexImageError( tex );
}
return true;
@ -622,8 +626,10 @@ static void GL_ProcessImage( image_t *tex, rgbdata_t *pic )
uint img_flags = 0;
// force upload texture as RGB or RGBA (detail textures requires this)
if( tex->flags & TF_FORCE_COLOR ) pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA ) tex->flags |= TF_HAS_ALPHA;
if( tex->flags & TF_FORCE_COLOR )
pic->flags |= IMAGE_HAS_COLOR;
if( pic->flags & IMAGE_HAS_ALPHA )
tex->flags |= TF_HAS_ALPHA;
if( ImageCompressed( pic->type ))
{
@ -670,7 +676,7 @@ static qboolean GL_CheckTexName( const char *name )
{
int len;
if( !COM_CheckString( name ) )
if( !COM_CheckString( name ))
return false;
len = Q_strlen( name );
@ -678,7 +684,7 @@ static qboolean GL_CheckTexName( const char *name )
// because multi-layered textures can exceed name string
if( len >= sizeof( r_images->name ))
{
gEngfuncs.Con_Printf( S_ERROR "%s: too long name %s (%d)\n", __func__, name, len);
gEngfuncs.Con_Printf( S_ERROR "%s: too long name %s (%d)\n", __func__, name, len );
return false;
}
@ -719,7 +725,8 @@ static image_t *GL_AllocTexture( const char *name, texFlags_t flags )
// find a free texture_t slot
for( i = 0, tex = r_images; i < r_numImages; i++, tex++ )
if( !tex->name[0] ) break;
if( !tex->name[0] )
break;
if( i == r_numImages )
{
@ -733,7 +740,7 @@ static image_t *GL_AllocTexture( const char *name, texFlags_t flags )
// copy initial params
Q_strncpy( tex->name, name, sizeof( tex->name ));
//tex->texnum = i; // texnum is used for fast acess into gl_textures array too
// tex->texnum = i; // texnum is used for fast acess into gl_textures array too
tex->flags = flags;
// add to hash table
@ -758,7 +765,8 @@ static void GL_DeleteTexture( image_t *tex )
ASSERT( tex != NULL );
// already freed?
if( !tex->pixels[0]) return;
if( !tex->pixels[0] )
return;
// debug
if( !tex->name[0] )
@ -773,7 +781,8 @@ static void GL_DeleteTexture( image_t *tex )
while( 1 )
{
cur = *prev;
if( !cur ) break;
if( !cur )
break;
if( cur == tex )
{
@ -788,8 +797,10 @@ static void GL_DeleteTexture( image_t *tex )
gEngfuncs.FS_FreeImage( tex->original );
for( i = 0; i < 4; i++ )
if( tex->pixels[i]) Mem_Free(tex->pixels[i]);
if( tex->alpha_pixels ) Mem_Free(tex->alpha_pixels);
if( tex->pixels[i] )
Mem_Free( tex->pixels[i] );
if( tex->alpha_pixels )
Mem_Free( tex->alpha_pixels );
memset( tex, 0, sizeof( *tex ));
}
@ -843,7 +854,7 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
// see if already loaded
if(( tex = GL_TextureForName( name )))
return (tex - r_images);
return( tex - r_images );
if( FBitSet( flags, TF_NOFLIP_TGA ))
SetBits( picFlags, IL_DONTFLIP_TGA );
@ -855,7 +866,8 @@ int GAME_EXPORT GL_LoadTexture( const char *name, const byte *buf, size_t size,
gEngfuncs.Image_SetForceFlags( picFlags );
pic = gEngfuncs.FS_LoadImage( name, buf, size );
if( !pic ) return 0; // couldn't loading image
if( !pic )
return 0; // couldn't loading image
// allocate the new one
tex = GL_AllocTexture( name, flags );
@ -899,10 +911,11 @@ int GAME_EXPORT GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texF
// see if already loaded
if(( tex = GL_TextureForName( name )) && !update )
return (tex - r_images);
return( tex - r_images );
// couldn't loading image
if( !pic ) return 0;
if( !pic )
return 0;
if( update )
{
@ -924,7 +937,7 @@ int GAME_EXPORT GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texF
}
GL_ApplyTextureParams( tex ); // update texture filter, wrap etc
return (tex - r_images);
return( tex - r_images );
}
/*
@ -995,7 +1008,7 @@ int GAME_EXPORT GL_FindTexture( const char *name )
// see if already loaded
if(( tex = GL_TextureForName( name )))
return (tex - r_images);
return( tex - r_images );
return 0;
}
@ -1112,7 +1125,7 @@ static rgbdata_t *GL_FakeImage( int width, int height, int depth, int flags )
r_image.flags = flags;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * r_image.depth * 4;
r_image.buffer = (r_image.size > sizeof( data2D )) ? NULL : data2D;
r_image.buffer = ( r_image.size > sizeof( data2D )) ? NULL : data2D;
r_image.palette = NULL;
r_image.numMips = 1;
r_image.encode = 0;
@ -1143,7 +1156,7 @@ void R_InitDlightTexture( void )
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP|TF_CLAMP|TF_ATLAS_PAGE );
tr.dlightTexture = GL_LoadTextureInternal( "*dlight", &r_image, TF_NOMIPMAP | TF_CLAMP | TF_ATLAS_PAGE );
}
/*
@ -1165,15 +1178,16 @@ static void GL_CreateInternalTextures( void )
for( x = 0; x < 16; x++ )
{
if(( y < 8 ) ^ ( x < 8 ))
((uint *)pic->buffer)[y*16+x] = 0xFFFF00FF;
else ((uint *)pic->buffer)[y*16+x] = 0xFF000000;
((uint *)pic->buffer )[y * 16 + x] = 0xFFFF00FF;
else
((uint *)pic->buffer )[y * 16 + x] = 0xFF000000;
}
}
tr.defaultTexture = GL_LoadTextureInternal( REF_DEFAULT_TEXTURE, pic, TF_COLORMAP );
// particle texture from quake1
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA );
pic = GL_FakeImage( 16, 16, 1, IMAGE_HAS_COLOR | IMAGE_HAS_ALPHA );
for( x = 0; x < 16; x++ )
{
@ -1193,24 +1207,24 @@ static void GL_CreateInternalTextures( void )
// white texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFFFFFFFF;
((uint *)pic->buffer )[x] = 0xFFFFFFFF;
tr.whiteTexture = GL_LoadTextureInternal( REF_WHITE_TEXTURE, pic, TF_COLORMAP );
// gray texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF7F7F7F;
((uint *)pic->buffer )[x] = 0xFF7F7F7F;
tr.grayTexture = GL_LoadTextureInternal( REF_GRAY_TEXTURE, pic, TF_COLORMAP );
// black texture
pic = GL_FakeImage( 4, 4, 1, IMAGE_HAS_COLOR );
for( x = 0; x < 16; x++ )
((uint *)pic->buffer)[x] = 0xFF000000;
((uint *)pic->buffer )[x] = 0xFF000000;
tr.blackTexture = GL_LoadTextureInternal( REF_BLACK_TEXTURE, pic, TF_COLORMAP );
// cinematic dummy
pic = GL_FakeImage( 640, 100, 1, IMAGE_HAS_COLOR );
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP|TF_CLAMP );
tr.cinTexture = GL_LoadTextureInternal( "*cintexture", pic, TF_NOMIPMAP | TF_CLAMP );
}
/*
@ -1228,7 +1242,8 @@ void R_TextureList_f( void )
for( i = texCount = 0, image = r_images; i < r_numImages; i++, image++ )
{
if( !image->pixels ) continue;
if( !image->pixels )
continue;
bytes += image->size;
texCount++;
@ -1239,13 +1254,15 @@ void R_TextureList_f( void )
if( image->flags & TF_NORMALMAP )
gEngfuncs.Con_Printf( "normal " );
else gEngfuncs.Con_Printf( "diffuse " );
else
gEngfuncs.Con_Printf( "diffuse " );
if( image->flags & TF_CLAMP )
gEngfuncs.Con_Printf( "clamp " );
else if( image->flags & TF_BORDER )
gEngfuncs.Con_Printf( "border " );
else gEngfuncs.Con_Printf( "repeat " );
else
gEngfuncs.Con_Printf( "repeat " );
gEngfuncs.Con_Printf( " %d ", image->depth );
gEngfuncs.Con_Printf( " %s\n", image->name );
}

View file

@ -19,7 +19,7 @@ GNU General Public License for more details.
#include "xash3d_mathlib.h"
#include "ref_params.h"
//unused, need refactor
// unused, need refactor
unsigned blocklights[10240];
/*
@ -38,7 +38,7 @@ CL_RunLightStyles
void CL_RunLightStyles( lightstyle_t *ls )
{
int i;
float frametime = (gp_cl->time - gp_cl->oldtime);
float frametime = ( gp_cl->time - gp_cl->oldtime );
if( !WORLDMODEL )
return;
@ -76,7 +76,7 @@ void CL_RunLightStyles( lightstyle_t *ls )
if( !ls[i].interp || !cl_lightstyle_lerping->value )
{
tr.lightstylevalue[i] = ls[i].map[flight%ls[i].length] * 22;
tr.lightstylevalue[i] = ls[i].map[flight % ls[i].length] * 22;
continue;
}
@ -132,10 +132,10 @@ void R_MarkLights( dlight_t *light, int bit, mnode_t *node )
if( !BoundsAndSphereIntersect( surf->info->mins, surf->info->maxs, light->origin, light->radius ))
continue; // no intersection
if( surf->dlightframe != tr.framecount )//tr.dlightframecount )
if( surf->dlightframe != tr.framecount ) // tr.dlightframecount )
{
surf->dlightbits = 0;
surf->dlightframe = tr.framecount; //tr.dlightframecount;
surf->dlightframe = tr.framecount; // tr.dlightframecount;
}
surf->dlightbits |= bit;
}
@ -170,10 +170,10 @@ void R_PushDlights( void )
if( l->die < gp_cl->time || !l->radius )
continue;
//if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))
//continue;
// if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 ))
// continue;
R_MarkLights( l, 1<<i, RI.currentmodel->nodes );
R_MarkLights( l, 1 << i, RI.currentmodel->nodes );
}
}
@ -259,7 +259,7 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
ds = s - info->lightmapmins[0];
dt = t - info->lightmapmins[1];
if ( ds > info->lightextents[0] || dt > info->lightextents[1] )
if( ds > info->lightextents[0] || dt > info->lightextents[1] )
continue;
cv->r = cv->g = cv->b = cv->a = 0;
@ -268,8 +268,8 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
return true;
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
smax = (info->lightextents[0] / sample_size) + 1;
tmax = (info->lightextents[1] / sample_size) + 1;
smax = ( info->lightextents[0] / sample_size ) + 1;
tmax = ( info->lightextents[1] / sample_size ) + 1;
ds /= sample_size;
dt /= sample_size;
@ -284,7 +284,8 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
if( FBitSet( surf->flags, SURF_PLANEBACK ))
VectorNegate( surf->plane->normal, faceNormal );
else VectorCopy( surf->plane->normal, faceNormal );
else
VectorCopy( surf->plane->normal, faceNormal );
// compute face TBN
#if 1
@ -315,9 +316,9 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f,
if( dm != NULL )
{
vec3_t srcNormal, lightNormal;
float f = (1.0f / 128.0f);
float f = ( 1.0f / 128.0f );
VectorSet( srcNormal, ((float)dm->r - 128.0f) * f, ((float)dm->g - 128.0f) * f, ((float)dm->b - 128.0f) * f );
VectorSet( srcNormal, ((float)dm->r - 128.0f ) * f, ((float)dm->g - 128.0f ) * f, ((float)dm->b - 128.0f ) * f );
Matrix3x4_VectorIRotate( tbn, srcNormal, lightNormal ); // turn to world space
VectorScale( lightNormal, (float)scale * -1.0f, lightNormal ); // turn direction from light
VectorAdd( g_trace_lightvec, lightNormal, g_trace_lightvec );
@ -345,8 +346,10 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
int i, maxEnts = 1;
colorVec light, cv;
if( lspot ) VectorClear( lspot );
if( lvec ) VectorClear( lvec );
if( lspot )
VectorClear( lspot );
if( lvec )
VectorClear( lvec );
if( WORLDMODEL && WORLDMODEL->lightdata )
{
@ -354,7 +357,7 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
last_fraction = 1.0f;
// get light from bmodels too
//if( CVAR_TO_BOOL( r_lighting_extended ))
// if( CVAR_TO_BOOL( r_lighting_extended ))
maxEnts = MAX_PHYSENTS;
// check all the bsp-models
@ -394,8 +397,10 @@ static colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t
if( g_trace_fraction < last_fraction )
{
if( lspot ) VectorCopy( g_trace_lightspot, lspot );
if( lvec ) VectorNormalize2( g_trace_lightvec, lvec );
if( lspot )
VectorCopy( g_trace_lightspot, lspot );
if( lvec )
VectorNormalize2( g_trace_lightvec, lvec );
light.r = Q_min(( cv.r >> 8 ), 255 );
light.g = Q_min(( cv.g >> 8 ), 255 );
light.b = Q_min(( cv.b >> 8 ), 255 );
@ -426,7 +431,7 @@ colorVec GAME_EXPORT R_LightVec( const vec3_t start, const vec3_t end, vec3_t ls
{
colorVec light = R_LightVecInternal( start, end, lspot, lvec );
//light.r = light.g = light.b = 255;
// light.r = light.g = light.b = 255;
if( lspot != NULL && lvec != NULL ) // CVAR_TO_BOOL( r_lighting_extended ) &&
{

View file

@ -36,8 +36,8 @@ typedef struct mip_s mip_t;
typedef int fixed8_t;
typedef int fixed16_t;
#define ASSERT(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#define Assert(x) if(!( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#define ASSERT( x ) if( !( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#define Assert( x ) if( !( x )) gEngfuncs.Host_Error( "assert failed at %s:%i\n", __FILE__, __LINE__ )
#include <stdio.h>
@ -75,10 +75,10 @@ extern poolhandle_t r_temppool;
#define RP_OLDVIEWLEAF BIT( 1 )
#define RP_CLIPPLANE BIT( 2 )
#define RP_NONVIEWERREF (RP_ENVVIEW)
#define RP_NONVIEWERREF ( RP_ENVVIEW )
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_LOCALCLIENT( e ) (( e ) != NULL && ( e )->index == ( gp_cl->playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define CL_IsViewEntityLocalPlayer() ( gp_cl->viewentity == ( gp_cl->playernum + 1 ))
@ -90,9 +90,9 @@ extern poolhandle_t r_temppool;
#define CULL_OTHER 4 // culled by other reason
// bit operation helpers
#define MASK(x) (BIT(x)-1)
#define GET_BIT(s,b) ((s & (1 << b)) >> b)
#define MOVE_BIT(s, f, t) (GET_BIT(s,f) << t )
#define MASK( x ) ( BIT( x ) - 1 )
#define GET_BIT( s, b ) (( s & ( 1 << b )) >> b )
#define MOVE_BIT( s, f, t ) ( GET_BIT( s, f ) << t )
/*
@ -115,33 +115,33 @@ typedef enum
} imagetype_t;
//===================================================================
// ===================================================================
typedef unsigned short pixel_t;
typedef struct vrect_s
{
int x,y,width,height;
int x, y, width, height;
struct vrect_s *pnext;
} vrect_t;
#define COLOR_WHITE 0xFFFF
//#define SEPARATE_BLIT
// #define SEPARATE_BLIT
typedef struct
{
pixel_t *buffer; // invisible buffer
pixel_t colormap[32*8192]; // 8192 * light levels
//pixel_t *alphamap; // 256 * 256 translucency map
pixel_t colormap[32 * 8192]; // 8192 * light levels
// pixel_t *alphamap; // 256 * 256 translucency map
#ifdef SEPARATE_BLIT
pixel_t screen_minor[256];
pixel_t screen_major[256];
#else
pixel_t screen[256*256];
unsigned int screen32[256*256];
pixel_t screen[256 * 256];
unsigned int screen32[256 * 256];
#endif
byte addmap[256*256];
byte modmap[256*256];
pixel_t alphamap[3*1024*256];
byte addmap[256 * 256];
byte modmap[256 * 256];
pixel_t alphamap[3 * 1024 * 256];
pixel_t color;
qboolean is2d;
byte alpha;
@ -172,7 +172,7 @@ typedef struct
cl_entity_t *currentbeam; // same as above but for beams
int viewport[4];
//gl_frustum_t frustum;
// gl_frustum_t frustum;
mleaf_t *viewleaf;
mleaf_t *oldviewleaf;
@ -204,7 +204,7 @@ typedef struct
matrix4x4 projectionMatrix;
matrix4x4 worldviewProjectionMatrix; // worldviewMatrix * projectionMatrix
byte visbytes[(MAX_MAP_LEAFS+7)/8];// actual PVS for current frame
byte visbytes[( MAX_MAP_LEAFS + 7 ) / 8]; // actual PVS for current frame
float viewplanedist;
@ -278,7 +278,7 @@ typedef struct
int recursion_level;
int max_recursion;
byte visbytes[(MAX_MAP_LEAFS+7)/8]; // member custom PVS
byte visbytes[( MAX_MAP_LEAFS + 7 ) / 8]; // member custom PVS
int lightstylevalue[MAX_LIGHTSTYLES]; // value 0 - 65536
int block_size; // lightmap blocksize
@ -332,8 +332,8 @@ extern ref_speeds_t r_stats;
extern ref_instance_t RI;
extern gl_globals_t tr;
#define r_numEntities (tr.draw_list->num_solid_entities + tr.draw_list->num_trans_entities)
#define r_numStatics (r_stats.c_client_ents)
#define r_numEntities ( tr.draw_list->num_solid_entities + tr.draw_list->num_trans_entities )
#define r_numStatics ( r_stats.c_client_ents )
typedef struct image_s
{
@ -380,9 +380,9 @@ qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
//
void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse );
float *R_DecalSetupVerts( decal_t *pDecal, msurface_t *surf, int texture, int *outCount );
//void DrawSingleDecal( decal_t *pDecal, msurface_t *fa );
// void DrawSingleDecal( decal_t *pDecal, msurface_t *fa );
void R_EntityRemoveDecals( model_t *mod );
//void DrawDecalsBatch( void );
// void DrawDecalsBatch( void );
void R_ClearDecals( void );
void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[3] );
@ -392,7 +392,7 @@ void GL_Bind( int tmu, unsigned int texnum );
// gl_draw.c
//
void R_Set2DMode( qboolean enable );
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data );//
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data ); //
// gl_image.c
//
@ -456,8 +456,8 @@ void Matrix4x4_ConcatTranslate( matrix4x4 out, float x, float y, float z );
void Matrix4x4_ConcatRotate( matrix4x4 out, float angle, float x, float y, float z );
void Matrix4x4_CreateTranslate( matrix4x4 out, float x, float y, float z );
void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float z );
void Matrix4x4_CreateProjection(matrix4x4 out, float xMax, float xMin, float yMax, float yMin, float zNear, float zFar);
void Matrix4x4_CreateOrtho(matrix4x4 m, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar);
void Matrix4x4_CreateProjection( matrix4x4 out, float xMax, float xMin, float yMax, float yMin, float zNear, float zFar );
void Matrix4x4_CreateOrtho( matrix4x4 m, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar );
void Matrix4x4_CreateModelview( matrix4x4 out );
//
@ -498,7 +498,8 @@ void Mod_StudioUnloadTextures( void *data );
// r_polyse.c
//
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct {
typedef struct
{
void *pdest;
short *pz;
int count;
@ -509,13 +510,13 @@ typedef struct {
extern void (*d_pdrawspans)( spanpackage_t * );
void R_PolysetFillSpans8( spanpackage_t * );
void R_PolysetDrawSpans8_33( spanpackage_t * );
void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage);
void R_PolysetDrawSpansTextureBlended( spanpackage_t *pspanpackage);
void R_PolysetDrawSpansBlended( spanpackage_t *pspanpackage);
void R_PolysetDrawSpansAdditive( spanpackage_t *pspanpackage);
void R_PolysetDrawSpansGlow( spanpackage_t *pspanpackage);
void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage );
void R_PolysetDrawSpansTextureBlended( spanpackage_t *pspanpackage );
void R_PolysetDrawSpansBlended( spanpackage_t *pspanpackage );
void R_PolysetDrawSpansAdditive( spanpackage_t *pspanpackage );
void R_PolysetDrawSpansGlow( spanpackage_t *pspanpackage );
//#include "vid_common.h"
// #include "vid_common.h"
//
// renderer exports
@ -581,8 +582,8 @@ void TriFogParams( float flDensity, int iFogSkybox );
void TriCullFace( TRICULLSTYLE mode );
void TriBrightness( float brightness );
#define ENGINE_GET_PARM_ (*gEngfuncs.EngineGetParm)
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_( (parm), 0 )
#define ENGINE_GET_PARM_ ( *gEngfuncs.EngineGetParm )
#define ENGINE_GET_PARM( parm ) ENGINE_GET_PARM_(( parm ), 0 )
extern ref_api_t gEngfuncs;
extern ref_globals_t *gpGlobals;
@ -639,10 +640,10 @@ static inline uint LinearGammaTable( uint b )
return !FBitSet( gp_host->features, ENGINE_LINEAR_GAMMA_SPACE ) ? tr.lineargammatable[b] : b;
}
#define WORLDMODEL (gp_cl->models[1])
#define WORLDMODEL ( gp_cl->models[1] )
// todo: gl_cull.c
#define R_CullModel(...) 0
#define R_CullModel( ... ) 0
// softrender defs
@ -655,7 +656,7 @@ static inline uint LinearGammaTable( uint b )
*/
#define VID_CBITS 6
#define VID_GRADES (1 << VID_CBITS)
#define VID_GRADES ( 1 << VID_CBITS )
// r_shared.h: general refresh-related stuff shared between the refresh and the
@ -663,15 +664,15 @@ static inline uint LinearGammaTable( uint b )
#define MAXVERTS 64 // max points in a surface polygon
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
// polygon (while processing)
#define MAXWORKINGVERTS ( MAXVERTS + 4 ) // max points in an intermediate
// polygon (while processing)
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
#define MAXHEIGHT 1200
#define MAXWIDTH 1920
#define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to
// be farther away than anything in
// the scene
// be farther away than anything in
// the scene
// d_iface.h: interface header file for rasterization driver modules
@ -685,7 +686,7 @@ static inline uint LinearGammaTable( uint b )
#define PARTICLE_Z_CLIP 8.0
// !!! must be kept the same as in quakeasm.h !!!
#define TRANSPARENT_COLOR 0x0349 //0xFF
#define TRANSPARENT_COLOR 0x0349 // 0xFF
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
@ -712,13 +713,13 @@ static inline uint LinearGammaTable( uint b )
#define ALIAS_Z_CLIP 0x0010
#define ALIAS_XY_CLIP_MASK 0x000F
#define SURFCACHE_SIZE_AT_320X240 1024*768
#define SURFCACHE_SIZE_AT_320X240 1024 * 768
#define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
// if bbox is trivially rejected
// if bbox is trivially rejected
#define XCENTERING (1.0f / 2.0f)
#define YCENTERING (1.0f / 2.0f)
#define XCENTERING ( 1.0f / 2.0f )
#define YCENTERING ( 1.0f / 2.0f )
#define CLIP_EPSILON 0.001f
@ -726,12 +727,12 @@ static inline uint LinearGammaTable( uint b )
#define NEAR_CLIP 0.01f
//#define MAXALIASVERTS 2000 // TODO: tune this
// #define MAXALIASVERTS 2000 // TODO: tune this
#define ALIAS_Z_CLIP_PLANE 4
// turbulence stuff
#define AMP 8*0x10000
#define AMP 8 * 0x10000
#define AMP2 3
#define SPEED 20
@ -757,7 +758,8 @@ typedef struct
#if SMALL_FINALVERT
typedef struct finalvert_s {
typedef struct finalvert_s
{
short u, v, s, t;
int l;
int zi;
@ -779,7 +781,8 @@ typedef struct finalvert_s {
#else
typedef struct finalvert_s {
typedef struct finalvert_s
{
int u, v, s, t;
int l;
int zi;
@ -940,25 +943,25 @@ VARS
====================================================
*/
// started
// started
extern float r_aliasuvscale; // scale-up factor for screen u and v
// on Alias vertices passed to driver
// on Alias vertices passed to driver
extern affinetridesc_t r_affinetridesc;
void D_DrawSurfaces (void);
void D_DrawSurfaces( void );
void R_DrawParticle( void );
void D_ViewChanged (void);
void D_ViewChanged( void );
//=======================================================================//
// =======================================================================//
// callbacks to Quake
extern drawsurf_t r_drawsurf;
void R_DrawSurface (void);
void R_DrawSurface( void );
//extern int c_surf;
// extern int c_surf;
extern byte r_warpbuffer[WARP_WIDTH * WARP_HEIGHT];
@ -979,16 +982,16 @@ extern fixed16_t sadjust, tadjust;
extern fixed16_t bbextents, bbextentt;
void D_DrawSpans16 (espan_t *pspans);
void D_DrawZSpans (espan_t *pspans);
void Turbulent8 (espan_t *pspan);
void NonTurbulent8 (espan_t *pspan); //PGM
void D_DrawSpans16( espan_t *pspans );
void D_DrawZSpans( espan_t *pspans );
void Turbulent8( espan_t *pspan );
void NonTurbulent8( espan_t *pspan ); // PGM
void D_BlendSpans16( espan_t *pspan, int alpha );
void D_AlphaSpans16( espan_t *pspan );
void D_AddSpans16( espan_t *pspan );
void TurbulentZ8( espan_t *pspan, int alpha );
surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel);
surfcache_t *D_CacheSurface( msurface_t *surface, int miplevel );
extern pixel_t *d_viewbuffer;
@ -1000,7 +1003,7 @@ extern int d_scantable[MAXHEIGHT];
extern int d_minmip;
extern float d_scalemip[3];
//===================================================================
// ===================================================================
extern int cachewidth;
extern pixel_t *cacheblock;
@ -1019,15 +1022,15 @@ extern surf_t *surfaces, *surface_p, *surf_max;
// surfaces[0] is a dummy, because index 0 is used to indicate no surface
// attached to an edge_t
//===================================================================
// ===================================================================
//extern vec3_t sxformaxis[4]; // s axis transformed into viewspace
//extern vec3_t txformaxis[4]; // t axis transformed into viewspac
// extern vec3_t sxformaxis[4]; // s axis transformed into viewspace
// extern vec3_t txformaxis[4]; // t axis transformed into viewspac
extern float xcenter, ycenter;
extern float xscale, yscale;
extern float xscaleinv, yscaleinv;
//extern float xscaleshrink, yscaleshrink;
// extern float xscaleshrink, yscaleshrink;
extern edge_t *auxedges;
@ -1040,7 +1043,7 @@ extern edge_t *removeedges[MAXHEIGHT];
extern int r_viewcluster, r_oldviewcluster;
extern int r_clipflags;
//extern qboolean r_fov_greater_than_90;
// extern qboolean r_fov_greater_than_90;
extern convar_t sw_clearcolor;
@ -1055,14 +1058,15 @@ extern convar_t r_traceglow;
extern convar_t sw_noalphabrushes;
extern convar_t r_studio_sort_textures;
extern struct qfrustum_s {
extern struct qfrustum_s
{
mplane_t screenedge[4];
clipplane_t view_clipplanes[4];
int frustum_indexes[4*6];
int frustum_indexes[4 * 6];
int *pfrustum_indexes[4];
} qfrustum;
#define CACHESPOT(surf) ((surfcache_t**)surf->info->reserved)
#define CACHESPOT( surf ) ((surfcache_t **)surf->info->reserved )
extern int r_currentkey;
extern int r_currentbkey;
extern qboolean insubmodel;
@ -1073,12 +1077,12 @@ extern unsigned short r_leafkeys[MAX_MAP_LEAFS];
#else
extern int r_leafkeys[MAX_MAP_LEAFS];
#endif
#define LEAF_KEY(pleaf) r_leafkeys[(pleaf - WORLDMODEL->leafs)]
#define LEAF_KEY( pleaf ) r_leafkeys[( pleaf - WORLDMODEL->leafs )]
extern mvertex_t *r_pcurrentvertbase;
//extern int r_maxvalidedgeoffset;
// extern int r_maxvalidedgeoffset;
typedef struct
{
@ -1094,21 +1098,21 @@ extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
extern float s_ziscale;
void R_DrawTriangle( void );
//void R_DrawTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2);
void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2);
// void R_DrawTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2);
void R_AliasClipTriangle( finalvert_t *index0, finalvert_t *index1, finalvert_t *index2 );
//
// r_bsp.c
//
void R_RotateBmodel (void);
void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode);
void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode);
void R_DrawBrushModel(cl_entity_t *pent);
void R_RotateBmodel( void );
void R_DrawSolidClippedSubmodelPolygons( model_t *pmodel, mnode_t *topnode );
void R_DrawSubmodelPolygons( model_t *pmodel, int clipflags, mnode_t *topnode );
void R_DrawBrushModel( cl_entity_t *pent );
//
// r_blitscreen.c
//
void R_InitCaches (void);
void R_InitCaches( void );
void R_BlitScreen( void );
qboolean R_InitBlit( qboolean gl );
qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int offset_y, float scale_x, float scale_y );
@ -1116,10 +1120,11 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
//
// r_edge.c
//
static inline void R_SurfacePatch (void) { }
void R_BeginEdgeFrame (void);
void R_RenderWorld (void);
void R_ScanEdges (void);
static inline void R_SurfacePatch( void ) {
}
void R_BeginEdgeFrame( void );
void R_RenderWorld( void );
void R_ScanEdges( void );
//
@ -1131,40 +1136,40 @@ void D_FlushCaches( void );
//
// r_draw.c
//
void Draw_Fill (int x, int y, int w, int h);
void Draw_Fill( int x, int y, int w, int h );
//
// r_misc.c
//
void R_SetupFrameQ (void);
void R_TransformFrustum (void);
void TransformVector (vec3_t in, vec3_t out);
void R_SetupFrameQ( void );
void R_TransformFrustum( void );
void TransformVector( vec3_t in, vec3_t out );
//
// r_rast.c
//
void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf);
void R_RenderFace (msurface_t *fa, int clipflags);
void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf );
void R_RenderFace( msurface_t *fa, int clipflags );
//
// r_main.c
//
void R_RenderTriangle( finalvert_t *fv1 , finalvert_t *fv2, finalvert_t *fv3 );
void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 );
void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, int s, int t );
void RotatedBBox (vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs);
int R_BmodelCheckBBox (float *minmaxs);
void RotatedBBox( vec3_t mins, vec3_t maxs, vec3_t angles, vec3_t tmins, vec3_t tmaxs );
int R_BmodelCheckBBox( float *minmaxs );
int CL_FxBlend( cl_entity_t *e );
void R_SetUpWorldTransform (void);
void R_SetUpWorldTransform( void );
#define BLEND_ALPHA_LOW(alpha, src, screen) (vid.alphamap[((alpha) << 18) | (((src) & 0xff00) << 2) | ((screen) >> 6)] | ((screen) & 0x3f))
#define BLEND_ALPHA(alpha, src, dst) (alpha) > 3?BLEND_ALPHA_LOW(7 - 1 - (alpha), (dst), (src)) : BLEND_ALPHA_LOW((alpha)-1, (src), (dst))
#define BLEND_ADD(src, screen) vid.addmap[((src)& 0xff00)|((screen)>>8)] << 8 | ((screen) & 0xff) | (((src) & 0xff) >> 0);
#define BLEND_COLOR(src, color) vid.modmap[((src) & 0xff00)|((color)>>8)] << 8 | ((src) & (color) & 0xff) | (((src) & 0xff) >> 3);
#define BLEND_ALPHA_LOW( alpha, src, screen ) ( vid.alphamap[(( alpha ) << 18 ) | ((( src ) & 0xff00 ) << 2 ) | (( screen ) >> 6 )] | (( screen ) & 0x3f ))
#define BLEND_ALPHA( alpha, src, dst ) ( alpha ) > 3 ? BLEND_ALPHA_LOW( 7 - 1 - ( alpha ), ( dst ), ( src )) : BLEND_ALPHA_LOW(( alpha ) - 1, ( src ), ( dst ))
#define BLEND_ADD( src, screen ) vid.addmap[(( src ) & 0xff00 ) | (( screen ) >> 8 )] << 8 | (( screen ) & 0xff ) | ((( src ) & 0xff ) >> 0 );
#define BLEND_COLOR( src, color ) vid.modmap[(( src ) & 0xff00 ) | (( color ) >> 8 )] << 8 | (( src ) & ( color ) & 0xff ) | ((( src ) & 0xff ) >> 3 );
#define LM_SAMPLE_SIZE_AUTO(surf) (tr.sample_size == -1?gEngfuncs.Mod_SampleSizeForFace( surf ): tr.sample_size)
#define LM_SAMPLE_SIZE_AUTO( surf ) ( tr.sample_size == -1 ? gEngfuncs.Mod_SampleSizeForFace( surf ) : tr.sample_size )
@ -1175,7 +1180,7 @@ void R_SetUpWorldTransform (void);
#include "crclib.h"
void _Mem_Free( void *data, const char *filename, int fileline );
void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char *filename, int fileline )
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
ALLOC_CHECK( 2 ) MALLOC_LIKE( _Mem_Free, 1 ) WARN_UNUSED_RESULT;
#define Mem_Malloc( pool, size ) _Mem_Alloc( pool, size, false, __FILE__, __LINE__ )
#define Mem_Calloc( pool, size ) _Mem_Alloc( pool, size, true, __FILE__, __LINE__ )

File diff suppressed because it is too large Load diff

View file

@ -67,17 +67,17 @@ void Matrix4x4_CreateProjection( matrix4x4 out, float xMax, float xMin, float yM
void Matrix4x4_CreateOrtho( matrix4x4 out, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar )
{
out[0][0] = 2.0f / (xRight - xLeft);
out[1][1] = 2.0f / (yTop - yBottom);
out[2][2] = -2.0f / (zFar - zNear);
out[0][0] = 2.0f / ( xRight - xLeft );
out[1][1] = 2.0f / ( yTop - yBottom );
out[2][2] = -2.0f / ( zFar - zNear );
out[3][3] = 1.0f;
out[0][1] = out[0][2] = out[1][0] = out[1][2] = out[3][0] = out[3][1] = out[3][2] = 0.0f;
out[2][0] = 0.0f;
out[2][1] = 0.0f;
out[0][3] = -(xRight + xLeft) / (xRight - xLeft);
out[1][3] = -(yTop + yBottom) / (yTop - yBottom);
out[2][3] = -(zFar + zNear) / (zFar - zNear);
out[0][3] = -( xRight + xLeft ) / ( xRight - xLeft );
out[1][3] = -( yTop + yBottom ) / ( yTop - yBottom );
out[2][3] = -( zFar + zNear ) / ( zFar - zNear );
}
/*
@ -124,30 +124,31 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float
float len, c, s;
len = x * x + y * y + z * z;
if( len != 0.0f ) len = 1.0f / sqrt( len );
if( len != 0.0f )
len = 1.0f / sqrt( len );
x *= len;
y *= len;
z *= len;
angle *= (-M_PI_F / 180.0f);
angle *= ( -M_PI_F / 180.0f );
SinCos( angle, &s, &c );
out[0][0]=x * x + c * (1 - x * x);
out[0][1]=x * y * (1 - c) + z * s;
out[0][2]=z * x * (1 - c) - y * s;
out[0][3]=0.0f;
out[1][0]=x * y * (1 - c) - z * s;
out[1][1]=y * y + c * (1 - y * y);
out[1][2]=y * z * (1 - c) + x * s;
out[1][3]=0.0f;
out[2][0]=z * x * (1 - c) + y * s;
out[2][1]=y * z * (1 - c) - x * s;
out[2][2]=z * z + c * (1 - z * z);
out[2][3]=0.0f;
out[3][0]=0.0f;
out[3][1]=0.0f;
out[3][2]=0.0f;
out[3][3]=1.0f;
out[0][0] = x * x + c * ( 1 - x * x );
out[0][1] = x * y * ( 1 - c ) + z * s;
out[0][2] = z * x * ( 1 - c ) - y * s;
out[0][3] = 0.0f;
out[1][0] = x * y * ( 1 - c ) - z * s;
out[1][1] = y * y + c * ( 1 - y * y );
out[1][2] = y * z * ( 1 - c ) + x * s;
out[1][3] = 0.0f;
out[2][0] = z * x * ( 1 - c ) + y * s;
out[2][1] = y * z * ( 1 - c ) - x * s;
out[2][2] = z * z + c * ( 1 - z * z );
out[2][3] = 0.0f;
out[3][0] = 0.0f;
out[3][1] = 0.0f;
out[3][2] = 0.0f;
out[3][3] = 1.0f;
}
static void Matrix4x4_CreateScale( matrix4x4 out, float x )

View file

@ -26,14 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
surfcache_t *d_initial_rover;
qboolean d_roverwrapped;
int d_minmip;
float d_scalemip[NUM_MIPS-1];
float d_scalemip[NUM_MIPS - 1];
static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8};
static float basemip[NUM_MIPS - 1] = {1.0, 0.5 * 0.8, 0.25 * 0.8};
//int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
// int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
//int d_pix_min, d_pix_max, d_pix_shift;
// int d_pix_min, d_pix_max, d_pix_shift;
int d_scantable[MAXHEIGHT];
short *zspantable[MAXHEIGHT];
@ -43,7 +43,7 @@ struct qfrustum_s qfrustum;
D_Patch
================
*/
static void D_Patch (void)
static void D_Patch( void )
{
}
/*
@ -52,12 +52,12 @@ D_ViewChanged
================
*/
void D_ViewChanged (void)
void D_ViewChanged( void )
{
int i;
scale_for_mip = xscale;
if (yscale > xscale)
if( yscale > xscale )
scale_for_mip = yscale;
d_zrowbytes = vid.width * 2;
@ -72,27 +72,27 @@ void D_ViewChanged (void)
if (d_pix_max < 1)
d_pix_max = 1;*/
//d_vrectx = RI.vrect.x;
//d_vrecty = RI.vrect.y;
//d_vrectright_particle = gpGlobals->width - d_pix_max;
//d_vrectbottom_particle =
// d_vrectx = RI.vrect.x;
// d_vrecty = RI.vrect.y;
// d_vrectright_particle = gpGlobals->width - d_pix_max;
// d_vrectbottom_particle =
// gpGlobals->height - d_pix_max;
for (i=0 ; i<vid.height; i++)
for( i = 0; i < vid.height; i++ )
{
d_scantable[i] = i*r_screenwidth;
zspantable[i] = d_pzbuffer + i*d_zwidth;
d_scantable[i] = i * r_screenwidth;
zspantable[i] = d_pzbuffer + i * d_zwidth;
}
/*
** clear Z-buffer and color-buffers if we're doing the gallery
*/
if ( !RI.drawWorld )
if( !RI.drawWorld )
{
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ) );
memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof( d_pzbuffer[0] ));
}
D_Patch ();
D_Patch();
}
@ -102,24 +102,24 @@ void D_ViewChanged (void)
R_TransformFrustum
===================
*/
void R_TransformFrustum (void)
void R_TransformFrustum( void )
{
int i;
vec3_t v, v2;
for (i=0 ; i<4 ; i++)
for( i = 0; i < 4; i++ )
{
v[0] = qfrustum.screenedge[i].normal[2];
v[1] = -qfrustum.screenedge[i].normal[0];
v[2] = qfrustum.screenedge[i].normal[1];
v2[0] = v[1]*RI.vright[0] + v[2]*RI.vup[0] + v[0]*RI.vforward[0];
v2[1] = v[1]*RI.vright[1] + v[2]*RI.vup[1] + v[0]*RI.vforward[1];
v2[2] = v[1]*RI.vright[2] + v[2]*RI.vup[2] + v[0]*RI.vforward[2];
v2[0] = v[1] * RI.vright[0] + v[2] * RI.vup[0] + v[0] * RI.vforward[0];
v2[1] = v[1] * RI.vright[1] + v[2] * RI.vup[1] + v[0] * RI.vforward[1];
v2[2] = v[1] * RI.vright[2] + v[2] * RI.vup[2] + v[0] * RI.vforward[2];
VectorCopy (v2, qfrustum.view_clipplanes[i].normal);
VectorCopy( v2, qfrustum.view_clipplanes[i].normal );
qfrustum.view_clipplanes[i].dist = DotProduct (tr.modelorg, v2);
qfrustum.view_clipplanes[i].dist = DotProduct( tr.modelorg, v2 );
}
}
@ -129,11 +129,11 @@ void R_TransformFrustum (void)
TransformVector
================
*/
void TransformVector (vec3_t in, vec3_t out)
void TransformVector( vec3_t in, vec3_t out )
{
out[0] = DotProduct(in,RI.vright);
out[1] = DotProduct(in,RI.vup);
out[2] = DotProduct(in,RI.vforward);
out[0] = DotProduct( in, RI.vright );
out[1] = DotProduct( in, RI.vup );
out[2] = DotProduct( in, RI.vforward );
}
/*
@ -141,25 +141,25 @@ void TransformVector (vec3_t in, vec3_t out)
R_SetUpFrustumIndexes
===============
*/
static void R_SetUpFrustumIndexes (void)
static void R_SetUpFrustumIndexes( void )
{
int i, j, *pindex;
pindex = qfrustum.frustum_indexes;
for (i=0 ; i<4 ; i++)
for( i = 0; i < 4; i++ )
{
for (j=0 ; j<3 ; j++)
for( j = 0; j < 3; j++ )
{
if (qfrustum.view_clipplanes[i].normal[j] < 0)
if( qfrustum.view_clipplanes[i].normal[j] < 0 )
{
pindex[j] = j;
pindex[j+3] = j+3;
pindex[j + 3] = j + 3;
}
else
{
pindex[j] = j+3;
pindex[j+3] = j;
pindex[j] = j + 3;
pindex[j + 3] = j;
}
}
@ -177,23 +177,23 @@ Called every time the vid structure or r_refdef changes.
Guaranteed to be called before the first refresh
===============
*/
static void R_ViewChanged (vrect_t *vr)
static void R_ViewChanged( vrect_t *vr )
{
int i;
float verticalFieldOfView, horizontalFieldOfView, xOrigin, yOrigin;
RI.vrect = *vr;
horizontalFieldOfView = 2*tan((float)RI.fov_x/360.0f * M_PI_F);
verticalFieldOfView = 2*tan((float)RI.fov_y/360.0f * M_PI_F);
horizontalFieldOfView = 2 * tan((float)RI.fov_x / 360.0f * M_PI_F );
verticalFieldOfView = 2 * tan((float)RI.fov_y / 360.0f * M_PI_F );
RI.fvrectx = (float)RI.vrect.x;
RI.fvrectx_adj = (float)RI.vrect.x - 0.5f;
RI.vrect_x_adj_shift20 = (RI.vrect.x<<20) + (1<<19) - 1;
RI.vrect_x_adj_shift20 = ( RI.vrect.x << 20 ) + ( 1 << 19 ) - 1;
RI.fvrecty = (float)RI.vrect.y;
RI.fvrecty_adj = (float)RI.vrect.y - 0.5f;
RI.vrectright = RI.vrect.x + RI.vrect.width;
RI.vrectright_adj_shift20 = (RI.vrectright<<20) + (1<<19) - 1;
RI.vrectright_adj_shift20 = ( RI.vrectright << 20 ) + ( 1 << 19 ) - 1;
RI.fvrectright = (float)RI.vrectright;
RI.fvrectright_adj = (float)RI.vrectright - 0.5f;
RI.vrectrightedge = (float)RI.vrectright - 0.99f;
@ -201,14 +201,14 @@ static void R_ViewChanged (vrect_t *vr)
RI.fvrectbottom = (float)RI.vrectbottom;
RI.fvrectbottom_adj = (float)RI.vrectbottom - 0.5f;
RI.aliasvrect.x = (int)(RI.vrect.x * r_aliasuvscale);
RI.aliasvrect.y = (int)(RI.vrect.y * r_aliasuvscale);
RI.aliasvrect.width = (int)(RI.vrect.width * r_aliasuvscale);
RI.aliasvrect.height = (int)(RI.vrect.height * r_aliasuvscale);
RI.aliasvrectright = RI.aliasvrect.x +
RI.aliasvrect.width;
RI.aliasvrectbottom = RI.aliasvrect.y +
RI.aliasvrect.height;
RI.aliasvrect.x = (int)( RI.vrect.x * r_aliasuvscale );
RI.aliasvrect.y = (int)( RI.vrect.y * r_aliasuvscale );
RI.aliasvrect.width = (int)( RI.vrect.width * r_aliasuvscale );
RI.aliasvrect.height = (int)( RI.vrect.height * r_aliasuvscale );
RI.aliasvrectright = RI.aliasvrect.x
+ RI.aliasvrect.width;
RI.aliasvrectbottom = RI.aliasvrect.y
+ RI.aliasvrect.height;
xOrigin = XCENTERING;
yOrigin = YCENTERING;
@ -219,11 +219,11 @@ static void R_ViewChanged (vrect_t *vr)
// the polygon rasterization will never render in the first row or column
// but will definately render in the [range] row and column, so adjust the
// buffer origin to get an exact edge to edge fill
xcenter = ((float)RI.vrect.width * XCENTERING) +
RI.vrect.x - 0.5f;
xcenter = ((float)RI.vrect.width * XCENTERING )
+ RI.vrect.x - 0.5f;
aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)RI.vrect.height * YCENTERING) +
RI.vrect.y - 0.5f;
ycenter = ((float)RI.vrect.height * YCENTERING )
+ RI.vrect.y - 0.5f;
aliasycenter = ycenter * r_aliasuvscale;
xscale = RI.vrect.width / horizontalFieldOfView;
@ -233,38 +233,38 @@ static void R_ViewChanged (vrect_t *vr)
yscale = xscale;
aliasyscale = yscale * r_aliasuvscale;
yscaleinv = 1.0f / yscale;
//xscaleshrink = (RI.vrect.width-6)/RI.horizontalFieldOfView;
//yscaleshrink = xscaleshrink;
// xscaleshrink = (RI.vrect.width-6)/RI.horizontalFieldOfView;
// yscaleshrink = xscaleshrink;
// left side clip
qfrustum.screenedge[0].normal[0] = -1.0f / (xOrigin*horizontalFieldOfView);
qfrustum.screenedge[0].normal[0] = -1.0f / ( xOrigin * horizontalFieldOfView );
qfrustum.screenedge[0].normal[1] = 0;
qfrustum.screenedge[0].normal[2] = 1;
qfrustum.screenedge[0].type = PLANE_ANYZ;
// right side clip
qfrustum.screenedge[1].normal[0] =
1.0f / ((1.0f-xOrigin)*horizontalFieldOfView);
qfrustum.screenedge[1].normal[0]
= 1.0f / (( 1.0f - xOrigin ) * horizontalFieldOfView );
qfrustum.screenedge[1].normal[1] = 0;
qfrustum.screenedge[1].normal[2] = 1;
qfrustum.screenedge[1].type = PLANE_ANYZ;
// top side clip
qfrustum.screenedge[2].normal[0] = 0;
qfrustum.screenedge[2].normal[1] = -1.0f / (yOrigin*verticalFieldOfView);
qfrustum.screenedge[2].normal[1] = -1.0f / ( yOrigin * verticalFieldOfView );
qfrustum.screenedge[2].normal[2] = 1;
qfrustum.screenedge[2].type = PLANE_ANYZ;
// bottom side clip
qfrustum.screenedge[3].normal[0] = 0;
qfrustum.screenedge[3].normal[1] = 1.0f / ((1.0f-yOrigin)*verticalFieldOfView);
qfrustum.screenedge[3].normal[1] = 1.0f / (( 1.0f - yOrigin ) * verticalFieldOfView );
qfrustum.screenedge[3].normal[2] = 1;
qfrustum.screenedge[3].type = PLANE_ANYZ;
for (i=0 ; i<4 ; i++)
VectorNormalize (qfrustum.screenedge[i].normal);
for( i = 0; i < 4; i++ )
VectorNormalize( qfrustum.screenedge[i].normal );
D_ViewChanged ();
D_ViewChanged();
}
@ -273,29 +273,29 @@ static void R_ViewChanged (vrect_t *vr)
R_SetupFrame
===============
*/
void R_SetupFrameQ (void)
void R_SetupFrameQ( void )
{
int i;
vrect_t vrect;
if (r_fullbright->flags & FCVAR_CHANGED)
if( r_fullbright->flags & FCVAR_CHANGED )
{
r_fullbright->flags &= ~FCVAR_CHANGED;
D_FlushCaches( ); // so all lighting changes
}
//tr.framecount++;
// tr.framecount++;
// build the transformation matrix for the given view angles
VectorCopy (RI.vieworg, tr.modelorg);
VectorCopy( RI.vieworg, tr.modelorg );
//AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
// AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup);
// current viewleaf
if ( RI.drawWorld )
if( RI.drawWorld )
{
RI.viewleaf = gEngfuncs.Mod_PointInLeaf (RI.vieworg, WORLDMODEL->nodes);
RI.viewleaf = gEngfuncs.Mod_PointInLeaf( RI.vieworg, WORLDMODEL->nodes );
r_viewcluster = RI.viewleaf->cluster;
}
@ -315,16 +315,16 @@ void R_SetupFrameQ (void)
d_viewbuffer = (void *)vid.buffer;
r_screenwidth = vid.rowbytes;
R_ViewChanged (&vrect);
R_ViewChanged( &vrect );
// start off with just the four screen edge clip planes
R_TransformFrustum ();
R_SetUpFrustumIndexes ();
R_TransformFrustum();
R_SetUpFrustumIndexes();
// save base values
VectorCopy (RI.vforward, RI.base_vpn);
VectorCopy (RI.vright, RI.base_vright);
VectorCopy (RI.vup, RI.base_vup);
VectorCopy( RI.vforward, RI.base_vpn );
VectorCopy( RI.vright, RI.base_vright );
VectorCopy( RI.vup, RI.base_vup );
// clear frame counts
/* c_faceclip = 0;
@ -341,13 +341,13 @@ void R_SetupFrameQ (void)
d_initial_rover = sc_rover;
d_minmip = sw_mipcap.value;
if (d_minmip > 3)
if( d_minmip > 3 )
d_minmip = 3;
else if (d_minmip < 0)
else if( d_minmip < 0 )
d_minmip = 0;
for (i=0 ; i<(NUM_MIPS-1) ; i++)
for( i = 0; i < ( NUM_MIPS - 1 ); i++ )
d_scalemip[i] = basemip[i] * sw_mipscale.value;
//d_aflatcolor = 0;
// d_aflatcolor = 0;
}

View file

@ -24,18 +24,18 @@ GNU General Public License for more details.
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 color24 gTracerColors[] =
{
{ 255, 255, 255 }, // White
{ 255, 0, 0 }, // Red
{ 0, 255, 0 }, // Green
{ 0, 0, 255 }, // Blue
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
{ 255, 167, 17 }, // Yellow-orange sparks
{ 255, 130, 90 }, // Yellowish streaks (garg)
{ 55, 60, 144 }, // Blue egon streak
{ 255, 130, 90 }, // More Yellowish streaks (garg)
{ 255, 140, 90 }, // More Yellowish streaks (garg)
{ 200, 130, 90 }, // More red streaks (garg)
{ 255, 120, 70 }, // Darker red streaks (garg)
{ 255, 255, 255 }, // White
{ 255, 0, 0 }, // Red
{ 0, 255, 0 }, // Green
{ 0, 0, 255 }, // Blue
{ 0, 0, 0 }, // Tracer default, filled in from cvars, etc.
{ 255, 167, 17 }, // Yellow-orange sparks
{ 255, 130, 90 }, // Yellowish streaks (garg)
{ 55, 60, 144 }, // Blue egon streak
{ 255, 130, 90 }, // More Yellowish streaks (garg)
{ 255, 140, 90 }, // More Yellowish streaks (garg)
{ 200, 130, 90 }, // More red streaks (garg)
{ 255, 120, 70 }, // Darker red streaks (garg)
};
/*
@ -56,14 +56,14 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
if( !cl_active_particles )
return; // nothing to draw?
//pglEnable( GL_BLEND );
//pglDisable( GL_ALPHA_TEST );
//pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// pglEnable( GL_BLEND );
// pglDisable( GL_ALPHA_TEST );
// pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
GL_SetRenderMode( kRenderTransAdd );
GL_Bind( XASH_TEXTURE0, tr.particleTexture );
//pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
//pglDepthMask( GL_FALSE );
// pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
// pglDepthMask( GL_FALSE );
for( p = cl_active_particles; p; p = p->next )
{
@ -72,12 +72,14 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
size = partsize; // get initial size of particle
// scale up to keep particles from disappearing
size += (p->org[0] - RI.vieworg[0]) * RI.cull_vforward[0];
size += (p->org[1] - RI.vieworg[1]) * RI.cull_vforward[1];
size += (p->org[2] - RI.vieworg[2]) * RI.cull_vforward[2];
size += ( p->org[0] - RI.vieworg[0] ) * RI.cull_vforward[0];
size += ( p->org[1] - RI.vieworg[1] ) * RI.cull_vforward[1];
size += ( p->org[2] - RI.vieworg[2] ) * RI.cull_vforward[2];
if( size < 20.0f ) size = partsize;
else size = partsize + size * 0.002f;
if( size < 20.0f )
size = partsize;
else
size = partsize + size * 0.002f;
// scale the axes by radius
VectorScale( RI.cull_vright, size, right );
@ -86,15 +88,15 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
p->color = bound( 0, p->color, 255 );
color = tr.palette[p->color];
alpha = 255 * (p->die - gp_cl->time) * 16.0f;
alpha = 255 * ( p->die - gp_cl->time ) * 16.0f;
if( alpha > 255 || p->type == pt_static )
alpha = 255;
//TriColor4ub( LightToTexGamma( color.r ),
// TriColor4ub( LightToTexGamma( color.r ),
// LightToTexGamma( color.g ),
// LightToTexGamma( color.b ), alpha );
//TriBrightness( alpha / 255.0f );
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
// TriBrightness( alpha / 255.0f );
_TriColor4f( 1.0f * alpha / 255 / 255 * color.r, 1.0f * alpha / 255 / 255 * color.g, 1.0f * alpha / 255 / 255 * color.b, 1.0f );
TriBegin( TRI_QUADS );
TriTexCoord2f( 0.0f, 1.0f );
@ -113,7 +115,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti
}
TriEnd();
//pglDepthMask( GL_TRUE );
// pglDepthMask( GL_TRUE );
}
/*
@ -169,12 +171,12 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
particle_t *p;
// update tracer color if this is changed
if( FBitSet( tracerred->flags|tracergreen->flags|tracerblue->flags|traceralpha->flags, FCVAR_CHANGED ))
if( FBitSet( tracerred->flags | tracergreen->flags | tracerblue->flags | traceralpha->flags, FCVAR_CHANGED ))
{
color24 *customColors = &gTracerColors[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);
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 );
@ -189,19 +191,21 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
if( !TriSpriteTexture( gEngfuncs.GetDefaultSprite( REF_DOT_SPRITE ), 0 ))
return;
//pglEnable( GL_BLEND );
//pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
//pglDisable( GL_ALPHA_TEST );
//pglDepthMask( GL_FALSE );
// pglEnable( GL_BLEND );
// pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
// pglDisable( GL_ALPHA_TEST );
// pglDepthMask( GL_FALSE );
gravity = frametime * tr.movevars->gravity;
scale = 1.0 - (frametime * 0.9);
if( scale < 0.0f ) scale = 0.0f;
scale = 1.0 - ( frametime * 0.9 );
if( scale < 0.0f )
scale = 0.0f;
for( p = cl_active_tracers; p; p = p->next )
{
atten = (p->die - gp_cl->time);
if( atten > 0.1f ) atten = 0.1f;
atten = ( p->die - gp_cl->time );
if( atten > 0.1f )
atten = 0.1f;
VectorScale( p->vel, ( p->ramp * atten ), delta );
VectorAdd( p->org, delta, end );
@ -242,8 +246,8 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
}
color = gTracerColors[p->color];
//TriColor4ub( color.r, color.g, color.b, p->packedColor );
_TriColor4f(1.0f*alpha/255/255*color.r,1.0f*alpha/255/255*color.g,1.0f*alpha/255/255* color.b,1.0f );
// TriColor4ub( color.r, color.g, color.b, p->packedColor );
_TriColor4f( 1.0f * alpha / 255 / 255 * color.r, 1.0f * alpha / 255 / 255 * color.g, 1.0f * alpha / 255 / 255 * color.b, 1.0f );
TriBegin( TRI_QUADS );
@ -267,8 +271,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
p->vel[1] *= scale;
p->vel[2] -= gravity;
p->packedColor = 255 * (p->die - gp_cl->time) * 2;
if( p->packedColor > 255 ) p->packedColor = 255;
p->packedColor = 255 * ( p->die - gp_cl->time ) * 2;
if( p->packedColor > 255 )
p->packedColor = 255;
}
else if( p->type == pt_slowgrav )
{
@ -276,7 +281,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
}
}
//pglDepthMask( GL_TRUE );
// pglDepthMask( GL_TRUE );
}
/*

File diff suppressed because it is too large Load diff

View file

@ -52,7 +52,7 @@ mvertex_t r_rightenter, r_rightexit;
typedef struct
{
float u,v;
float u, v;
int ceilv;
} evert_t;
@ -72,32 +72,32 @@ medge_t *r_skyedges;
int *r_skysurfedges;
// I just copied this data from a box map...
int skybox_planes[12] = {2,-128, 0,-128, 2,128, 1,128, 0,128, 1,-128};
int skybox_planes[12] = {2, -128, 0, -128, 2, 128, 1, 128, 0, 128, 1, -128};
int box_surfedges[24] = { 1,2,3,4, -1,5,6,7, 8,9,-6,10, -2,-7,-9,11,
12,-3,-11,-8, -12,-10,-5,-4};
int box_edges[24] = { 1,2, 2,3, 3,4, 4,1, 1,5, 5,6, 6,2, 7,8, 8,6, 5,7, 8,3, 7,4};
int box_surfedges[24] = { 1, 2, 3, 4, -1, 5, 6, 7, 8, 9, -6, 10, -2, -7, -9, 11,
12, -3, -11, -8, -12, -10, -5, -4};
int box_edges[24] = { 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 2, 7, 8, 8, 6, 5, 7, 8, 3, 7, 4};
int box_faces[6] = {0,0,2,2,2,0};
int box_faces[6] = {0, 0, 2, 2, 2, 0};
vec3_t box_vecs[6][2] = {
{ {0,-1,0}, {-1,0,0} },
{ {0,1,0}, {0,0,-1} },
{ {0,-1,0}, {1,0,0} },
{ {1,0,0}, {0,0,-1} },
{ {0,-1,0}, {0,0,-1} },
{ {-1,0,0}, {0,0,-1} }
{ {0, -1, 0}, {-1, 0, 0} },
{ {0, 1, 0}, {0, 0, -1} },
{ {0, -1, 0}, {1, 0, 0} },
{ {1, 0, 0}, {0, 0, -1} },
{ {0, -1, 0}, {0, 0, -1} },
{ {-1, 0, 0}, {0, 0, -1} }
};
float box_verts[8][3] = {
{-1,-1,-1},
{-1,1,-1},
{1,1,-1},
{1,-1,-1},
{-1,-1,1},
{-1,1,1},
{1,-1,1},
{1,1,1}
{-1, -1, -1},
{-1, 1, -1},
{1, 1, -1},
{1, -1, -1},
{-1, -1, 1},
{-1, 1, 1},
{1, -1, 1},
{1, 1, 1}
};
// down, west, up, north, east, south
@ -108,7 +108,7 @@ float box_verts[8][3] = {
R_EmitEdge
================
*/
static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
static void R_EmitEdge( mvertex_t *pv0, mvertex_t *pv1 )
{
edge_t *edge, *pcheck;
int u_check;
@ -119,7 +119,7 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
float scale, lzi0, u0, v0;
int side;
if (r_lastvertvalid)
if( r_lastvertvalid )
{
u0 = r_u1;
v0 = r_v1;
@ -131,80 +131,80 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
world = &pv0->position[0];
// transform and project
VectorSubtract (world, tr.modelorg, local);
TransformVector (local, transformed);
VectorSubtract( world, tr.modelorg, local );
TransformVector( local, transformed );
if (transformed[2] < NEAR_CLIP)
if( transformed[2] < NEAR_CLIP )
transformed[2] = NEAR_CLIP;
lzi0 = 1.0f / transformed[2];
// FIXME: build x/yscale into transform?
scale = xscale * lzi0;
u0 = (xcenter + scale*transformed[0]);
if (u0 < RI.fvrectx_adj)
u0 = ( xcenter + scale * transformed[0] );
if( u0 < RI.fvrectx_adj )
u0 = RI.fvrectx_adj;
if (u0 > RI.fvrectright_adj)
if( u0 > RI.fvrectright_adj )
u0 = RI.fvrectright_adj;
scale = yscale * lzi0;
v0 = (ycenter - scale*transformed[1]);
if (v0 < RI.fvrecty_adj)
v0 = ( ycenter - scale * transformed[1] );
if( v0 < RI.fvrecty_adj )
v0 = RI.fvrecty_adj;
if (v0 > RI.fvrectbottom_adj)
if( v0 > RI.fvrectbottom_adj )
v0 = RI.fvrectbottom_adj;
ceilv0 = (int) ceil(v0);
ceilv0 = (int) ceil( v0 );
}
world = &pv1->position[0];
// transform and project
VectorSubtract (world, tr.modelorg, local);
TransformVector (local, transformed);
VectorSubtract( world, tr.modelorg, local );
TransformVector( local, transformed );
if (transformed[2] < NEAR_CLIP)
if( transformed[2] < NEAR_CLIP )
transformed[2] = NEAR_CLIP;
r_lzi1 = 1.0f / transformed[2];
scale = xscale * r_lzi1;
r_u1 = (xcenter + scale*transformed[0]);
if (r_u1 < RI.fvrectx_adj)
r_u1 = ( xcenter + scale * transformed[0] );
if( r_u1 < RI.fvrectx_adj )
r_u1 = RI.fvrectx_adj;
if (r_u1 > RI.fvrectright_adj)
if( r_u1 > RI.fvrectright_adj )
r_u1 = RI.fvrectright_adj;
scale = yscale * r_lzi1;
r_v1 = (ycenter - scale*transformed[1]);
if (r_v1 < RI.fvrecty_adj)
r_v1 = ( ycenter - scale * transformed[1] );
if( r_v1 < RI.fvrecty_adj )
r_v1 = RI.fvrecty_adj;
if (r_v1 > RI.fvrectbottom_adj)
if( r_v1 > RI.fvrectbottom_adj )
r_v1 = RI.fvrectbottom_adj;
if (r_lzi1 > lzi0)
if( r_lzi1 > lzi0 )
lzi0 = r_lzi1;
if (lzi0 > r_nearzi) // for mipmap finding
if( lzi0 > r_nearzi ) // for mipmap finding
r_nearzi = lzi0;
// for right edges, all we want is the effect on 1/z
if (r_nearzionly)
if( r_nearzionly )
return;
r_emitted = 1;
r_ceilv1 = (int) ceil(r_v1);
r_ceilv1 = (int) ceil( r_v1 );
// create the edge
if (ceilv0 == r_ceilv1 || ceilv0 < 0 )
if( ceilv0 == r_ceilv1 || ceilv0 < 0 )
{
// we cache unclipped horizontal edges as fully clipped
if (cacheoffset != 0x7FFFFFFF)
if( cacheoffset != 0x7FFFFFFF )
{
cacheoffset = FULLY_CLIPPED_CACHED |
(tr.framecount & FRAMECOUNT_MASK);
cacheoffset = FULLY_CLIPPED_CACHED
| ( tr.framecount & FRAMECOUNT_MASK );
}
return; // horizontal edge
@ -218,7 +218,7 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->nearzi = lzi0;
if (side == 0)
if( side == 0 )
{
// trailing edge (go from p1 to p2)
v = ceilv0;
@ -233,8 +233,8 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->surfs[0] = surface_p - surfaces;
edge->surfs[1] = 0;
u_step = ((r_u1 - u0) / (r_v1 - v0));
u = u0 + ((float)v - v0) * u_step;
u_step = (( r_u1 - u0 ) / ( r_v1 - v0 ));
u = u0 + ((float)v - v0 ) * u_step;
}
else
{
@ -251,12 +251,12 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->surfs[0] = 0;
edge->surfs[1] = surface_p - surfaces;
u_step = ((u0 - r_u1) / (v0 - r_v1));
u = r_u1 + ((float)v - r_v1) * u_step;
u_step = (( u0 - r_u1 ) / ( v0 - r_v1 ));
u = r_u1 + ((float)v - r_v1 ) * u_step;
}
edge->u_step = u_step*0x100000;
edge->u = u*0x100000 + 0xFFFFF;
edge->u_step = u_step * 0x100000;
edge->u = u * 0x100000 + 0xFFFFF;
// we need to do this to avoid stepping off the edges if a very nearly
// horizontal edge is less than epsilon above a scan, and numeric error causes
@ -269,9 +269,9 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
edge->u = x;
if (edge->u > r)
edge->u = r;*/
if (edge->u < RI.vrect_x_adj_shift20)
if( edge->u < RI.vrect_x_adj_shift20 )
edge->u = RI.vrect_x_adj_shift20;
if (edge->u > RI.vrectright_adj_shift20)
if( edge->u > RI.vrectright_adj_shift20 )
edge->u = RI.vrectright_adj_shift20;
@ -279,10 +279,10 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// sort the edge in normally
//
u_check = edge->u;
if (edge->surfs[0])
if( edge->surfs[0] )
u_check++; // sort trailers after leaders
if (!newedges[v] || newedges[v]->u >= u_check)
if( !newedges[v] || newedges[v]->u >= u_check )
{
edge->next = newedges[v];
newedges[v] = edge;
@ -290,7 +290,7 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
else
{
pcheck = newedges[v];
while (pcheck->next && pcheck->next->u < u_check)
while( pcheck->next && pcheck->next->u < u_check )
pcheck = pcheck->next;
edge->next = pcheck->next;
pcheck->next = edge;
@ -306,22 +306,22 @@ static void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
R_ClipEdge
================
*/
static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
static void R_ClipEdge( mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip )
{
float d0, d1, f;
mvertex_t clipvert;
if (clip)
if( clip )
{
do
{
d0 = DotProduct (pv0->position, clip->normal) - clip->dist;
d1 = DotProduct (pv1->position, clip->normal) - clip->dist;
d0 = DotProduct( pv0->position, clip->normal ) - clip->dist;
d1 = DotProduct( pv1->position, clip->normal ) - clip->dist;
if (d0 >= 0)
if( d0 >= 0 )
{
// point 0 is unclipped
if (d1 >= 0)
if( d1 >= 0 )
{
// both points are unclipped
continue;
@ -332,38 +332,38 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
// we don't cache clipped edges
cacheoffset = 0x7FFFFFFF;
f = d0 / (d0 - d1);
clipvert.position[0] = pv0->position[0] +
f * (pv1->position[0] - pv0->position[0]);
clipvert.position[1] = pv0->position[1] +
f * (pv1->position[1] - pv0->position[1]);
clipvert.position[2] = pv0->position[2] +
f * (pv1->position[2] - pv0->position[2]);
f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0]
+ f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1]
+ f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2]
+ f * ( pv1->position[2] - pv0->position[2] );
if (clip->leftedge)
if( clip->leftedge )
{
r_leftclipped = true;
r_leftexit = clipvert;
}
else if (clip->rightedge)
else if( clip->rightedge )
{
r_rightclipped = true;
r_rightexit = clipvert;
}
R_ClipEdge (pv0, &clipvert, clip->next);
R_ClipEdge( pv0, &clipvert, clip->next );
return;
}
else
{
// point 0 is clipped
if (d1 < 0)
if( d1 < 0 )
{
// both points are clipped
// we do cache fully clipped edges
if (!r_leftclipped)
cacheoffset = FULLY_CLIPPED_CACHED |
(tr.framecount & FRAMECOUNT_MASK);
if( !r_leftclipped )
cacheoffset = FULLY_CLIPPED_CACHED
| ( tr.framecount & FRAMECOUNT_MASK );
return;
}
@ -373,33 +373,34 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
// we don't cache partially clipped edges
cacheoffset = 0x7FFFFFFF;
f = d0 / (d0 - d1);
clipvert.position[0] = pv0->position[0] +
f * (pv1->position[0] - pv0->position[0]);
clipvert.position[1] = pv0->position[1] +
f * (pv1->position[1] - pv0->position[1]);
clipvert.position[2] = pv0->position[2] +
f * (pv1->position[2] - pv0->position[2]);
f = d0 / ( d0 - d1 );
clipvert.position[0] = pv0->position[0]
+ f * ( pv1->position[0] - pv0->position[0] );
clipvert.position[1] = pv0->position[1]
+ f * ( pv1->position[1] - pv0->position[1] );
clipvert.position[2] = pv0->position[2]
+ f * ( pv1->position[2] - pv0->position[2] );
if (clip->leftedge)
if( clip->leftedge )
{
r_leftclipped = true;
r_leftenter = clipvert;
}
else if (clip->rightedge)
else if( clip->rightedge )
{
r_rightclipped = true;
r_rightenter = clipvert;
}
R_ClipEdge (&clipvert, pv1, clip->next);
R_ClipEdge( &clipvert, pv1, clip->next );
return;
}
} while ((clip = clip->next) != NULL);
}
while(( clip = clip->next ) != NULL );
}
// add the edge
R_EmitEdge (pv0, pv1);
R_EmitEdge( pv0, pv1 );
}
/*
@ -407,18 +408,18 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
R_EmitCachedEdge
================
*/
static void R_EmitCachedEdge (void)
static void R_EmitCachedEdge( void )
{
edge_t *pedge_t;
pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset);
pedge_t = (edge_t *)((uintptr_t)r_edges + r_pedge->cachededgeoffset );
if (!pedge_t->surfs[0])
if( !pedge_t->surfs[0] )
pedge_t->surfs[0] = surface_p - surfaces;
else
pedge_t->surfs[1] = surface_p - surfaces;
if (pedge_t->nearzi > r_nearzi) // for mipmap finding
if( pedge_t->nearzi > r_nearzi )// for mipmap finding
r_nearzi = pedge_t->nearzi;
r_emitted = 1;
@ -430,7 +431,7 @@ static void R_EmitCachedEdge (void)
R_RenderFace
================
*/
void R_RenderFace (msurface_t *fa, int clipflags)
void R_RenderFace( msurface_t *fa, int clipflags )
{
int i, lindex;
unsigned mask;
@ -441,32 +442,32 @@ void R_RenderFace (msurface_t *fa, int clipflags)
clipplane_t *pclip;
// translucent surfaces are not drawn by the edge renderer
if (fa->flags & (SURF_DRAWTURB|SURF_TRANSPARENT))
if( fa->flags & ( SURF_DRAWTURB | SURF_TRANSPARENT ))
{
//fa->nextalphasurface = r_alpha_surfaces;
//r_alpha_surfaces = fa;
//return;
// fa->nextalphasurface = r_alpha_surfaces;
// r_alpha_surfaces = fa;
// return;
}
// sky surfaces encountered in the world will cause the
// environment box surfaces to be emited
if ( fa->flags & SURF_DRAWSKY )
if( fa->flags & SURF_DRAWSKY )
{
//R_EmitSkyBox ();
// R_EmitSkyBox ();
// return;
}
// skip out if no more surfs
if ((surface_p) >= surf_max)
if(( surface_p ) >= surf_max )
{
// r_outofsurfaces++;
return;
}
// ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + fa->numedges + 4) >= edge_max)
if(( edge_p + fa->numedges + 4 ) >= edge_max )
{
//r_outofedges += fa->numedges;
// r_outofedges += fa->numedges;
return;
}
@ -475,9 +476,9 @@ void R_RenderFace (msurface_t *fa, int clipflags)
// set up clip planes
pclip = NULL;
for (i=3, mask = 0x08 ; i>=0 ; i--, mask >>= 1)
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
{
if (clipflags & mask)
if( clipflags & mask )
{
qfrustum.view_clipplanes[i].next = pclip;
pclip = &qfrustum.view_clipplanes[i];
@ -492,21 +493,21 @@ void R_RenderFace (msurface_t *fa, int clipflags)
pedges = RI.currentmodel->edges;
r_lastvertvalid = false;
for (i=0 ; i<fa->numedges ; i++)
for( i = 0; i < fa->numedges; i++ )
{
lindex = RI.currentmodel->surfedges[fa->firstedge + i];
if (lindex > 0)
if( lindex > 0 )
{
r_pedge = &pedges[lindex];
// if the edge is cached, we can just reuse the edge
if (!insubmodel)
if( !insubmodel )
{
if (r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED)
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
{
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
tr.framecount)
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
== tr.framecount )
{
r_lastvertvalid = false;
continue;
@ -514,12 +515,12 @@ void R_RenderFace (msurface_t *fa, int clipflags)
}
else
{
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
r_pedge->cachededgeoffset) &&
(((edge_t *)((uintptr_t)r_edges +
r_pedge->cachededgeoffset))->owner == r_pedge))
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
> r_pedge->cachededgeoffset )
&& (((edge_t *)((uintptr_t)r_edges
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
{
R_EmitCachedEdge ();
R_EmitCachedEdge();
r_lastvertvalid = false;
continue;
}
@ -529,14 +530,14 @@ void R_RenderFace (msurface_t *fa, int clipflags)
// assume it's cacheable
cacheoffset = (byte *)edge_p - (byte *)r_edges;
r_leftclipped = r_rightclipped = false;
R_ClipEdge (&r_pcurrentvertbase[r_pedge->v[0]],
R_ClipEdge( &r_pcurrentvertbase[r_pedge->v[0]],
&r_pcurrentvertbase[r_pedge->v[1]],
pclip);
pclip );
r_pedge->cachededgeoffset = cacheoffset;
if (r_leftclipped)
if( r_leftclipped )
makeleftedge = true;
if (r_rightclipped)
if( r_rightclipped )
makerightedge = true;
r_lastvertvalid = true;
}
@ -545,12 +546,12 @@ void R_RenderFace (msurface_t *fa, int clipflags)
lindex = -lindex;
r_pedge = &pedges[lindex];
// if the edge is cached, we can just reuse the edge
if (!insubmodel)
if( !insubmodel )
{
if (r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED)
if( r_pedge->cachededgeoffset & FULLY_CLIPPED_CACHED )
{
if ((r_pedge->cachededgeoffset & FRAMECOUNT_MASK) ==
tr.framecount)
if(( r_pedge->cachededgeoffset & FRAMECOUNT_MASK )
== tr.framecount )
{
r_lastvertvalid = false;
continue;
@ -560,12 +561,12 @@ void R_RenderFace (msurface_t *fa, int clipflags)
{
// it's cached if the cached edge is valid and is owned
// by this medge_t
if ((((uintptr_t)edge_p - (uintptr_t)r_edges) >
r_pedge->cachededgeoffset) &&
(((edge_t *)((uintptr_t)r_edges +
r_pedge->cachededgeoffset))->owner == r_pedge))
if((((uintptr_t)edge_p - (uintptr_t)r_edges )
> r_pedge->cachededgeoffset )
&& (((edge_t *)((uintptr_t)r_edges
+ r_pedge->cachededgeoffset ))->owner == r_pedge ))
{
R_EmitCachedEdge ();
R_EmitCachedEdge();
r_lastvertvalid = false;
continue;
}
@ -575,14 +576,14 @@ void R_RenderFace (msurface_t *fa, int clipflags)
// assume it's cacheable
cacheoffset = (byte *)edge_p - (byte *)r_edges;
r_leftclipped = r_rightclipped = false;
R_ClipEdge (&r_pcurrentvertbase[r_pedge->v[1]],
R_ClipEdge( &r_pcurrentvertbase[r_pedge->v[1]],
&r_pcurrentvertbase[r_pedge->v[0]],
pclip);
pclip );
r_pedge->cachededgeoffset = cacheoffset;
if (r_leftclipped)
if( r_leftclipped )
makeleftedge = true;
if (r_rightclipped)
if( r_rightclipped )
makerightedge = true;
r_lastvertvalid = true;
}
@ -591,24 +592,24 @@ void R_RenderFace (msurface_t *fa, int clipflags)
// if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space?
// FIXME: share clipped edges?
if (makeleftedge)
if( makeleftedge )
{
r_pedge = &tedge;
r_lastvertvalid = false;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
R_ClipEdge( &r_leftexit, &r_leftenter, pclip->next );
}
// if there was a clip off the right edge, get the right r_nearzi
if (makerightedge)
if( makerightedge )
{
r_pedge = &tedge;
r_lastvertvalid = false;
r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next);
R_ClipEdge( &r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next );
}
// if no edges made it out, return without posting the surface
if (!r_emitted)
if( !r_emitted )
return;
// r_polycount++;
@ -624,15 +625,15 @@ void R_RenderFace (msurface_t *fa, int clipflags)
pplane = fa->plane;
// FIXME: cache this?
TransformVector (pplane->normal, p_normal);
TransformVector( pplane->normal, p_normal );
// FIXME: cache this?
distinv = 1.0f / (pplane->dist - DotProduct (tr.modelorg, pplane->normal));
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv -
xcenter * surface_p->d_zistepu -
ycenter * surface_p->d_zistepv;
surface_p->d_ziorigin = p_normal[2] * distinv
- xcenter * surface_p->d_zistepu
- ycenter * surface_p->d_zistepv;
surface_p++;
}
@ -643,7 +644,7 @@ void R_RenderFace (msurface_t *fa, int clipflags)
R_RenderBmodelFace
================
*/
void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
void R_RenderBmodelFace( bedge_t *pedges, msurface_t *psurf )
{
int i;
unsigned mask;
@ -661,16 +662,16 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
}*/
// skip out if no more surfs
if (surface_p >= surf_max)
if( surface_p >= surf_max )
{
//r_outofsurfaces++;
// r_outofsurfaces++;
return;
}
// ditto if not enough edges left, or switch to auxedges if possible
if ((edge_p + psurf->numedges + 4) >= edge_max)
if(( edge_p + psurf->numedges + 4 ) >= edge_max )
{
//r_outofedges += psurf->numedges;
// r_outofedges += psurf->numedges;
return;
}
@ -682,9 +683,9 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
// set up clip planes
pclip = NULL;
for (i=3, mask = 0x08 ; i>=0 ; i--, mask >>= 1)
for( i = 3, mask = 0x08; i >= 0; i--, mask >>= 1 )
{
if (r_clipflags & mask)
if( r_clipflags & mask )
{
qfrustum.view_clipplanes[i].next = pclip;
pclip = &qfrustum.view_clipplanes[i];
@ -700,39 +701,39 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
// can be used?
r_lastvertvalid = false;
for ( ; pedges ; pedges = pedges->pnext)
for( ; pedges; pedges = pedges->pnext )
{
r_leftclipped = r_rightclipped = false;
R_ClipEdge (pedges->v[0], pedges->v[1], pclip);
R_ClipEdge( pedges->v[0], pedges->v[1], pclip );
if (r_leftclipped)
if( r_leftclipped )
makeleftedge = true;
if (r_rightclipped)
if( r_rightclipped )
makerightedge = true;
}
// if there was a clip off the left edge, add that edge too
// FIXME: faster to do in screen space?
// FIXME: share clipped edges?
if (makeleftedge)
if( makeleftedge )
{
r_pedge = &tedge;
R_ClipEdge (&r_leftexit, &r_leftenter, pclip->next);
R_ClipEdge( &r_leftexit, &r_leftenter, pclip->next );
}
// if there was a clip off the right edge, get the right r_nearzi
if (makerightedge)
if( makerightedge )
{
r_pedge = &tedge;
r_nearzionly = true;
R_ClipEdge (&r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next);
R_ClipEdge( &r_rightexit, &r_rightenter, qfrustum.view_clipplanes[1].next );
}
// if no edges made it out, return without posting the surface
if (!r_emitted)
if( !r_emitted )
return;
//r_polycount++;
// r_polycount++;
surface_p->msurf = psurf;
surface_p->nearzi = r_nearzi;
@ -745,15 +746,15 @@ void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
pplane = psurf->plane;
// FIXME: cache this?
TransformVector (pplane->normal, p_normal);
TransformVector( pplane->normal, p_normal );
// FIXME: cache this?
distinv = 1.0f / (pplane->dist - DotProduct (tr.modelorg, pplane->normal));
distinv = 1.0f / ( pplane->dist - DotProduct( tr.modelorg, pplane->normal ));
surface_p->d_zistepu = p_normal[0] * xscaleinv * distinv;
surface_p->d_zistepv = -p_normal[1] * yscaleinv * distinv;
surface_p->d_ziorigin = p_normal[2] * distinv -
xcenter * surface_p->d_zistepu -
ycenter * surface_p->d_zistepv;
surface_p->d_ziorigin = p_normal[2] * distinv
- xcenter * surface_p->d_zistepu
- ycenter * surface_p->d_zistepv;
surface_p++;
}

File diff suppressed because it is too large Load diff

View file

@ -80,7 +80,7 @@ static const byte *R_SpriteLoadFrame( model_t *mod, const void *pin, mspritefram
pspriteframe->gl_texturenum = gl_texturenum;
*ppframe = pspriteframe;
return ( const byte* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
return (const byte *)((const byte *)pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
}
/*
@ -102,12 +102,12 @@ static const void *R_SpriteLoadGroup( model_t *mod, const void *pin, mspritefram
pingroup = (const dspritegroup_t *)pin;
numframes = pingroup->numframes;
groupsize = sizeof( mspritegroup_t ) + (numframes - 1) * sizeof( pspritegroup->frames[0] );
groupsize = sizeof( mspritegroup_t ) + ( numframes - 1 ) * sizeof( pspritegroup->frames[0] );
pspritegroup = Mem_Calloc( mod->mempool, groupsize );
pspritegroup->numframes = numframes;
*ppframe = (mspriteframe_t *)pspritegroup;
pin_intervals = (const dspriteinterval_t *)(pingroup + 1);
pin_intervals = (const dspriteinterval_t *)( pingroup + 1 );
poutintervals = Mem_Calloc( mod->mempool, numframes * sizeof( float ));
pspritegroup->intervals = poutintervals;
@ -150,7 +150,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
if( pin->version == SPRITE_VERSION_Q1 || pin->version == SPRITE_VERSION_32 )
numi = NULL;
else if( pin->version == SPRITE_VERSION_HL )
numi = (const short *)((const byte*)buffer + sizeof( dsprite_hl_t ));
numi = (const short *)((const byte *)buffer + sizeof( dsprite_hl_t ));
r_texFlags = texFlags;
sprite_version = pin->version;
@ -162,12 +162,12 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
rgbdata_t *pal;
pal = gEngfuncs.FS_LoadImage( "#id.pal", (byte *)&i, 768 );
pframetype = ((const byte*)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
pframetype = ((const byte *)buffer + sizeof( dsprite_q1_t )); // pinq1 + 1
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
}
else if( *numi == 256 )
{
const byte *src = (const byte *)(numi+1);
const byte *src = (const byte *)( numi + 1 );
rgbdata_t *pal;
// install palette
@ -184,7 +184,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
break;
}
pframetype = (const byte *)(src + 768);
pframetype = (const byte *)( src + 768 );
gEngfuncs.FS_FreeImage( pal ); // palette installed, no reason to keep this data
}
else
@ -220,10 +220,12 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
pframetype = R_SpriteLoadGroup( mod, pframetype + sizeof( dframetype_t ), &psprite->frames[i].frameptr, i );
break;
}
if( pframetype == NULL ) break; // technically an error
if( pframetype == NULL )
break; // technically an error
}
if( loaded ) *loaded = true; // done
if( loaded )
*loaded = true; // done
}
/*
@ -305,13 +307,13 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
pintervals = pspritegroup->intervals;
numframes = pspritegroup->numframes;
fullinterval = pintervals[numframes-1];
fullinterval = pintervals[numframes - 1];
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by zero
targettime = gp_cl->time - ((int)( gp_cl->time / fullinterval )) * fullinterval;
for( i = 0; i < (numframes - 1); i++ )
for( i = 0; i < ( numframes - 1 ); i++ )
{
if( pintervals[i] > targettime )
break;
@ -320,7 +322,7 @@ mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw )
}
else if( psprite->frames[frame].type == FRAME_ANGLED )
{
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
int angleframe = (int)( Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8 ) - 4 ) & 7;
// e.g. doom-style sprite monsters
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
@ -352,7 +354,7 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
lerpFrac = 1.0f;
// misc info
m_fDoInterp = (ent->curstate.effects & EF_NOINTERP) ? false : true;
m_fDoInterp = ( ent->curstate.effects & EF_NOINTERP ) ? false : true;
if( frame < 0 )
{
@ -386,7 +388,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * 11.0f;
else
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * 11.0f;
}
else
{
@ -410,26 +413,28 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
}
// get the interpolated frames
if( oldframe ) *oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe ) *curframe = psprite->frames[frame].frameptr;
if( oldframe )
*oldframe = psprite->frames[ent->latched.prevblending[0]].frameptr;
if( curframe )
*curframe = psprite->frames[frame].frameptr;
}
else if( psprite->frames[frame].type == FRAME_GROUP )
{
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
pintervals = pspritegroup->intervals;
numframes = pspritegroup->numframes;
fullinterval = pintervals[numframes-1];
fullinterval = pintervals[numframes - 1];
jinterval = pintervals[1] - pintervals[0];
time = gp_cl->time;
jtime = 0.0f;
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by zero
targettime = time - ((int)(time / fullinterval)) * fullinterval;
targettime = time - ((int)( time / fullinterval )) * fullinterval;
// LordHavoc: since I can't measure the time properly when it loops from numframes - 1 to 0,
// i instead measure the time of the first frame, hoping it is consistent
for( i = 0, j = numframes - 1; i < (numframes - 1); i++ )
for( i = 0, j = numframes - 1; i < ( numframes - 1 ); i++ )
{
if( pintervals[i] > targettime )
break;
@ -439,18 +444,21 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
}
if( m_fDoInterp )
lerpFrac = (targettime - jtime) / jinterval;
else j = i; // no lerping
lerpFrac = ( targettime - jtime ) / jinterval;
else
j = i; // no lerping
// get the interpolated frames
if( oldframe ) *oldframe = pspritegroup->frames[j];
if( curframe ) *curframe = pspritegroup->frames[i];
if( oldframe )
*oldframe = pspritegroup->frames[j];
if( curframe )
*curframe = pspritegroup->frames[i];
}
else if( psprite->frames[frame].type == FRAME_ANGLED )
{
// e.g. doom-style sprite monsters
float yaw = ent->angles[YAW];
int angleframe = (int)(Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8) - 4) & 7;
int angleframe = (int)( Q_rint(( RI.viewangles[1] - yaw + 45.0f ) / 360 * 8 ) - 4 ) & 7;
if( m_fDoInterp )
{
@ -472,7 +480,8 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
ent->latched.sequencetime = gp_cl->time;
lerpFrac = 0.0f;
}
else lerpFrac = (gp_cl->time - ent->latched.sequencetime) * ent->curstate.framerate;
else
lerpFrac = ( gp_cl->time - ent->latched.sequencetime ) * ent->curstate.framerate;
}
else
{
@ -488,10 +497,12 @@ static float R_GetSpriteFrameInterpolant( cl_entity_t *ent, mspriteframe_t **old
}
pspritegroup = (mspritegroup_t *)psprite->frames[ent->latched.prevblending[0]].frameptr;
if( oldframe ) *oldframe = pspritegroup->frames[angleframe];
if( oldframe )
*oldframe = pspritegroup->frames[angleframe];
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
if( curframe ) *curframe = pspritegroup->frames[angleframe];
if( curframe )
*curframe = pspritegroup->frames[angleframe];
}
return lerpFrac;
@ -545,7 +556,7 @@ static float R_SpriteGlowBlend( vec3_t origin, int rendermode, int renderfx, flo
if( RP_NORMALPASS( ))
{
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : (PM_GLASS_IGNORE|PM_STUDIO_IGNORE));
tr = gEngfuncs.EV_VisTraceLine( RI.vieworg, origin, r_traceglow.value ? PM_GLASS_IGNORE : ( PM_GLASS_IGNORE | PM_STUDIO_IGNORE ));
if(( 1.0f - tr->fraction ) * dist > 8.0f )
return 0.0f;
@ -702,7 +713,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
return;
model = e->model;
psprite = (msprite_t * )model->cache.data;
psprite = (msprite_t *)model->cache.data;
VectorCopy( e->origin, origin ); // set render origin
// do movewith
@ -717,14 +728,16 @@ void R_DrawSpriteModel( cl_entity_t *e )
if( parent->model->type == mod_studio && e->curstate.body > 0 )
{
int num = bound( 1, e->curstate.body, MAXSTUDIOATTACHMENTS );
VectorCopy( parent->attachment[num-1], origin );
VectorCopy( parent->attachment[num - 1], origin );
}
else VectorCopy( parent->origin, origin );
else
VectorCopy( parent->origin, origin );
}
}
scale = e->curstate.scale;
if( !scale ) scale = 1.0f;
if( !scale )
scale = 1.0f;
if( R_SpriteOccluded( e, origin, &scale ))
return; // sprite culled
@ -763,7 +776,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
if( R_SpriteAllowLerping( e, psprite ))
lerp = R_GetSpriteFrameInterpolant( e, &oldframe, &frame );
else frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
else
frame = oldframe = R_GetSpriteFrame( model, e->curstate.frame, e->angles[YAW] );
type = psprite->type;
@ -779,7 +793,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
VectorSubtract( origin, v_forward, origin );
break;
case SPR_FACING_UPRIGHT:
VectorSet( v_right, origin[1] - RI.vieworg[1], -(origin[0] - RI.vieworg[0]), 0.0f );
VectorSet( v_right, origin[1] - RI.vieworg[1], -( origin[0] - RI.vieworg[0] ), 0.0f );
VectorSet( v_up, 0.0f, 0.0f, 1.0f );
VectorNormalize( v_right );
break;
@ -792,11 +806,11 @@ void R_DrawSpriteModel( cl_entity_t *e )
VectorNormalize( v_right );
break;
case SPR_FWD_PARALLEL_ORIENTED:
angle = e->angles[ROLL] * (M_PI2 / 360.0f);
angle = e->angles[ROLL] * ( M_PI2 / 360.0f );
SinCos( angle, &sr, &cr );
for( i = 0; i < 3; i++ )
{
v_right[i] = (RI.vright[i] * cr + RI.vup[i] * sr);
v_right[i] = ( RI.vright[i] * cr + RI.vup[i] * sr );
v_up[i] = RI.vright[i] * -sr + RI.vup[i] * cr;
}
break;
@ -807,8 +821,8 @@ void R_DrawSpriteModel( cl_entity_t *e )
break;
}
//if( psprite->facecull == SPR_CULL_NONE )
//GL_Cull( GL_NONE );
// if( psprite->facecull == SPR_CULL_NONE )
// GL_Cull( GL_NONE );
if( oldframe == frame )
{

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -24,8 +24,8 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
};
void R_AliasSetUpTransform (void);
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv);
void R_AliasSetUpTransform( void );
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv );
void R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, dtrivertx_t *oldv, dtrivertx_t *newv );
@ -41,7 +41,7 @@ R_AliasCheckBBox
#define BBOX_MUST_CLIP_Z 2
#define BBOX_TRIVIAL_REJECT 8
static void VectorInverse (vec3_t v)
static void VectorInverse( vec3_t v )
{
v[0] = -v[0];
v[1] = -v[1];
@ -53,7 +53,7 @@ static void VectorInverse (vec3_t v)
R_SetUpWorldTransform
================
*/
void R_SetUpWorldTransform (void)
void R_SetUpWorldTransform( void )
{
int i;
static float viewmatrix[3][4];
@ -72,10 +72,10 @@ void R_SetUpWorldTransform (void)
// TODO: can do this with simple matrix rearrangement
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ) );
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ) );
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ));
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ));
for (i=0 ; i<3 ; i++)
for( i = 0; i < 3; i++ )
{
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
aliasoldworldtransform[i][0] = aliasworldtransform[i][1] = -s_alias_right[i];
@ -86,9 +86,9 @@ void R_SetUpWorldTransform (void)
aliasworldtransform[1][3] = -RI.vieworg[1];
aliasworldtransform[2][3] = -RI.vieworg[2];
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
// FIXME: can do more efficiently than full concatenation
// memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) );
@ -96,11 +96,11 @@ void R_SetUpWorldTransform (void)
// R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
// TODO: should be global, set when vright, etc., set
VectorCopy (RI.vright, viewmatrix[0]);
VectorCopy (RI.vup, viewmatrix[1]);
VectorInverse (viewmatrix[1]);
//VectorScale(viewmatrix[1], -1, viewmatrix[1]);
VectorCopy (RI.vforward, viewmatrix[2]);
VectorCopy( RI.vright, viewmatrix[0] );
VectorCopy( RI.vup, viewmatrix[1] );
VectorInverse( viewmatrix[1] );
// VectorScale(viewmatrix[1], -1, viewmatrix[1]);
VectorCopy( RI.vforward, viewmatrix[2] );
viewmatrix[0][3] = 0;
viewmatrix[1][3] = 0;
@ -108,16 +108,16 @@ void R_SetUpWorldTransform (void)
// memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) );
//R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
Matrix3x4_ConcatTransforms(aliastransform, viewmatrix, aliasworldtransform );
// R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
Matrix3x4_ConcatTransforms( aliastransform, viewmatrix, aliasworldtransform );
aliasworldtransform[0][3] = 0;
aliasworldtransform[1][3] = 0;
aliasworldtransform[2][3] = 0;
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
}
@ -126,7 +126,7 @@ void R_SetUpWorldTransform (void)
R_AliasSetUpTransform
================
*/
void R_AliasSetUpTransform (void)
void R_AliasSetUpTransform( void )
{
int i;
static float viewmatrix[3][4];
@ -145,23 +145,23 @@ void R_AliasSetUpTransform (void)
// TODO: can do this with simple matrix rearrangement
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ) );
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ) );
memset( aliasworldtransform, 0, sizeof( aliasworldtransform ));
memset( aliasoldworldtransform, 0, sizeof( aliasworldtransform ));
for (i=0 ; i<3 ; i++)
for( i = 0; i < 3; i++ )
{
aliasoldworldtransform[i][0] = aliasworldtransform[i][0] = s_alias_forward[i];
aliasoldworldtransform[i][0] = aliasworldtransform[i][1] = -s_alias_right[i];
aliasoldworldtransform[i][0] = aliasworldtransform[i][2] = s_alias_up[i];
}
aliasworldtransform[0][3] = RI.currententity->origin[0]-RI.vieworg[0];
aliasworldtransform[1][3] = RI.currententity->origin[1]-RI.vieworg[1];
aliasworldtransform[2][3] = RI.currententity->origin[2]-RI.vieworg[2];
aliasworldtransform[0][3] = RI.currententity->origin[0] - RI.vieworg[0];
aliasworldtransform[1][3] = RI.currententity->origin[1] - RI.vieworg[1];
aliasworldtransform[2][3] = RI.currententity->origin[2] - RI.vieworg[2];
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0]-r_origin[0];
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1]-r_origin[1];
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2]-r_origin[2];
// FIXME: can do more efficiently than full concatenation
// memcpy( rotationmatrix, t2matrix, sizeof( rotationmatrix ) );
@ -169,11 +169,11 @@ void R_AliasSetUpTransform (void)
// R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
// TODO: should be global, set when vright, etc., set
VectorCopy (RI.vright, viewmatrix[0]);
VectorCopy (RI.vup, viewmatrix[1]);
VectorInverse (viewmatrix[1]);
//VectorScale(viewmatrix[1], -1, viewmatrix[1]);
VectorCopy (RI.vforward, viewmatrix[2]);
VectorCopy( RI.vright, viewmatrix[0] );
VectorCopy( RI.vup, viewmatrix[1] );
VectorInverse( viewmatrix[1] );
// VectorScale(viewmatrix[1], -1, viewmatrix[1]);
VectorCopy( RI.vforward, viewmatrix[2] );
viewmatrix[0][3] = 0;
viewmatrix[1][3] = 0;
@ -181,16 +181,16 @@ void R_AliasSetUpTransform (void)
// memcpy( aliasworldtransform, rotationmatrix, sizeof( aliastransform ) );
//R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
Matrix3x4_ConcatTransforms(aliastransform, viewmatrix, aliasworldtransform );
// R_ConcatTransforms (viewmatrix, aliasworldtransform, aliastransform);
Matrix3x4_ConcatTransforms( aliastransform, viewmatrix, aliasworldtransform );
aliasworldtransform[0][3] = RI.currententity->origin[0];
aliasworldtransform[1][3] = RI.currententity->origin[1];
aliasworldtransform[2][3] = RI.currententity->origin[2];
//aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
//aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
//aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
// aliasoldworldtransform[0][3] = RI.currententity->oldorigin[0];
// aliasoldworldtransform[1][3] = RI.currententity->oldorigin[1];
// aliasoldworldtransform[2][3] = RI.currententity->oldorigin[2];
}
/*
@ -211,16 +211,16 @@ void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
fv->zi = zi * s_ziscale;
fv->u = (x * aliasxscale * zi) + aliasxcenter;
fv->v = (y * aliasyscale * zi) + aliasycenter;
fv->u = ( x * aliasxscale * zi ) + aliasxcenter;
fv->v = ( y * aliasyscale * zi ) + aliasycenter;
if (fv->u < RI.aliasvrect.x)
if( fv->u < RI.aliasvrect.x )
fv->flags |= ALIAS_LEFT_CLIP;
if (fv->v < RI.aliasvrect.y)
if( fv->v < RI.aliasvrect.y )
fv->flags |= ALIAS_TOP_CLIP;
if (fv->u > RI.aliasvrectright)
if( fv->u > RI.aliasvrectright )
fv->flags |= ALIAS_RIGHT_CLIP;
if (fv->v > RI.aliasvrectbottom)
if( fv->v > RI.aliasvrectbottom )
fv->flags |= ALIAS_BOTTOM_CLIP;
}
@ -228,15 +228,15 @@ void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, in
{
vec3_t v = {x, y, z};
fv->xyz[0] = DotProduct(v, aliastransform[0]) + aliastransform[0][3];
fv->xyz[1] = DotProduct(v, aliastransform[1]) + aliastransform[1][3];
fv->xyz[2] = DotProduct(v, aliastransform[2]) + aliastransform[2][3];
fv->xyz[0] = DotProduct( v, aliastransform[0] ) + aliastransform[0][3];
fv->xyz[1] = DotProduct( v, aliastransform[1] ) + aliastransform[1][3];
fv->xyz[2] = DotProduct( v, aliastransform[2] ) + aliastransform[2][3];
fv->flags = 0;
fv->l = light;
if ( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
if( fv->xyz[2] < ALIAS_Z_CLIP_PLANE )
{
fv->flags |= ALIAS_Z_CLIP;
}
@ -252,10 +252,10 @@ void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, in
void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
{
if ( fv1->flags & fv2->flags & fv3->flags )
return ; // completely clipped
if( fv1->flags & fv2->flags & fv3->flags )
return; // completely clipped
if ( ! (fv1->flags | fv2->flags | fv3->flags) )
if( !( fv1->flags | fv2->flags | fv3->flags ))
{ // totally unclipped
aliastriangleparms.a = fv1;
aliastriangleparms.b = fv2;
@ -265,7 +265,7 @@ void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
}
else
{ // partially clipped
R_AliasClipTriangle (fv1, fv2, fv3);
R_AliasClipTriangle( fv1, fv2, fv3 );
}
}

View file

@ -82,16 +82,16 @@ _TriColor4f
*/
void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
{
//pglColor4f( r, g, b, a );
unsigned short r,g,b;
// pglColor4f( r, g, b, a );
unsigned short r, g, b;
unsigned int major, minor;
if( vid.rendermode == kRenderTransAdd || vid.rendermode == kRenderGlow )
rr *= aa, gg *= aa, bb *= aa;
//gEngfuncs.Con_Printf("%d\n", vid.alpha);
// gEngfuncs.Con_Printf("%d\n", vid.alpha);
light = (rr + gg + bb) * 31 / 3;
light = ( rr + gg + bb ) * 31 / 3;
if( light > 31 )
light = 31;
@ -116,12 +116,12 @@ void GAME_EXPORT _TriColor4f( float rr, float gg, float bb, float aa )
b = 31;
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
major = ((( r >> 2 ) & MASK( 3 )) << 5 ) | (((( g >> 3 ) & MASK( 3 )) << 2 )) | ((( b >> 3 ) & MASK( 2 )));
// save minor GBRGBRGB
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
minor = MOVE_BIT( r, 1, 5 ) | MOVE_BIT( r, 0, 2 ) | MOVE_BIT( g, 2, 7 ) | MOVE_BIT( g, 1, 4 ) | MOVE_BIT( g, 0, 1 ) | MOVE_BIT( b, 2, 6 ) | MOVE_BIT( b, 1, 3 ) | MOVE_BIT( b, 0, 0 );
vid.color = major << 8 | (minor & 0xFF);
vid.color = major << 8 | ( minor & 0xFF );
}
/*
@ -132,10 +132,10 @@ TriColor4ub
*/
void TriColor4ub( byte r, byte g, byte b, byte a )
{
ds.triRGBA[0] = r * (1.0f / 255.0f);
ds.triRGBA[1] = g * (1.0f / 255.0f);
ds.triRGBA[2] = b * (1.0f / 255.0f);
ds.triRGBA[3] = a * (1.0f / 255.0f);
ds.triRGBA[0] = r * ( 1.0f / 255.0f );
ds.triRGBA[1] = g * ( 1.0f / 255.0f );
ds.triRGBA[2] = b * ( 1.0f / 255.0f );
ds.triRGBA[3] = a * ( 1.0f / 255.0f );
_TriColor4f( ds.triRGBA[0], ds.triRGBA[1], ds.triRGBA[2], 1.0f );
}
@ -148,10 +148,10 @@ TriColor4ub
*/
void GAME_EXPORT _TriColor4ub( byte r, byte g, byte b, byte a )
{
_TriColor4f( r * (1.0f / 255.0f),
g * (1.0f / 255.0f),
b * (1.0f / 255.0f),
a * (1.0f / 255.0f));
_TriColor4f( r * ( 1.0f / 255.0f ),
g * ( 1.0f / 255.0f ),
b * ( 1.0f / 255.0f ),
a * ( 1.0f / 255.0f ));
}
/*
@ -161,11 +161,12 @@ TriColor4f
*/
void TriColor4f( float r, float g, float b, float a )
{
//if( a < 0.5 )
// if( a < 0.5 )
// a = 1;
if( ds.renderMode == kRenderTransAlpha )
TriColor4ub( r * 255.0f, g * 255.0f, b * 255.0f, a * 255.0f );
else _TriColor4f( r * a, g * a, b * a, 1.0 );
else
_TriColor4f( r * a, g * a, b * a, 1.0 );
ds.triRGBA[0] = r;
ds.triRGBA[1] = g;
@ -182,8 +183,8 @@ TriTexCoord2f
void GAME_EXPORT TriTexCoord2f( float u, float v )
{
double u1 = 0, v1 = 0;
u = fmodf(u, 10);
v = fmodf(v, 10);
u = fmodf( u, 10 );
v = fmodf( v, 10 );
if( u < 1000 && u > -1000 )
u1 = u;
if( v < 1000 && v > -1000 )
@ -199,8 +200,8 @@ void GAME_EXPORT TriTexCoord2f( float u, float v )
v1 = v1 - 1;
s = r_affinetridesc.skinwidth * bound(0.01,u1,0.99);
t = r_affinetridesc.skinheight * bound(0.01,v1,0.99);
s = r_affinetridesc.skinwidth * bound( 0.01, u1, 0.99 );
t = r_affinetridesc.skinheight * bound( 0.01, v1, 0.99 );
}
/*
@ -224,35 +225,35 @@ void GAME_EXPORT TriVertex3f( float x, float y, float z )
{
if( mode == TRI_TRIANGLES )
{
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8,s,t);
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8, s, t );
vertcount++;
if( vertcount == 3 )
{
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
//R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
// R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
vertcount = 0;
}
}
if( mode == TRI_TRIANGLE_FAN )
{
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8,s,t);
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8, s, t );
vertcount++;
if( vertcount >= 3 )
{
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
//R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
// R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
triv[1] = triv[2];
vertcount = 2;
}
}
if( mode == TRI_TRIANGLE_STRIP )
{
R_SetupFinalVert( &triv[n], x, y, z, light << 8,s,t);
R_SetupFinalVert( &triv[n], x, y, z, light << 8, s, t );
n++;
vertcount++;
if( n == 3 )
n = 0;
if (vertcount >= 3)
if( vertcount >= 3 )
{
if( vertcount & 1 )
R_RenderTriangle( &triv[0], &triv[1], &triv[2] );