ref: soft: remove dead, commented out code

This commit is contained in:
Alibek Omarov 2024-11-06 02:17:06 +03:00
parent 38e8a581b6
commit 659adca473
17 changed files with 17 additions and 2601 deletions

View file

@ -59,9 +59,6 @@ static void R_Alias_clip_z (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *o
R_AliasProjectAndClipTestFinalVert (out);
}
#if !id386
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out)
{
float scale;
@ -90,7 +87,6 @@ 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)
{
float scale;
@ -119,7 +115,6 @@ void R_Alias_clip_right (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;
@ -148,7 +143,6 @@ 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)
{
@ -180,9 +174,6 @@ void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
}
}
#endif
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) )
{
@ -222,7 +213,6 @@ static int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
return k;
}
/*
================
R_AliasClipTriangle

View file

@ -169,180 +169,7 @@ void R_RotateBmodel (void)
R_TransformFrustum ();
}
#if 0
/*
================
R_RecursiveClipBPoly
Clip a bmodel poly down the world bsp tree
================
*/
void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
float dist, frac, lastdist;
mplane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
mnode_t *pn;
int area;
psideedges[0] = psideedges[1] = NULL;
makeclippededge = false;
// 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);
// clip edges to BSP plane
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;
if (lastdist > 0)
lastside = 0;
else
lastside = 1;
pvert = pedges->v[1];
dist = DotProduct (pvert->position, tplane.normal) - tplane.dist;
if (dist > 0)
side = 0;
else
side = 1;
if (side != lastside)
{
// clipped
if (numbverts >= MAX_BMODEL_VERTS)
return;
// generate the clipped vertex
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]);
// 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))
{
gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
return;
}
ptedge = &pbedges[numbedges];
ptedge->pnext = psideedges[lastside];
psideedges[lastside] = ptedge;
ptedge->v[0] = plastvert;
ptedge->v[1] = ptvert;
ptedge = &pbedges[numbedges + 1];
ptedge->pnext = psideedges[side];
psideedges[side] = ptedge;
ptedge->v[0] = ptvert;
ptedge->v[1] = pvert;
numbedges += 2;
if (side == 0)
{
// entering for front, exiting for back
pfrontenter = ptvert;
makeclippededge = true;
}
else
{
pfrontexit = ptvert;
makeclippededge = true;
}
}
else
{
// add the edge to the appropriate side
pedges->pnext = psideedges[side];
psideedges[side] = pedges;
}
}
// if anything was clipped, reconstitute and add the edges along the clip
// plane to both sides (but in opposite directions)
if (makeclippededge)
{
if (numbedges >= (MAX_BMODEL_EDGES - 2))
{
gEngfuncs.Con_Printf ("Out of edges for bmodel\n");
return;
}
ptedge = &pbedges[numbedges];
ptedge->pnext = psideedges[0];
psideedges[0] = ptedge;
ptedge->v[0] = pfrontexit;
ptedge->v[1] = pfrontenter;
ptedge = &pbedges[numbedges + 1];
ptedge->pnext = psideedges[1];
psideedges[1] = ptedge;
ptedge->v[0] = pfrontenter;
ptedge->v[1] = pfrontexit;
numbedges += 2;
}
// draw or recurse further
for (i=0 ; i<2 ; 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 == r_visframecount)
{
if (pn->contents < 0)
{
if (pn->contents != CONTENTS_SOLID)
{
r_currentbkey = ((mleaf_t *)pn)->cluster;
R_RenderBmodelFace (psideedges[i], psurf);
}
}
else
{
R_RecursiveClipBPoly (psideedges[i], pnode->children[i],
psurf);
}
}
}
}
}
#else
/*
================
R_RecursiveClipBPoly
@ -512,128 +339,6 @@ static void R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *p
}
}
}
#endif
#if 0
/*
================
R_DrawSolidClippedSubmodelPolygons
================
*/
void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
{
int i, j, lindex;
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
mvertex_t bverts[MAX_BMODEL_VERTS];
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
medge_t *pedge, *pedges;
// FIXME: use bounding-box-based frustum clipping info?
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;
pedges = pmodel->edges;
for (i=0 ; i<numsurfaces ; i++, psurf++)
{
// find which side of the node we are on
pplane = psurf->plane;
dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
// draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
{
// FIXME: use bounding-box-based frustum clipping info?
// copy the edges to bedges, flipping if necessary so always
// clockwise winding
// FIXME: if edges and vertices get caches, these assignments must move
// outside the loop, and overflow checking must be done here
pbverts = bverts;
pbedges = bedges;
numbverts = numbedges = 0;
if (psurf->numedges > 0)
{
pbedge = &bedges[numbedges];
numbedges += psurf->numedges;
for (j=0 ; j<psurf->numedges ; j++)
{
lindex = pmodel->surfedges[psurf->firstedge+j];
if (lindex > 0)
{
pedge = &pedges[lindex];
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[0]];
pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[1]];
}
else
{
lindex = -lindex;
pedge = &pedges[lindex];
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[1]];
pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[0]];
}
pbedge[j].pnext = &pbedge[j+1];
}
pbedge[j-1].pnext = NULL; // mark end of edges
R_RecursiveClipBPoly (pbedge, RI.currententity->topnode, psurf);
}
else
{
gEngfuncs.Host_Error ("no edges in bmodel");
}
}
}
}
/*
================
R_DrawSubmodelPolygons
================
*/
void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
{
int i;
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
// FIXME: use bounding-box-based frustum clipping info?
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;
for (i=0 ; i<numsurfaces ; i++, psurf++)
{
// find which side of the node we are on
pplane = psurf->plane;
dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
// draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
{
r_currentkey = ((mleaf_t *)RI.currententity->topnode)->cluster;
// FIXME: use bounding-box-based frustum clipping info?
R_RenderFace (psurf, clipflags);
}
}
}
#else
/*
================
@ -767,10 +472,6 @@ void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode)
}
}
#endif
int c_drawnode;
#if XASH_LOW_MEMORY
unsigned short r_leafkeys[MAX_MAP_LEAFS];
#else
@ -946,8 +647,6 @@ void R_RenderWorld (void)
if ( !RI.drawWorld )
return;
c_drawnode=0;
// auto cycle the world frame for texture animation
RI.currententity = CL_GetEntityByIndex(0);
//RI.currententity->frame = (int)(gp_cl->time*2);

View file

@ -153,28 +153,6 @@ void R_DecalComputeBasis( msurface_t *surf, int flags, vec3_t textureSpaceBasis[
else VectorCopy( surf->plane->normal, surfaceNormal );
VectorNormalize2( surfaceNormal, textureSpaceBasis[2] );
#if 0
if( FBitSet( flags, FDECAL_CUSTOM ))
{
vec3_t pSAxis = { 1, 0, 0 };
// T = S cross N
CrossProduct( pSAxis, textureSpaceBasis[2], textureSpaceBasis[1] );
// Name sure they aren't parallel or antiparallel
// In that case, fall back to the normal algorithm.
if( DotProduct( textureSpaceBasis[1], textureSpaceBasis[1] ) > 1e-6 )
{
// S = N cross T
CrossProduct( textureSpaceBasis[2], textureSpaceBasis[1], textureSpaceBasis[0] );
VectorNormalizeFast( textureSpaceBasis[0] );
VectorNormalizeFast( textureSpaceBasis[1] );
return;
}
// Fall through to the standard algorithm for parallel or antiparallel
}
#endif
VectorNormalize2( surf->texinfo->vecs[0], textureSpaceBasis[0] );
VectorNormalize2( surf->texinfo->vecs[1], textureSpaceBasis[1] );
}
@ -888,213 +866,6 @@ float * GAME_EXPORT R_DecalSetupVerts( decal_t *pDecal, msurface_t *surf, int te
return v;
}
#if 0
void DrawSingleDecal( decal_t *pDecal, msurface_t *fa )
{
float *v;
int i, numVerts;
v = R_DecalSetupVerts( pDecal, fa, pDecal->texture, &numVerts );
if( !numVerts ) return;
GL_Bind( XASH_TEXTURE0, pDecal->texture );
pglBegin( GL_POLYGON );
for( i = 0; i < numVerts; i++, v += VERTEXSIZE )
{
pglTexCoord2f( v[3], v[4] );
pglVertex3fv( v );
}
pglEnd();
}
void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse )
{
decal_t *p;
cl_entity_t *e;
if( !fa->pdecals ) return;
e = RI.currententity;
Assert( e != NULL );
if( single )
{
if( e->curstate.rendermode == kRenderNormal || e->curstate.rendermode == kRenderTransAlpha )
{
pglDepthMask( GL_FALSE );
pglEnable( GL_BLEND );
if( e->curstate.rendermode == kRenderTransAlpha )
pglDisable( GL_ALPHA_TEST );
}
if( e->curstate.rendermode == kRenderTransColor )
pglEnable( GL_TEXTURE_2D );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_NONE );
if( gl_polyoffset->value )
{
pglEnable( GL_POLYGON_OFFSET_FILL );
pglPolygonOffset( -1.0f, -gl_polyoffset->value );
}
}
if( FBitSet( fa->flags, SURF_TRANSPARENT ) && glState.stencilEnabled )
{
mtexinfo_t *tex = fa->texinfo;
for( p = fa->pdecals; p; p = p->pnext )
{
if( p->texture )
{
float *o, *v;
int i, numVerts;
o = R_DecalSetupVerts( p, fa, p->texture, &numVerts );
pglEnable( GL_STENCIL_TEST );
pglStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFF );
pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
pglStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
pglBegin( GL_POLYGON );
for( i = 0, v = o; i < numVerts; i++, v += VERTEXSIZE )
{
v[5] = ( DotProduct( v, tex->vecs[0] ) + tex->vecs[0][3] ) / tex->texture->width;
v[6] = ( DotProduct( v, tex->vecs[1] ) + tex->vecs[1][3] ) / tex->texture->height;
pglTexCoord2f( v[5], v[6] );
pglVertex3fv( v );
}
pglEnd();
pglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
pglEnable( GL_ALPHA_TEST );
pglBegin( GL_POLYGON );
for( i = 0, v = o; i < numVerts; i++, v += VERTEXSIZE )
{
pglTexCoord2f( v[5], v[6] );
pglVertex3fv( v );
}
pglEnd();
pglDisable( GL_ALPHA_TEST );
pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
pglStencilFunc( GL_EQUAL, 0, 0xFFFFFFFF );
pglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
}
}
}
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
if( reverse && e->curstate.rendermode == kRenderTransTexture )
{
decal_t *list[1024];
int i, count;
for( p = fa->pdecals, count = 0; p && count < 1024; p = p->pnext )
if( p->texture ) list[count++] = p;
for( i = count - 1; i >= 0; i-- )
DrawSingleDecal( list[i], fa );
}
else
{
for( p = fa->pdecals; p; p = p->pnext )
{
if( !p->texture ) continue;
DrawSingleDecal( p, fa );
}
}
if( FBitSet( fa->flags, SURF_TRANSPARENT ) && glState.stencilEnabled )
pglDisable( GL_STENCIL_TEST );
if( single )
{
if( e->curstate.rendermode == kRenderNormal || e->curstate.rendermode == kRenderTransAlpha )
{
pglDepthMask( GL_TRUE );
pglDisable( GL_BLEND );
if( e->curstate.rendermode == kRenderTransAlpha )
pglEnable( GL_ALPHA_TEST );
}
if( gl_polyoffset->value )
pglDisable( GL_POLYGON_OFFSET_FILL );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_FRONT );
if( e->curstate.rendermode == kRenderTransColor )
pglDisable( GL_TEXTURE_2D );
// restore blendfunc here
if( e->curstate.rendermode == kRenderTransAdd || e->curstate.rendermode == kRenderGlow )
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
}
}
void DrawDecalsBatch( void )
{
cl_entity_t *e;
int i;
if( !tr.num_draw_decals )
return;
e = RI.currententity;
Assert( e != NULL );
if( e->curstate.rendermode != kRenderTransTexture )
{
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglDepthMask( GL_FALSE );
}
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_NONE );
if( gl_polyoffset->value )
{
pglEnable( GL_POLYGON_OFFSET_FILL );
pglPolygonOffset( -1.0f, -gl_polyoffset->value );
}
for( i = 0; i < tr.num_draw_decals; i++ )
{
DrawSurfaceDecals( tr.draw_decals[i], false, false );
}
if( e->curstate.rendermode != kRenderTransTexture )
{
pglDepthMask( GL_TRUE );
pglDisable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
}
if( gl_polyoffset->value )
pglDisable( GL_POLYGON_OFFSET_FILL );
if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd )
GL_Cull( GL_FRONT );
tr.num_draw_decals = 0;
}
#endif
/*
=============================================================

View file

@ -294,43 +294,7 @@ void GAME_EXPORT R_Set2DMode( qboolean enable )
if( enable )
{
// if( glState.in2DMode )
// return;
#if 0
// set 2D virtual screen size
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
pglMatrixMode( GL_PROJECTION );
pglLoadIdentity();
pglOrtho( 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
pglMatrixMode( GL_MODELVIEW );
pglLoadIdentity();
GL_Cull( GL_NONE );
pglDepthMask( GL_FALSE );
pglDisable( GL_DEPTH_TEST );
pglEnable( GL_ALPHA_TEST );
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
#endif
// glState.in2DMode = true;
RI.currententity = NULL;
RI.currentmodel = NULL;
}
else
{
#if 0
pglDepthMask( GL_TRUE );
pglEnable( GL_DEPTH_TEST );
glState.in2DMode = false;
pglMatrixMode( GL_PROJECTION );
GL_LoadMatrix( RI.projectionMatrix );
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.worldviewMatrix );
GL_Cull( GL_FRONT );
#endif
}
}

View file

@ -21,22 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "r_local.h"
#ifndef id386
void R_SurfacePatch (void)
{
}
#endif
#if 0
the complex cases add new polys on most lines, so dont optimize for keeping them the same
have multiple free span lists to try to get better coherence?
low depth complexity -- 1 to 3 or so
have a sentinal at both ends?
#endif
edge_t *auxedges;
edge_t *r_edges, *edge_p, *edge_max;
@ -131,9 +115,6 @@ void R_BeginEdgeFrame (void)
}
}
#if !id386
/*
==============
R_InsertNewEdges
@ -160,7 +141,6 @@ edgesearch:
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
#if 1
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
@ -170,7 +150,6 @@ edgesearch:
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
#endif
goto edgesearch;
// insert edgestoadd before edgelist
@ -182,11 +161,6 @@ addedge:
} while ((edgestoadd = next_edge) != NULL);
}
#endif // !id386
#if !id386
/*
==============
R_RemoveEdges
@ -202,11 +176,6 @@ static void R_RemoveEdges (edge_t *pedge)
} while ((pedge = pedge->nextremove) != NULL);
}
#endif // !id386
#if !id386
/*
==============
R_StepActiveU
@ -276,9 +245,6 @@ pushback:
}
}
#endif // !id386
/*
==============
R_CleanupSpan
@ -431,9 +397,6 @@ void R_TrailingEdge (surf_t *surf, edge_t *edge)
}
}
#if !id386
/*
==============
R_LeadingEdge
@ -593,9 +556,6 @@ void R_GenerateSpans (void)
R_CleanupSpan ();
}
#endif // !id386
/*
==============
R_GenerateSpansBackward
@ -692,7 +652,6 @@ void R_ScanEdges (void)
{
R_InsertNewEdges (newedges[iv], edge_head.next);
}
#if 1
(*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left for
@ -707,7 +666,6 @@ void R_ScanEdges (void)
span_p = basespan_p;
}
#endif
if (removeedges[iv])
R_RemoveEdges (removeedges[iv]);
@ -935,14 +893,10 @@ static void D_TurbulentSurf (surf_t *s)
//============
//PGM
// textures that aren't warping are just flowing. Use NonTurbulent8 instead
#if 0
Turbulent8 (s->spans);
#else
if(!(pface->flags & SURF_DRAWTURB))
NonTurbulent8 (s->spans);
else
Turbulent8 (s->spans);
#endif
//PGM
//============
@ -1001,38 +955,12 @@ static void D_AlphaSurf (surf_t *s)
if( !pface )
return;
#if 1
if( pface->flags & SURF_CONVEYOR )
miplevel = 1;
else
miplevel = 0;
#else
{
float dot;
float normal[3];
if ( s->insubmodel )
{
VectorCopy( pface->plane->normal, normal );
// TransformVector( pface->plane->normal, normal);
dot = DotProduct( normal, vpn );
}
else
{
VectorCopy( pface->plane->normal, normal );
dot = DotProduct( normal, vpn );
}
if ( pface->flags & SURF_PLANEBACK )
dot = -dot;
if ( dot > 0 )
printf( "blah" );
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust);
}
#endif
alpha = RI.currententity->curstate.renderamt * 7 / 255;
if( alpha <= 0 && RI.currententity->curstate.renderamt > 0 )
alpha = 1;
@ -1121,41 +1049,15 @@ static void D_SolidSurf (surf_t *s)
if( !pface )
return;
#if 1
if( pface->flags & SURF_CONVEYOR )
miplevel = 1;
else
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip );
while( 1 << miplevel > gEngfuncs.Mod_SampleSizeForFace(pface))
miplevel--;
#else
{
float dot;
float normal[3];
if ( s->insubmodel )
{
VectorCopy( pface->plane->normal, normal );
// TransformVector( pface->plane->normal, normal);
dot = DotProduct( normal, vpn );
}
else
{
VectorCopy( pface->plane->normal, normal );
dot = DotProduct( normal, vpn );
}
if ( pface->flags & SURF_PLANEBACK )
dot = -dot;
if ( dot > 0 )
printf( "blah" );
miplevel = D_MipLevelForScale(s->nearzi * scale_for_mip * pface->texinfo->mipadjust);
}
#endif
// FIXME: make this passed in to D_CacheSurface
// FIXME: make this passed in to D_CacheSurface
pcurrentcache = D_CacheSurface (pface, miplevel);
cacheblock = (pixel_t *)pcurrentcache->data;
@ -1235,8 +1137,6 @@ void D_DrawSurfaces (void)
if (!s->spans)
continue;
//r_drawnpolycount++;
#if 1
if( alphaspans )
D_AlphaSurf (s);
else if(s->flags & SURF_DRAWSKY)
@ -1245,16 +1145,6 @@ void D_DrawSurfaces (void)
D_TurbulentSurf (s);
else
D_SolidSurf (s);
#else
if (! (s->flags & (SURF_DRAWSKYBOX|SURF_DRAWBACKGROUND|SURF_DRAWTURB) ) )
D_SolidSurf (s);
else if (s->flags & SURF_DRAWSKYBOX)
D_SkySurf (s);
else if (s->flags & SURF_DRAWBACKGROUND)
D_BackgroundSurf (s);
else if (s->flags & SURF_DRAWTURB)
D_TurbulentSurf (s);
#endif
}
}
else

View file

@ -527,16 +527,6 @@ static void R_BuildBlendMaps( void )
b = b1 * b2 / MASK(2);
vid.modmap[index2|index1] = r << (2 + 3) | g << 2 | b;
#if 0
for( a = 0; a < 8; a++ )
{
r = r1 * (7 - a) / 7 + r2 * a / 7;
g = g1 * (7 - a) / 7 + g2 * a / 7;
b = b1 * (7 - a) / 7 + b2 * a / 7;
//if( b == 1 ) b = 0;
vid.alphamap[a << 16|index2|index1] = r << (2 + 3) | g << 2 | b;
}
#endif
}
for( i = 0; i < 8192; i++ )
{
@ -569,7 +559,7 @@ static void R_BuildBlendMaps( void )
vid.colormap[index2|index1] = major << 8 | (minor & 0xFF);
}
}
#if 1
for( i = 0; i < 1024; i++ )
{
unsigned int r, g, b;
@ -614,12 +604,10 @@ static void R_BuildBlendMaps( void )
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);
}
}
}
#endif
}
static qboolean R_AllocScreen( void );

View file

@ -576,16 +576,11 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
for(i = 0; i < height * width; i++ )
{
unsigned int r, g, b, major, minor;
#if 0
r = data[i * 4 + 0] * MASK(5-1) / 255;
g = data[i * 4 + 1] * MASK(6-1) / 255;
b = data[i * 4 + 2] * MASK(5-1) / 255;
#else
// 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;
#endif
// 565 to 332
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
@ -612,121 +607,6 @@ static qboolean GL_UploadTexture( image_t *tex, rgbdata_t *pic )
//GL_CheckTexImageError( tex );
}
#if 0
GL_SetTextureTarget( tex, pic ); // must be first
// make sure what target is correct
if( tex->target == GL_NONE )
{
gEngfuncs.Con_DPrintf( S_ERROR "%s: %s is not supported by your hardware\n", __func__, tex->name );
return false;
}
GL_SetTextureDimensions( tex, pic->width, pic->height, pic->depth );
GL_SetTextureFormat( tex, pic->type, pic->flags );
tex->fogParams[0] = pic->fogParams[0];
tex->fogParams[1] = pic->fogParams[1];
tex->fogParams[2] = pic->fogParams[2];
tex->fogParams[3] = pic->fogParams[3];
if(( pic->width * pic->height ) & 3 )
{
// will be resampled, just tell me for debug targets
gEngfuncs.Con_Reportf( "%s: %s s&3 [%d x %d]\n", __func__, tex->name, pic->width, pic->height );
}
buf = pic->buffer;
bufend = pic->buffer + pic->size; // total image size include all the layers, cube sides, mipmaps
offset = GL_CalcImageSize( pic->type, pic->width, pic->height, pic->depth );
texsize = GL_CalcTextureSize( tex->format, tex->width, tex->height, tex->depth );
normalMap = FBitSet( tex->flags, TF_NORMALMAP ) ? true : false;
numSides = FBitSet( pic->flags, IMAGE_CUBEMAP ) ? 6 : 1;
// uploading texture into video memory, change the binding
glState.currentTextures[glState.activeTMU] = tex->texnum;
pglBindTexture( tex->target, tex->texnum );
for( i = 0; i < numSides; i++ )
{
// track the buffer bounds
if( buf != NULL && buf >= bufend )
gEngfuncs.Host_Error( "%s: %s image buffer overflow\n", __func__, tex->name );
if( ImageCompressed( pic->type ))
{
for( j = 0; j < Q_max( 1, pic->numMips ); j++ )
{
width = Q_max( 1, ( tex->width >> j ));
height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth );
size = GL_CalcImageSize( pic->type, width, height, tex->depth );
GL_TextureImageCompressed( tex, i, j, width, height, tex->depth, size, buf );
tex->size += texsize;
buf += size; // move pointer
tex->numMips++;
GL_CheckTexImageError( tex );
}
}
else if( Q_max( 1, pic->numMips ) > 1 ) // not-compressed DDS
{
for( j = 0; j < Q_max( 1, pic->numMips ); j++ )
{
width = Q_max( 1, ( tex->width >> j ));
height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( tex->format, width, height, tex->depth );
size = GL_CalcImageSize( pic->type, width, height, tex->depth );
GL_TextureImageRAW( tex, i, j, width, height, tex->depth, pic->type, buf );
tex->size += texsize;
buf += size; // move pointer
tex->numMips++;
GL_CheckTexImageError( tex );
}
}
else // RGBA32
{
int mipCount = GL_CalcMipmapCount( tex, ( buf != NULL ));
// NOTE: only single uncompressed textures can be resamples, no mips, no layers, no sides
if(( tex->depth == 1 ) && ( pic->width != tex->width ) || ( pic->height != tex->height ))
data = GL_ResampleTexture( buf, pic->width, pic->height, tex->width, tex->height, normalMap );
else data = buf;
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
for( j = 0; j < mipCount; j++ )
{
width = Q_max( 1, ( tex->width >> j ));
height = Q_max( 1, ( tex->height >> j ));
texsize = GL_CalcTextureSize( tex->format, 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 );
if( mipCount > 1 )
GL_BuildMipMap( data, width, height, tex->depth, tex->flags );
tex->size += texsize;
tex->numMips++;
GL_CheckTexImageError( tex );
}
// move to next side
if( numSides > 1 && ( buf != NULL ))
buf += GL_CalcImageSize( pic->type, pic->width, pic->height, 1 );
}
}
SetBits( tex->flags, TF_IMG_UPLOADED ); // done
tex->numMips /= numSides;
return true;
#endif
return true;
}

View file

@ -369,43 +369,12 @@ typedef struct image_s
struct image_s *nextHash;
} image_t;
#if 0
//
// gl_backend.c
//
void GL_BackendStartFrame( void );
void GL_BackendEndFrame( void );
void GL_CleanUpTextureUnits( int last );
void GL_Bind( int tmu, unsigned int texnum );
void GL_LoadTexMatrixExt( const float *glmatrix );
void GL_LoadMatrix( const matrix4x4 source );
void GL_TexGen( unsigned int coord, unsigned int mode );
void GL_SelectTexture( int texture );
void GL_CleanupAllTextureUnits( void );
void GL_LoadIdentityTexMatrix( void );
void GL_DisableAllTexGens( void );
void GL_SetRenderMode( int mode );
void GL_TextureTarget( uint target );
void GL_Cull( unsigned int cull );
void R_ShowTextures( void );
void R_ShowTree( void );
void SCR_TimeRefresh_f( void );
#endif
//
// gl_beams.c
//
void CL_DrawBeams( int fTrans, BEAM *active_beams );
qboolean R_BeamCull( const vec3_t start, const vec3_t end, qboolean pvsOnly );
#if 0
//
// gl_cull.c
//
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax );
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
qboolean R_CullSphere( const vec3_t centre, const float radius );
//int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags );
#endif
//
// gl_decals.c
//
@ -490,32 +459,7 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float
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 );
#if 0
//
// gl_rmisc.c
//
void R_ClearStaticEntities( void );
//
// gl_rsurf.c
//
void R_MarkLeaves( void );
void R_DrawWorld( void );
void R_DrawWaterSurfaces( void );
void R_DrawBrushModel( cl_entity_t *e );
void GL_SubdivideSurface( msurface_t *fa );
void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa );
void DrawGLPoly( glpoly2_t *p, float xScale, float yScale );
texture_t *R_TextureAnimation( msurface_t *s );
void GL_SetupFogColorForSurfaces( void );
void R_DrawAlphaTextureChains( void );
void GL_RebuildLightmaps( void );
void GL_BuildLightmaps( void );
void GL_ResetFogColor( void );
void R_GenerateVBO();
void R_ClearVBO();
void R_AddDecalVBO( decal_t *pdecal, msurface_t *surf );
#endif
//
// gl_rpart.c
//
@ -549,24 +493,6 @@ void R_StudioResetPlayerModels( void );
void CL_InitStudioAPI( void );
void Mod_StudioLoadTextures( model_t *mod, void *data );
void Mod_StudioUnloadTextures( void *data );
#if 0
//
// gl_alias.c
//
void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded );
void R_DrawAliasModel( cl_entity_t *e );
void R_AliasInit( void );
//
// gl_warp.c
//
void R_AddSkyBoxSurface( msurface_t *fa );
void R_ClearSkyBox( void );
void R_DrawSkyBox( void );
void R_DrawClouds( void );
void EmitWaterPolys( msurface_t *warp, qboolean reverse );
#endif
//
// r_polyse.c
@ -633,18 +559,7 @@ byte *Mod_GetCurrentVis( void );
void Mod_SetOrthoBounds( const float *mins, const float *maxs );
void R_NewMap( void );
void CL_AddCustomBeam( cl_entity_t *pEnvBeam );
#if 0
//
// gl_opengl.c
//
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
const char *GL_ErrorString( int err );
qboolean GL_Support( int r_ext );
int GL_MaxTextureUnits( void );
void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext );
void GL_SetExtension( int r_ext, int enable );
#endif
//
// gl_triapi.c
//
@ -941,18 +856,7 @@ typedef struct
int surfheight; // in mipmapped texels
} drawsurf_t;
#if 0
typedef struct {
int ambientlight;
int shadelight;
float *plightvec;
} alight_t;
#endif
// clipped bmodel edges
typedef struct bedge_s
{
mvertex_t *v[2];
@ -1212,7 +1116,7 @@ qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_x, int
//
// r_edge.c
//
void R_SurfacePatch (void);
static inline void R_SurfacePatch (void) { }
void R_BeginEdgeFrame (void);
void R_RenderWorld (void);
void R_ScanEdges (void);
@ -1269,7 +1173,6 @@ void R_SetUpWorldTransform (void);
//
#include "crtlib.h"
#include "crclib.h"
#if 1
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;
@ -1281,13 +1184,5 @@ void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
#else
#define Mem_Malloc( pool, size ) malloc(size)
#define Mem_Calloc( pool, size ) calloc(1,size)
#define Mem_Realloc( pool, ptr, size ) realloc(ptr, size)
#define Mem_Free( mem ) free(mem)
#define Mem_AllocPool( name ) gEngfuncs._Mem_AllocPool( name, __FILE__, __LINE__ )
#define Mem_FreePool( pool ) gEngfuncs._Mem_FreePool( pool, __FILE__, __LINE__ )
#define Mem_EmptyPool( pool ) gEngfuncs._Mem_EmptyPool( pool, __FILE__, __LINE__ )
#endif
#endif // GL_LOCAL_H

View file

@ -112,27 +112,6 @@ static int R_RankForRenderMode( int rendermode )
}
return 0;
}
#if 0
/*
================
R_GetEntityRenderMode
check for texture flags
================
*/
int R_GetEntityRenderMode( cl_entity_t *ent )
{
int i, opaque, trans;
mstudiotexture_t *ptexture;
cl_entity_t *oldent;
model_t *model;
studiohdr_t *phdr;
oldent = RI.currententity;
RI.currententity = ent;
return ent->curstate.rendermode;
}
#endif
void GAME_EXPORT R_AllowFog( qboolean allowed )
{
@ -223,8 +202,6 @@ static int R_TransEntityCompare( const cl_entity_t **a, const cl_entity_t **b )
return 0;
}
#if 1
/*
===============
R_WorldToScreen
@ -287,8 +264,6 @@ void GAME_EXPORT R_ScreenToWorld( const vec3_t screen, vec3_t point )
if( w != 0.0f ) VectorScale( point, ( 1.0f / w ), point );
}
#endif
/*
===============
R_PushScene
@ -392,36 +367,6 @@ R_Clear
*/
static void R_Clear( int bitMask )
{
int bits;
#if 0
if( gEngfuncs.CL_IsDevOverviewMode( ))
pglClearColor( 0.0f, 1.0f, 0.0f, 1.0f ); // green background (Valve rules)
else pglClearColor( 0.5f, 0.5f, 0.5f, 1.0f );
bits = GL_DEPTH_BUFFER_BIT;
if( glState.stencilEnabled )
bits |= GL_STENCIL_BUFFER_BIT;
bits &= bitMask;
pglClear( bits );
// change ordering for overview
if( RI.drawOrtho )
{
gldepthmin = 1.0f;
gldepthmax = 0.0f;
}
else
{
gldepthmin = 0.0f;
gldepthmax = 1.0f;
}
pglDepthFunc( GL_LEQUAL );
pglDepthRange( gldepthmin, gldepthmax );
#endif
memset( vid.buffer, 0, vid.width * vid.height *2);
}
@ -445,30 +390,15 @@ R_SetupFrustum
*/
void R_SetupFrustum( void )
{
#if 1
//ref_overview_t *ov = gEngfuncs.GetOverviewParms();
/*if( RP_NORMALPASS() && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ) && ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
{
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gp_cl->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gp_cl->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
}*/
// build the transformation matrix for the given view angles
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
//if( !r_lockfrustum->value )
{
VectorCopy( RI.vieworg, RI.cullorigin );
VectorCopy( RI.vforward, RI.cull_vforward );
VectorCopy( RI.vright, RI.cull_vright );
VectorCopy( RI.vup, RI.cull_vup );
}
// if( RI.drawOrtho )
// GL_FrustumInitOrtho( &RI.frustum, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
// else GL_FrustumInitProj( &RI.frustum, 0.0f, R_GetFarClip(), RI.fov_x, RI.fov_y ); // NOTE: we ignore nearplane here (mirrors only)
#endif
}
/*
@ -478,7 +408,6 @@ R_SetupProjectionMatrix
*/
static void R_SetupProjectionMatrix( matrix4x4 m )
{
#if 1
float xMin, xMax, yMin, yMax, zNear, zFar;
if( RI.drawOrtho )
@ -500,7 +429,6 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
xMin = -xMax;
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );
#endif
}
/*
@ -510,13 +438,11 @@ R_SetupModelviewMatrix
*/
static void R_SetupModelviewMatrix( matrix4x4 m )
{
#if 1
Matrix4x4_CreateModelview( m );
Matrix4x4_ConcatRotate( m, -RI.viewangles[2], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[0], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -RI.viewangles[1], 0, 0, 1 );
Matrix4x4_ConcatTranslate( m, -RI.vieworg[0], -RI.vieworg[1], -RI.vieworg[2] );
#endif
}
/*
@ -526,16 +452,6 @@ R_LoadIdentity
*/
void R_LoadIdentity( void )
{
#if 0
if( tr.modelviewIdentity ) return;
Matrix4x4_LoadIdentity( RI.objectMatrix );
Matrix4x4_Copy( RI.modelviewMatrix, RI.worldviewMatrix );
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.modelviewMatrix );
tr.modelviewIdentity = true;
#endif
}
/*
@ -545,25 +461,6 @@ R_RotateForEntity
*/
void R_RotateForEntity( cl_entity_t *e )
{
#if 0
float scale = 1.0f;
if( e == CL_GetEntityByIndex( 0 ) )
{
R_LoadIdentity();
return;
}
if( e->model->type != mod_brush && e->curstate.scale > 0.0f )
scale = e->curstate.scale;
Matrix4x4_CreateFromEntity( RI.objectMatrix, e->angles, e->origin, scale );
Matrix4x4_ConcatTransforms( RI.modelviewMatrix, RI.worldviewMatrix, RI.objectMatrix );
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.modelviewMatrix );
tr.modelviewIdentity = false;
#endif
}
/*
@ -573,25 +470,6 @@ R_TranslateForEntity
*/
void R_TranslateForEntity( cl_entity_t *e )
{
#if 0
float scale = 1.0f;
if( e == CL_GetEntityByIndex( 0 ) )
{
R_LoadIdentity();
return;
}
if( e->model->type != mod_brush && e->curstate.scale > 0.0f )
scale = e->curstate.scale;
Matrix4x4_CreateFromEntity( RI.objectMatrix, vec3_origin, e->origin, scale );
Matrix4x4_ConcatTransforms( RI.modelviewMatrix, RI.worldviewMatrix, RI.objectMatrix );
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.modelviewMatrix );
tr.modelviewIdentity = false;
#endif
}
/*
@ -631,79 +509,6 @@ static void R_SetupFrame( void )
// setup twice until globals fully refactored
R_SetupFrameQ();
}
#if 0
/*
=============
R_SetupGL
=============
*/
void R_SetupGL( qboolean set_gl_state )
{
R_SetupModelviewMatrix( RI.worldviewMatrix );
R_SetupProjectionMatrix( RI.projectionMatrix );
Matrix4x4_Concat( RI.worldviewProjectionMatrix, RI.projectionMatrix, RI.worldviewMatrix );
if( !set_gl_state ) return;
if( RP_NORMALPASS( ))
{
int x, x2, y, y2;
// set up viewport (main, playersetup)
x = floor( RI.viewport[0] * gpGlobals->width / gpGlobals->width );
x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * gpGlobals->width / gpGlobals->width );
y = floor( gpGlobals->height - RI.viewport[1] * gpGlobals->height / gpGlobals->height );
y2 = ceil( gpGlobals->height - ( RI.viewport[1] + RI.viewport[3] ) * gpGlobals->height / gpGlobals->height );
pglViewport( x, y2, x2 - x, y - y2 );
}
else
{
// envpass, mirrorpass
pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] );
}
pglMatrixMode( GL_PROJECTION );
GL_LoadMatrix( RI.projectionMatrix );
pglMatrixMode( GL_MODELVIEW );
GL_LoadMatrix( RI.worldviewMatrix );
if( FBitSet( RI.params, RP_CLIPPLANE ))
{
GLdouble clip[4];
mplane_t *p = &RI.clipPlane;
clip[0] = p->normal[0];
clip[1] = p->normal[1];
clip[2] = p->normal[2];
clip[3] = -p->dist;
pglClipPlane( GL_CLIP_PLANE0, clip );
pglEnable( GL_CLIP_PLANE0 );
}
GL_Cull( GL_FRONT );
pglDisable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
/*
=============
R_EndGL
=============
*/
static void R_EndGL( void )
{
if( RI.params & RP_CLIPPLANE )
pglDisable( GL_CLIP_PLANE0 );
}
#endif
/*
=============
@ -812,40 +617,12 @@ static void R_DrawEntitiesOnList( void )
case mod_studio:
R_SetUpWorldTransform();
R_DrawStudioModel( RI.currententity );
#if 0
// gradient debug (for colormap testing)
{finalvert_t fv[3];
void R_AliasSetUpTransform (void);
extern void (*d_pdrawspans)(void *);
extern void R_PolysetFillSpans8 ( void * );
d_pdrawspans = R_PolysetFillSpans8;
//RI.currententity = CL_GetEntityByIndex(0);
R_AliasSetUpTransform();
image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0));
r_affinetridesc.pskin = image->pixels[0];
r_affinetridesc.skinwidth = image->width;
r_affinetridesc.skinheight = image->height;
R_SetupFinalVert( &fv[0], 0, -50, 50, 31 << 8, 0, 0);
R_SetupFinalVert( &fv[1], 0, 50, 50, 0 << 8, image->width, 0);
R_SetupFinalVert( &fv[2], 0, 0, 0, 0 << 8, image->width/2, image->height);
R_RenderTriangle( &fv[0], &fv[1], &fv[2] );
}
#endif
break;
default:
break;
}
}
// GL_CheckForErrors();
// quake-specific feature
// R_DrawAlphaTextureChains();
// GL_CheckForErrors();
R_SetUpWorldTransform();
// draw sprites seperately, because of alpha blending
for( i = 0; i < tr.draw_list->num_solid_entities && !RI.onlyClientDraw; i++ )
@ -864,19 +641,14 @@ static void R_DrawEntitiesOnList( void )
}
}
// GL_CheckForErrors();
if( !RI.onlyClientDraw )
{
gEngfuncs.CL_DrawEFX( tr.frametime, false );
}
// GL_CheckForErrors();
if( RI.drawWorld )
gEngfuncs.pfnDrawNormalTriangles();
// GL_CheckForErrors();
d_pdrawspans = R_PolysetDrawSpans8_33;
// then draw translucent entities
for( i = 0; i < tr.draw_list->num_trans_entities && !RI.onlyClientDraw; i++ )
@ -915,16 +687,11 @@ static void R_DrawEntitiesOnList( void )
}
}
// GL_CheckForErrors();
if( RI.drawWorld )
{
// pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
gEngfuncs.pfnDrawTransparentTriangles ();
}
// GL_CheckForErrors();
if( !RI.onlyClientDraw )
{
R_AllowFog( false );
@ -932,22 +699,16 @@ static void R_DrawEntitiesOnList( void )
R_AllowFog( true );
}
//GL_CheckForErrors();
// pglDisable( GL_BLEND ); // Trinity Render issues
GL_SetRenderMode(kRenderNormal);
R_SetUpWorldTransform();
if( !RI.onlyClientDraw )
R_DrawViewModel();
gEngfuncs.CL_ExtraUpdate();
//GL_CheckForErrors();
}
#if 1
qboolean insubmodel;
/*
=============
R_BmodelCheckBBox
@ -1110,7 +871,6 @@ static void R_DrawBEntitiesOnList (void)
VectorCopy (tr.modelorg, oldorigin);
insubmodel = true;
//r_dlightframecount = r_framecount;
for( i = 0; i < tr.draw_list->num_edge_entities && !RI.onlyClientDraw; i++ )
{
@ -1121,22 +881,12 @@ static void R_DrawBEntitiesOnList (void)
continue;
if (RI.currentmodel->nummodelsurfaces == 0)
continue; // clip brush only
//if ( currententity->flags & RF_BEAM )
//continue;
if (RI.currentmodel->type != mod_brush)
continue;
// see if the bounding box lets us trivially reject, also sets
// trivial accept status
RotatedBBox (RI.currentmodel->mins, RI.currentmodel->maxs,
RI.currententity->angles, mins, maxs);
#if 0
mins[0] = mins[0] - 100;
mins[1] = mins[1] - 100;
mins[2] = mins[2] - 100;
maxs[0] = maxs[0] + 100;
maxs[1] = maxs[1] + 100;
maxs[2] = maxs[2] + 100;
#endif
VectorAdd (mins, RI.currententity->origin, minmaxs);
VectorAdd (maxs, RI.currententity->origin, (minmaxs+3));
@ -1157,18 +907,6 @@ static void R_DrawBEntitiesOnList (void)
// FIXME: stop transforming twice
R_RotateBmodel ();
// calculate dynamic lighting for bmodel
// this will reset RI.currententity, do we need this?
//R_PushDlights ();
/*if (clmodel->firstmodelsurface != 0)
{
for (k=0 ; k<r_refdef2.numDlights ; k++)
{
R_MarkLights (&r_refdef2.dlights[k], 1<<k,
clmodel->nodes + clmodel->firstnode);
}
}*/
// calculate dynamic lighting for bmodel
for( k = 0; k < MAX_DLIGHTS; k++ )
{
@ -1183,14 +921,10 @@ static void R_DrawBEntitiesOnList (void)
Matrix4x4_VectorITransform( RI.objectMatrix, l->origin, origin_l );
VectorCopy( origin_l, l->origin ); // move light in bmodel space
R_MarkLights( l, 1<<k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode );
VectorCopy( oldorigin, l->origin ); // restore lightorigin*/
//R_MarkLights( l, 1<<k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode );
VectorCopy( oldorigin, l->origin ); // restore lightorigin
}
// RI.currentmodel = tr.draw_list->solid_entities[i]->model;
// RI.currententity = tr.draw_list->solid_entities[i];
RI.currententity->topnode = topnode;
//ASSERT( RI.currentmodel == tr.draw_list->solid_entities[i]->model );
if (topnode->contents >= 0)
{
// not a leaf; has to be clipped to the world BSP
@ -1202,9 +936,6 @@ static void R_DrawBEntitiesOnList (void)
// falls entirely in one leaf, so we just put all the
// edges in the edge list and let 1/z sorting handle
// drawing order
//ASSERT( RI.currentmodel == tr.draw_list->solid_entities[i]->model );
R_DrawSubmodelPolygons (RI.currentmodel, clipflags, topnode);
}
RI.currententity->topnode = NULL;
@ -1269,28 +1000,17 @@ void R_DrawBrushModel(cl_entity_t *pent)
VectorCopy (tr.modelorg, oldorigin);
insubmodel = true;
//r_dlightframecount = r_framecount;
if (!RI.currentmodel)
return;
if (RI.currentmodel->nummodelsurfaces == 0)
return; // clip brush only
//if ( currententity->flags & RF_BEAM )
//continue;
if (RI.currentmodel->type != mod_brush)
return;
// see if the bounding box lets us trivially reject, also sets
// trivial accept status
RotatedBBox (RI.currentmodel->mins, RI.currentmodel->maxs,
RI.currententity->angles, mins, maxs);
#if 0
mins[0] = mins[0] - 100;
mins[1] = mins[1] - 100;
mins[2] = mins[2] - 100;
maxs[0] = maxs[0] + 100;
maxs[1] = maxs[1] + 100;
maxs[2] = maxs[2] + 100;
#endif
VectorAdd (mins, RI.currententity->origin, minmaxs);
VectorAdd (maxs, RI.currententity->origin, (minmaxs+3));
@ -1312,18 +1032,6 @@ void R_DrawBrushModel(cl_entity_t *pent)
// FIXME: stop transforming twice
R_RotateBmodel ();
// calculate dynamic lighting for bmodel
// this will reset RI.currententity, do we need this?
//R_PushDlights ();
/*if (clmodel->firstmodelsurface != 0)
{
for (k=0 ; k<r_refdef2.numDlights ; k++)
{
R_MarkLights (&r_refdef2.dlights[k], 1<<k,
clmodel->nodes + clmodel->firstnode);
}
}*/
// calculate dynamic lighting for bmodel
for( k = 0; k < MAX_DLIGHTS; k++ )
{
@ -1340,13 +1048,9 @@ void R_DrawBrushModel(cl_entity_t *pent)
VectorCopy( origin_l, l->origin ); // move light in bmodel space
R_MarkLights( l, 1<<k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode );
VectorCopy( oldorigin, l->origin ); // restore lightorigin*/
//R_MarkLights( l, 1<<k, RI.currentmodel->nodes + RI.currentmodel->hulls[0].firstclipnode );
}
// RI.currentmodel = tr.draw_list->solid_entities[i]->model;
// RI.currententity = tr.draw_list->solid_entities[i];
RI.currententity->topnode = topnode;
//ASSERT( RI.currentmodel == tr.draw_list->solid_entities[i]->model );
if (topnode->contents >= 0)
{
// not a leaf; has to be clipped to the world BSP
@ -1358,9 +1062,6 @@ void R_DrawBrushModel(cl_entity_t *pent)
// falls entirely in one leaf, so we just put all the
// edges in the edge list and let 1/z sorting handle
// drawing order
//ASSERT( RI.currentmodel == tr.draw_list->solid_entities[i]->model );
R_DrawSubmodelPolygons (RI.currentmodel, clipflags, topnode);
}
RI.currententity->topnode = NULL;
@ -1379,8 +1080,6 @@ void R_DrawBrushModel(cl_entity_t *pent)
alphaspans = false;
}
#endif
/*
================
R_EdgeDrawing
@ -1410,7 +1109,7 @@ static void R_EdgeDrawing (void)
{
surfaces = (surf_t *)(((uintptr_t)&lsurfs + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
surf_max = &surfaces[r_cnumsurfs];
// surface 0 doesn't really exist; it's just a dummy because index 0
// is used to indicate no edge attached to surface
@ -1431,85 +1130,6 @@ static void R_EdgeDrawing (void)
R_ScanEdges ();
}
#if 0
/*
===============
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current leaf
===============
*/
void R_MarkLeaves( void )
{
qboolean novis = false;
qboolean force = false;
mleaf_t *leaf = NULL;
mnode_t *node;
vec3_t test;
int i;
if( !RI.drawWorld ) return;
/*if( FBitSet( r_novis->flags, FCVAR_CHANGED ) || tr.fResetVis )
{
// force recalc viewleaf
ClearBits( r_novis->flags, FCVAR_CHANGED );
tr.fResetVis = false;
RI.viewleaf = NULL;
}*/
VectorCopy( RI.pvsorigin, test );
if( RI.viewleaf != NULL )
{
// merge two leafs that can be a crossed-line contents
if( RI.viewleaf->contents == CONTENTS_EMPTY )
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
else
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
force = true;
}
if( RI.viewleaf == RI.oldviewleaf && RI.viewleaf != NULL && !force )
return;
// development aid to let you run around
// and see exactly where the pvs ends
//if( sw_lockpvs->value ) return;
RI.oldviewleaf = RI.viewleaf;
tr.visframecount++;
if( RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) gEngfuncs.R_FatPVS( test, REFPVS_RADIUS, RI.visbytes, true, novis );
for( i = 0; i < WORLDMODEL->numleafs; i++ )
{
if( CHECKVISBIT( RI.visbytes, i ))
{
node = (mnode_t *)&WORLDMODEL->leafs[i+1];
do
{
if( node->visframe == tr.visframecount )
break;
node->visframe = tr.visframecount;
node = node->parent;
} while( node );
}
}
}
#else
/*
===============
R_MarkLeaves
@ -1546,11 +1166,6 @@ static void R_MarkLeaves (void)
}
}
#endif
/*
================
R_RenderScene

View file

@ -45,24 +45,6 @@ D_Patch
*/
static void D_Patch (void)
{
#if id386
extern void D_Aff8Patch( void );
static qboolean protectset8 = false;
extern void D_PolysetAff8Start( void );
if (!protectset8)
{
Sys_MakeCodeWriteable ((int)D_PolysetAff8Start,
(int)D_Aff8Patch - (int)D_PolysetAff8Start);
Sys_MakeCodeWriteable ((long)R_Surf8Start,
(long)R_Surf8End - (long)R_Surf8Start);
protectset8 = true;
}
colormap = vid.colormap;
R_Surf8Patch ();
D_Aff8Patch();
#endif
}
/*
================
@ -369,18 +351,3 @@ void R_SetupFrameQ (void)
//d_aflatcolor = 0;
}
#if !id386
/*
================
R_SurfacePatch
================
*/
/*void R_SurfacePatch (void)
{
// we only patch code on Intel
}
*/
#endif // !id386

View file

@ -185,52 +185,6 @@ static inline qboolean R_DrawCheckBounds( pixel_t *lptex )
return false;
return true;
}
#if 0
static inline qboolean R_CheckBounds2( spanpackage_t *pspanpackage, int lcount )
{
int lsfrac, ltfrac;
pixel_t *lptex, *start, *end;
lptex = pspanpackage->ptex;
lsfrac = pspanpackage->sfrac;
ltfrac = pspanpackage->tfrac;
start = r_affinetridesc.pskin;
end = skinend;
do
{
if( lptex - start < 0 || lptex - end >= 0 )
return false;
lptex += a_ststepxwhole;
lsfrac += a_sstepxfrac;
lptex += lsfrac >> 16;
lsfrac &= 0xFFFF;
ltfrac += a_tstepxfrac;
if (ltfrac & 0x10000)
{
lptex += r_affinetridesc.skinwidth;
ltfrac &= 0xFFFF;
}
} while (--lcount);
// span is linear, so only need to check first and last
if( lptex - start < 0 || lptex - end >= 0 )
return false;
//if( !(--lcount) )
//return true;
lptex = lptex + a_ststepxwhole * lcount + ((lsfrac + ( a_sstepxfrac * lcount)) >> 16) + ((ltfrac + (a_tstepxfrac * lcount)) >> 16) * r_affinetridesc.skinwidth;
if( lptex - start < 0 || lptex - end >= 0 )
return false;
return true;
}
#endif
static inline qboolean R_PolysetCheckBounds( pixel_t *lptex, int lsfrac, int ltfrac, int lcount )
{
@ -425,265 +379,6 @@ static void R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
R_PolysetCalcGradients
================
*/
#if id386 && !defined __linux__
void R_PolysetCalcGradients( int skinwidth )
{
static float xstepdenominv, ystepdenominv, t0, t1;
static float p01_minus_p21, p11_minus_p21, p00_minus_p20, p10_minus_p20;
static float one = 1.0F, negative_one = -1.0F;
static unsigned long t0_int, t1_int;
extern unsigned long fpu_sp24_ceil_cw, fpu_ceil_cw, fpu_chop_cw;
/*
p00_minus_p20 = r_p0[0] - r_p2[0];
p01_minus_p21 = r_p0[1] - r_p2[1];
p10_minus_p20 = r_p1[0] - r_p2[0];
p11_minus_p21 = r_p1[1] - r_p2[1];
*/
__asm mov eax, dword ptr [r_p0+0]
__asm mov ebx, dword ptr [r_p0+4]
__asm sub eax, dword ptr [r_p2+0]
__asm sub ebx, dword ptr [r_p2+4]
__asm mov p00_minus_p20, eax
__asm mov p01_minus_p21, ebx
__asm fild dword ptr p00_minus_p20
__asm fild dword ptr p01_minus_p21
__asm mov eax, dword ptr [r_p1+0]
__asm mov ebx, dword ptr [r_p1+4]
__asm sub eax, dword ptr [r_p2+0]
__asm sub ebx, dword ptr [r_p2+4]
__asm fstp p01_minus_p21
__asm fstp p00_minus_p20
__asm mov p10_minus_p20, eax
__asm mov p11_minus_p21, ebx
__asm fild dword ptr p10_minus_p20
__asm fild dword ptr p11_minus_p21
__asm fstp p11_minus_p21
__asm fstp p10_minus_p20
/*
xstepdenominv = 1.0 / (float)d_xdenom;
ystepdenominv = -xstepdenominv;
*/
/*
** put FPU in single precision ceil mode
*/
__asm fldcw word ptr [fpu_sp24_ceil_cw]
// __asm fldcw word ptr [fpu_ceil_cw]
__asm fild dword ptr d_xdenom ; d_xdenom
__asm fdivr one ; 1 / d_xdenom
__asm fst xstepdenominv ;
__asm fmul negative_one ; -( 1 / d_xdenom )
// ceil () for light so positive steps are exaggerated, negative steps
// diminished, pushing us away from underflow toward overflow. Underflow is
// very visible, overflow is very unlikely, because of ambient lighting
/*
t0 = r_p0[4] - r_p2[4];
t1 = r_p1[4] - r_p2[4];
r_lstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
*/
__asm mov eax, dword ptr [r_p0+16]
__asm mov ebx, dword ptr [r_p1+16]
__asm sub eax, dword ptr [r_p2+16]
__asm sub ebx, dword ptr [r_p2+16]
__asm fstp ystepdenominv ; (empty)
__asm mov t0_int, eax
__asm mov t1_int, ebx
__asm fild t0_int ; t0
__asm fild t1_int ; t1 | t0
__asm fxch st(1) ; t0 | t1
__asm fstp t0 ; t1
__asm fst t1 ; t1
__asm fmul p01_minus_p21 ; t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p01_minus_p21
__asm fmul p11_minus_p21 ; t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t1 ; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p00_minus_p20 ; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p10_minus_p20 ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fxch st(2) ; t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
__asm fsubp st(3), st ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fsubrp st(1), st ; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fxch st(1) ; t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fmul xstepdenominv ; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fxch st(1)
__asm fmul ystepdenominv ; r_lstepy | r_lstepx
__asm fxch st(1) ; r_lstepx | r_lstepy
__asm fistp dword ptr [r_lstepx]
__asm fistp dword ptr [r_lstepy]
/*
** put FPU back into extended precision chop mode
*/
__asm fldcw word ptr [fpu_chop_cw]
/*
t0 = r_p0[2] - r_p2[2];
t1 = r_p1[2] - r_p2[2];
r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_sstepy = (int)((t1 * p00_minus_p20 - t0* p10_minus_p20) *
ystepdenominv);
*/
__asm mov eax, dword ptr [r_p0+8]
__asm mov ebx, dword ptr [r_p1+8]
__asm sub eax, dword ptr [r_p2+8]
__asm sub ebx, dword ptr [r_p2+8]
__asm mov t0_int, eax
__asm mov t1_int, ebx
__asm fild t0_int ; t0
__asm fild t1_int ; t1 | t0
__asm fxch st(1) ; t0 | t1
__asm fstp t0 ; t1
__asm fst t1 ; (empty)
__asm fmul p01_minus_p21 ; t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p01_minus_p21
__asm fmul p11_minus_p21 ; t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t1 ; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p00_minus_p20 ; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p10_minus_p20 ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fxch st(2) ; t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
__asm fsubp st(3), st ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fsubrp st(1), st ; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fxch st(1) ; t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fmul xstepdenominv ; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fxch st(1)
__asm fmul ystepdenominv ; r_lstepy | r_lstepx
__asm fxch st(1) ; r_lstepx | r_lstepy
__asm fistp dword ptr [r_sstepx]
__asm fistp dword ptr [r_sstepy]
/*
t0 = r_p0[3] - r_p2[3];
t1 = r_p1[3] - r_p2[3];
r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
*/
__asm mov eax, dword ptr [r_p0+12]
__asm mov ebx, dword ptr [r_p1+12]
__asm sub eax, dword ptr [r_p2+12]
__asm sub ebx, dword ptr [r_p2+12]
__asm mov t0_int, eax
__asm mov t1_int, ebx
__asm fild t0_int ; t0
__asm fild t1_int ; t1 | t0
__asm fxch st(1) ; t0 | t1
__asm fstp t0 ; t1
__asm fst t1 ; (empty)
__asm fmul p01_minus_p21 ; t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p01_minus_p21
__asm fmul p11_minus_p21 ; t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t1 ; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p00_minus_p20 ; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p10_minus_p20 ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fxch st(2) ; t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
__asm fsubp st(3), st ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fsubrp st(1), st ; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fxch st(1) ; t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fmul xstepdenominv ; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fxch st(1)
__asm fmul ystepdenominv ; r_lstepy | r_lstepx
__asm fxch st(1) ; r_lstepx | r_lstepy
__asm fistp dword ptr [r_tstepx]
__asm fistp dword ptr [r_tstepy]
/*
t0 = r_p0[5] - r_p2[5];
t1 = r_p1[5] - r_p2[5];
r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
xstepdenominv);
r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
*/
__asm mov eax, dword ptr [r_p0+20]
__asm mov ebx, dword ptr [r_p1+20]
__asm sub eax, dword ptr [r_p2+20]
__asm sub ebx, dword ptr [r_p2+20]
__asm mov t0_int, eax
__asm mov t1_int, ebx
__asm fild t0_int ; t0
__asm fild t1_int ; t1 | t0
__asm fxch st(1) ; t0 | t1
__asm fstp t0 ; t1
__asm fst t1 ; (empty)
__asm fmul p01_minus_p21 ; t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p01_minus_p21
__asm fmul p11_minus_p21 ; t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t1 ; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p00_minus_p20 ; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fld t0 ; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fmul p10_minus_p20 ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
__asm fxch st(2) ; t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
__asm fsubp st(3), st ; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fsubrp st(1), st ; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
__asm fxch st(1) ; t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fmul xstepdenominv ; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
__asm fxch st(1)
__asm fmul ystepdenominv ; r_lstepy | r_lstepx
__asm fxch st(1) ; r_lstepx | r_lstepy
__asm fistp dword ptr [r_zistepx]
__asm fistp dword ptr [r_zistepy]
/*
#if id386ALIAS
a_sstepxfrac = r_sstepx << 16;
a_tstepxfrac = r_tstepx << 16;
#else
a_sstepxfrac = r_sstepx & 0xFFFF;
a_tstepxfrac = r_tstepx & 0xFFFF;
#endif
*/
__asm mov eax, d_pdrawspans
__asm cmp eax, offset R_PolysetDrawSpans8_Opaque
__asm mov eax, r_sstepx
__asm mov ebx, r_tstepx
__asm jne translucent
//#if id386ALIAS
__asm shl eax, 16
__asm shl ebx, 16
__asm jmp done_with_steps
//#else
translucent:
__asm and eax, 0ffffh
__asm and ebx, 0ffffh
//#endif
done_with_steps:
__asm mov a_sstepxfrac, eax
__asm mov a_tstepxfrac, ebx
/*
a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
*/
__asm mov ebx, r_tstepx
__asm mov ecx, r_sstepx
__asm sar ebx, 16
__asm mov eax, skinwidth
__asm mul ebx
__asm sar ecx, 16
__asm add eax, ecx
__asm mov a_ststepxwhole, eax
}
#else
qboolean R_PolysetCalcGradients (int skinwidth)
{
float xstepdenominv, ystepdenominv, t0, t1;
@ -734,49 +429,16 @@ qboolean R_PolysetCalcGradients (int skinwidth)
r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
/*if( r_zistepx > INT_MAX / 2 )
return false;
if( r_zistepx < INT_MIN / 2 )
return false;
if( r_zistepy > INT_MAX / 2 )
return false;
if( r_zistepy < INT_MIN / 2 )
return false;*/
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
a_sstepxfrac = r_sstepx << 16;
a_tstepxfrac = r_tstepx << 16;
}
else
#endif
{
//#else
a_sstepxfrac = r_sstepx & 0xFFFF;
a_tstepxfrac = r_tstepx & 0xFFFF;
}
//#endif
// do not allow big steps to make 512 byte extra bounds enough (still f**ng not)
/*if( r_sstepx <= -65535*8 )
return false;
if( r_tstepx <= -65535*8)
return false;
if( r_sstepx >= 65535*8 )
return false;
if( r_tstepx >= 65535*8 )
return false;*/
a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
// printf("%d %d %d %d\n",a_ststepxwhole, r_sstepx, r_tstepx, skinwidth );
skinend = (pixel_t*)r_affinetridesc.pskin + r_affinetridesc.skinwidth * r_affinetridesc.skinheight;
return true;
}
#endif
/*
@ -827,13 +489,6 @@ void R_PolysetDrawSpansBlended( spanpackage_t *pspanpackage)
{
if ((lzi >> 16) >= *lpz)
{
#if 0
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
#if BOUNDCHECK_MODE == 1
if( !R_DrawCheckBounds( lptex ) )
return;
@ -922,13 +577,7 @@ void R_PolysetDrawSpansAdditive( spanpackage_t *pspanpackage)
if( !R_DrawCheckBounds( lptex ) )
return;
#endif
#if 0
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
pixel_t temp = *lptex;//vid.colormap[*lptex + ( llight & 0xFF00 )];
temp = BLEND_COLOR(temp, vid.color);
@ -1007,13 +656,6 @@ void R_PolysetDrawSpansGlow( spanpackage_t *pspanpackage)
#if BOUNDCHECK_MODE == 1
if( !R_DrawCheckBounds( lptex ) )
return;
#endif
#if 0
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
pixel_t temp = *lptex;//vid.colormap[*lptex + ( llight & 0xFF00 )];
temp = BLEND_COLOR(temp, vid.color);
@ -1095,13 +737,6 @@ void R_PolysetDrawSpansTextureBlended( spanpackage_t *pspanpackage)
#if BOUNDCHECK_MODE == 1
if( !R_DrawCheckBounds( lptex ) )
return;
#endif
#if 0
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
pixel_t temp = *lptex;//vid.colormap[*lptex + ( llight & 0xFF00 )];
@ -1180,13 +815,6 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
{
if ((lzi >> 16) >= *lpz)
{
#if 0
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
pixel_t temp = *lptex;//vid.colormap[*lptex + ( llight & 0xFF00 )];
int alpha = tr.blend * 7;
@ -1369,7 +997,6 @@ static void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
} while (pspanpackage->count != -999999);
}
#if !id386
void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
{
int lcount;
@ -1438,46 +1065,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
pspanpackage++;
} while (pspanpackage->count != -999999);
}
#endif
#if 0
/*
================
R_PolysetFillSpans8
================
*/
void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
{
int color;
// FIXME: do z buffering
color = d_aflatcolor++;
while (1)
{
int lcount;
byte *lpdest;
lcount = pspanpackage->count;
if (lcount == -1)
return;
if (lcount)
{
lpdest = pspanpackage->pdest;
do
{
*lpdest++ = color;
} while (--lcount);
}
pspanpackage++;
}
}
#else
void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
{
//int color;
@ -1532,27 +1120,9 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
#if BOUNDCHECK_MODE == 1
if( !R_DrawCheckBounds( lptex ) )
return;
#endif
//PGM
/*if(r_newrefdef.rdflags & RDF_IRGOGGLES && RI.currententity->flags & RF_IR_VISIBLE)
*lpdest = ((byte *)vid.colormap)[irtable[*lptex]];
else*/
//*lpdest = *lptex; //((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
#if 0 // check for texture bounds to make asan happy
if((int)(lptex - (pixel_t*)r_affinetridesc.pskin) > r_affinetridesc.skinwidth * r_affinetridesc.skinheight || (int)(lptex - (pixel_t*)r_affinetridesc.pskin) < 0 )
{
printf("%d %d %d %d\n",(int)(lptex - (pixel_t*)r_affinetridesc.pskin), r_affinetridesc.skinwidth * r_affinetridesc.skinheight, lsfrac, a_ststepxwhole );
return;
}
#endif
pixel_t src = *lptex;
//*lpdest = //vid.colormap[src & 0xff00|(llight>>8)] << 8 | (src & llight & 0xff) | ((src & 0xff) >> 3);
// very dirty, maybe need dual colormap?
//*lpdest = (vid.colormap[src >> 8 | (llight & 0xFF00)] << 8) | src & 0xff;
// 13 bit lighting, 32 light levels
*lpdest = vid.colormap[(src >> 3) | ((llight & 0x1F00) << 5)] | (src & 7);
//PGM
*lpz = lzi >> 16;
}
lpdest++;
@ -1574,7 +1144,7 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
else pspanpackage++;
} while (pspanpackage->count != -999999);
}
#endif
/*
================
R_RasterizeAliasPolySmooth
@ -1616,21 +1186,10 @@ void R_RasterizeAliasPolySmooth (void)
d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_sfrac = (plefttop[2] & 0xFFFF) << 16;
d_tfrac = (plefttop[3] & 0xFFFF) << 16;
}
//#else
else
#endif
{
d_sfrac = plefttop[2] & 0xFFFF;
d_tfrac = plefttop[3] & 0xFFFF;
}
//#endif
d_light = plefttop[4];
d_zi = plefttop[5];
@ -1659,21 +1218,10 @@ void R_RasterizeAliasPolySmooth (void)
R_PolysetSetUpForLineScan(plefttop[0], plefttop[1],
pleftbottom[0], pleftbottom[1]);
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_pzbasestep = (d_zwidth + ubasestep) << 1;
d_pzextrastep = d_pzbasestep + 2;
}
//#else
else
#endif
{
d_pzbasestep = d_zwidth + ubasestep;
d_pzextrastep = d_pzbasestep + 1;
}
//#endif
d_pdestbasestep = r_screenwidth + ubasestep;
d_pdestextrastep = d_pdestbasestep + 1;
@ -1692,52 +1240,23 @@ void R_RasterizeAliasPolySmooth (void)
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
r_affinetridesc.skinwidth;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) << 16;
d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) << 16;
}
else
#endif
{
//#else
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
}
//#endif
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
r_affinetridesc.skinwidth;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) << 16;
d_tfracextrastep = (r_tstepy + r_tstepx*d_countextrastep) << 16;
}
else
#endif
{
//#else
d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF;
d_tfracextrastep = (r_tstepy + r_tstepx*d_countextrastep) & 0xFFFF;
}
//#endif
d_lightextrastep = d_lightbasestep + working_lstepx;
d_ziextrastep = d_zibasestep + r_zistepx;
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
R_PolysetScanLeftEdge (initialleftheight);
}
else
#endif
{
if(!R_PolysetScanLeftEdge_C(initialleftheight))
return;
@ -1796,21 +1315,10 @@ void R_RasterizeAliasPolySmooth (void)
d_pdestbasestep = r_screenwidth + ubasestep;
d_pdestextrastep = d_pdestbasestep + 1;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_pzbasestep = (d_zwidth + ubasestep) << 1;
d_pzextrastep = d_pzbasestep + 2;
}
//#else
else
#endif
{
d_pzbasestep = d_zwidth + ubasestep;
d_pzextrastep = d_pzbasestep + 1;
}
//#endif
if (ubasestep < 0)
working_lstepx = r_lstepx - 1;
@ -1821,52 +1329,23 @@ void R_RasterizeAliasPolySmooth (void)
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
((r_tstepy + r_tstepx * ubasestep) >> 16) *
r_affinetridesc.skinwidth;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) << 16;
d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) << 16;
}
//#else
else
#endif
{
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
}
//#endif
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
r_affinetridesc.skinwidth;
//#if id386ALIAS
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
d_sfracextrastep = ((r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF)<<16;
d_tfracextrastep = ((r_tstepy+r_tstepx*d_countextrastep) & 0xFFFF)<<16;
}
else
#endif
//#endif
{
d_sfracextrastep = (r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF;
d_tfracextrastep = (r_tstepy+r_tstepx*d_countextrastep) & 0xFFFF;
}
//#endif
d_lightextrastep = d_lightbasestep + working_lstepx;
d_ziextrastep = d_zibasestep + r_zistepx;
#if id386
if ( d_pdrawspans == R_PolysetDrawSpans8_Opaque )
{
R_PolysetScanLeftEdge (height);
}
else
#endif
{
if(!R_PolysetScanLeftEdge_C(height))
return;

View file

@ -102,113 +102,6 @@ float box_verts[8][3] = {
// down, west, up, north, east, south
// {"rt", "bk", "lf", "ft", "up", "dn"};
#if 0
/*
================
R_InitSkyBox
================
*/
void R_InitSkyBox (void)
{
int i;
extern model_t *loadmodel;
r_skyfaces = loadmodel->surfaces + loadmodel->numsurfaces;
loadmodel->numsurfaces += 6;
r_skyverts = loadmodel->vertexes + loadmodel->numvertexes;
loadmodel->numvertexes += 8;
r_skyedges = loadmodel->edges + loadmodel->numedges;
loadmodel->numedges += 12;
r_skysurfedges = loadmodel->surfedges + loadmodel->numsurfedges;
loadmodel->numsurfedges += 24;
if (loadmodel->numsurfaces > MAX_MAP_FACES
|| loadmodel->numvertexes > MAX_MAP_VERTS
|| loadmodel->numedges > MAX_MAP_EDGES)
ri.Sys_Error (ERR_DROP, "InitSkyBox: map overflow");
memset (r_skyfaces, 0, 6*sizeof(*r_skyfaces));
for (i=0 ; i<6 ; i++)
{
r_skyplanes[i].normal[skybox_planes[i*2]] = 1;
r_skyplanes[i].dist = skybox_planes[i*2+1];
VectorCopy (box_vecs[i][0], r_skytexinfo[i].vecs[0]);
VectorCopy (box_vecs[i][1], r_skytexinfo[i].vecs[1]);
r_skyfaces[i].plane = &r_skyplanes[i];
r_skyfaces[i].numedges = 4;
r_skyfaces[i].flags = box_faces[i] | SURF_DRAWSKYBOX;
r_skyfaces[i].firstedge = loadmodel->numsurfedges-24+i*4;
r_skyfaces[i].texinfo = &r_skytexinfo[i];
r_skyfaces[i].texturemins[0] = -128;
r_skyfaces[i].texturemins[1] = -128;
r_skyfaces[i].extents[0] = 256;
r_skyfaces[i].extents[1] = 256;
}
for (i=0 ; i<24 ; i++)
if (box_surfedges[i] > 0)
r_skysurfedges[i] = loadmodel->numedges-13 + box_surfedges[i];
else
r_skysurfedges[i] = - (loadmodel->numedges-13 + -box_surfedges[i]);
for(i=0 ; i<12 ; i++)
{
r_skyedges[i].v[0] = loadmodel->numvertexes-9+box_edges[i*2+0];
r_skyedges[i].v[1] = loadmodel->numvertexes-9+box_edges[i*2+1];
r_skyedges[i].cachededgeoffset = 0;
}
}
/*
================
R_EmitSkyBox
================
*/
void R_EmitSkyBox (void)
{
int i, j;
int oldkey;
if (insubmodel)
return; // submodels should never have skies
if (r_skyframe == r_framecount)
return; // already set this frame
r_skyframe = r_framecount;
// set the eight fake vertexes
for (i=0 ; i<8 ; i++)
for (j=0 ; j<3 ; j++)
r_skyverts[i].position[j] = r_origin[j] + box_verts[i][j]*128;
// set the six fake planes
for (i=0 ; i<6 ; i++)
if (skybox_planes[i*2+1] > 0)
r_skyplanes[i].dist = r_origin[skybox_planes[i*2]]+128;
else
r_skyplanes[i].dist = r_origin[skybox_planes[i*2]]-128;
// fix texture offseets
for (i=0 ; i<6 ; i++)
{
r_skytexinfo[i].vecs[0][3] = -DotProduct (r_origin, r_skytexinfo[i].vecs[0]);
r_skytexinfo[i].vecs[1][3] = -DotProduct (r_origin, r_skytexinfo[i].vecs[1]);
}
// emit the six faces
oldkey = r_currentkey;
r_currentkey = 0x7ffffff0;
for (i=0 ; i<6 ; i++)
{
R_RenderFace (r_skyfaces + i, 15);
}
r_currentkey = oldkey; // bsp sorting order
}
#endif
#if !id386
/*
================
@ -509,9 +402,6 @@ static void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip)
R_EmitEdge (pv0, pv1);
}
#endif // !id386
/*
================
R_EmitCachedEdge

View file

@ -31,11 +31,6 @@ int *r_turb_turb;
static int r_turb_spancount;
int alpha;
void D_DrawTurbulent8Span (void);
#if !id386
/*
=============
D_DrawTurbulent8Span
@ -55,7 +50,6 @@ void D_DrawTurbulent8Span (void)
} while (--r_turb_spancount > 0);
}
/*
=============
D_DrawTurbulent8Span
@ -85,9 +79,6 @@ static void D_DrawTurbulent8ZSpan (void)
} while (--r_turb_spancount > 0);
}
#endif // !id386
/*
=============
Turbulent8
@ -220,7 +211,6 @@ void Turbulent8 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
/*
=============
Turbulent8
@ -503,9 +493,6 @@ void NonTurbulent8 (espan_t *pspan)
//PGM
//====================
#if !id386
int kernel[2][2][2] =
{
{
@ -1290,11 +1277,6 @@ void D_AddSpans16 (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
#endif
#if !id386
/*
=============
D_DrawZSpans
@ -1353,5 +1335,3 @@ void D_DrawZSpans (espan_t *pspan)
} while ((pspan = pspan->pnext) != NULL);
}
#endif

View file

@ -631,70 +631,6 @@ static void R_DrawSpriteQuad( mspriteframe_t *frame, vec3_t org, vec3_t v_right,
VectorMA( point, frame->right * scale, v_right, point );
TriVertex3fv( point );
TriEnd();
#if 0
image_t *pic = R_GetTexture(frame->gl_texturenum);
r_polydesc.pixels = pic->pixels[0];
r_polydesc.pixel_width = pic->width;
r_polydesc.pixel_height = pic->height;
r_polydesc.dist = 0;
// generate the sprite's axes, completely parallel to the viewplane.
VectorCopy (v_up, r_polydesc.vup);
VectorCopy (v_right, r_polydesc.vright);
VectorCopy (vpn, r_polydesc.vpn);
// build the sprite poster in worldspace
VectorScale (r_polydesc.vright,
frame->width - frame->origin_x, right);
VectorScale (r_polydesc.vup,
s_psprframe->height - s_psprframe->origin_y, up);
VectorScale (r_polydesc.vright,
-s_psprframe->origin_x, left);
VectorScale (r_polydesc.vup,
-s_psprframe->origin_y, down);
// invert UP vector for sprites
VectorInverse( r_polydesc.vup );
pverts = r_clip_verts[0];
pverts[0][0] = r_entorigin[0] + up[0] + left[0];
pverts[0][1] = r_entorigin[1] + up[1] + left[1];
pverts[0][2] = r_entorigin[2] + up[2] + left[2];
pverts[0][3] = 0;
pverts[0][4] = 0;
pverts[1][0] = r_entorigin[0] + up[0] + right[0];
pverts[1][1] = r_entorigin[1] + up[1] + right[1];
pverts[1][2] = r_entorigin[2] + up[2] + right[2];
pverts[1][3] = s_psprframe->width;
pverts[1][4] = 0;
pverts[2][0] = r_entorigin[0] + down[0] + right[0];
pverts[2][1] = r_entorigin[1] + down[1] + right[1];
pverts[2][2] = r_entorigin[2] + down[2] + right[2];
pverts[2][3] = s_psprframe->width;
pverts[2][4] = s_psprframe->height;
pverts[3][0] = r_entorigin[0] + down[0] + left[0];
pverts[3][1] = r_entorigin[1] + down[1] + left[1];
pverts[3][2] = r_entorigin[2] + down[2] + left[2];
pverts[3][3] = 0;
pverts[3][4] = s_psprframe->height;
r_polydesc.nump = 4;
r_polydesc.s_offset = ( r_polydesc.pixel_width >> 1);
r_polydesc.t_offset = ( r_polydesc.pixel_height >> 1);
VectorCopy( modelorg, r_polydesc.viewer_position );
r_polydesc.stipple_parity = 1;
if ( currententity->flags & RF_TRANSLUCENT )
R_ClipAndDrawPoly ( currententity->alpha, false, true );
else
R_ClipAndDrawPoly ( 1.0F, false, true );
r_polydesc.stipple_parity = 0;
#endif
}
static qboolean R_SpriteHasLightmap( cl_entity_t *e, int texFormat )
@ -799,34 +735,7 @@ void R_DrawSpriteModel( cl_entity_t *e )
R_AllowFog( false );
GL_SetRenderMode( e->curstate.rendermode );
#if 0
// select properly rendermode
switch( e->curstate.rendermode )
{
case kRenderTransAlpha:
pglDepthMask( GL_FALSE );
case kRenderTransColor:
case kRenderTransTexture:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
break;
case kRenderGlow:
pglDisable( GL_DEPTH_TEST );
case kRenderTransAdd:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglDepthMask( GL_FALSE );
break;
case kRenderNormal:
default:
pglDisable( GL_BLEND );
break;
}
// all sprites can have color
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglEnable( GL_ALPHA_TEST );
#endif
// NOTE: never pass sprites with rendercolor '0 0 0' it's a stupid Valve Hammer Editor bug
if( e->curstate.rendercolor.r || e->curstate.rendercolor.g || e->curstate.rendercolor.b )
{
@ -928,39 +837,4 @@ void R_DrawSpriteModel( cl_entity_t *e )
R_DrawSpriteQuad( frame, origin, v_right, v_up, scale );
}
}
#if 0
// draw the sprite 'lightmap' :-)
if( R_SpriteHasLightmap( e, psprite->texFormat ))
{
if( !r_lightmap->value )
pglEnable( GL_BLEND );
else pglDisable( GL_BLEND );
pglDepthFunc( GL_EQUAL );
pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_ZERO, GL_SRC_COLOR );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4f( color2[0], color2[1], color2[2], tr.blend );
GL_Bind( XASH_TEXTURE0, tr.whiteTexture );
R_DrawSpriteQuad( frame, origin, v_right, v_up, scale );
pglAlphaFunc( GL_GREATER, DEFAULT_ALPHATEST );
pglDepthFunc( GL_LEQUAL );
}
if( psprite->facecull == SPR_CULL_NONE )
GL_Cull( GL_FRONT );
pglDisable( GL_ALPHA_TEST );
pglDepthMask( GL_TRUE );
if( e->curstate.rendermode == kRenderGlow || e->curstate.rendermode == kRenderTransAdd )
R_AllowFog( true );
if( e->curstate.rendermode != kRenderNormal )
{
pglDisable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
pglEnable( GL_DEPTH_TEST );
}
#endif
}

View file

@ -2202,51 +2202,6 @@ R_StudioDrawHulls
*/
static void R_StudioDrawHulls( void )
{
#if 0
float alpha, lv;
int i, j;
if( r_drawentities->value == 4 )
alpha = 0.5f;
else alpha = 1.0f;
GL_Bind( XASH_TEXTURE0, tr.whiteTexture );
//pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
for( i = 0; i < m_pStudioHeader->numhitboxes; i++ )
{
mstudiobbox_t *pbbox = (mstudiobbox_t *)((byte *)m_pStudioHeader + m_pStudioHeader->hitboxindex);
vec3_t tmp, p[8];
for( j = 0; j < 8; j++ )
{
tmp[0] = (j & 1) ? pbbox[i].bbmin[0] : pbbox[i].bbmax[0];
tmp[1] = (j & 2) ? pbbox[i].bbmin[1] : pbbox[i].bbmax[1];
tmp[2] = (j & 4) ? pbbox[i].bbmin[2] : pbbox[i].bbmax[2];
Matrix3x4_VectorTransform( g_studio.bonestransform[pbbox[i].bone], tmp, p[j] );
}
j = (pbbox[i].group % 8);
TriBegin( TRI_QUADS );
_TriColor4f( hullcolor[j][0], hullcolor[j][1], hullcolor[j][2], alpha );
for( j = 0; j < 6; j++ )
{
VectorClear( tmp );
tmp[j % 3] = (j < 3) ? 1.0f : -1.0f;
R_StudioLighting( &lv, pbbox[i].bone, 0, tmp );
TriBrightness( lv );
TriVertex3fv( p[boxpnt[j][0]] );
TriVertex3fv( p[boxpnt[j][1]] );
TriVertex3fv( p[boxpnt[j][2]] );
TriVertex3fv( p[boxpnt[j][3]] );
}
TriEnd();
}
#endif
}
/*
@ -2297,99 +2252,10 @@ R_StudioDrawBones
*/
static void R_StudioDrawBones( void )
{
mstudiobone_t *pbones = (mstudiobone_t *) ((byte *)m_pStudioHeader + m_pStudioHeader->boneindex);
vec3_t point;
int i;
#if 0
pglDisable( GL_TEXTURE_2D );
for( i = 0; i < m_pStudioHeader->numbones; i++ )
{
if( pbones[i].parent >= 0 )
{
pglPointSize( 3.0f );
pglColor3f( 1, 0.7f, 0 );
pglBegin( GL_LINES );
Matrix3x4_OriginFromMatrix( g_studio.bonestransform[pbones[i].parent], point );
pglVertex3fv( point );
Matrix3x4_OriginFromMatrix( g_studio.bonestransform[i], point );
pglVertex3fv( point );
pglEnd();
pglColor3f( 0, 0, 0.8f );
pglBegin( GL_POINTS );
if( pbones[pbones[i].parent].parent != -1 )
{
Matrix3x4_OriginFromMatrix( g_studio.bonestransform[pbones[i].parent], point );
pglVertex3fv( point );
}
Matrix3x4_OriginFromMatrix( g_studio.bonestransform[i], point );
pglVertex3fv( point );
pglEnd();
}
else
{
// draw parent bone node
pglPointSize( 5.0f );
pglColor3f( 0.8f, 0, 0 );
pglBegin( GL_POINTS );
Matrix3x4_OriginFromMatrix( g_studio.bonestransform[i], point );
pglVertex3fv( point );
pglEnd();
}
}
pglPointSize( 1.0f );
pglEnable( GL_TEXTURE_2D );
#endif
}
static void R_StudioDrawAttachments( void )
{
int i;
#if 0
pglDisable( GL_TEXTURE_2D );
pglDisable( GL_DEPTH_TEST );
for( i = 0; i < m_pStudioHeader->numattachments; i++ )
{
mstudioattachment_t *pattachments;
vec3_t v[4];
pattachments = (mstudioattachment_t *)((byte *)m_pStudioHeader + m_pStudioHeader->attachmentindex);
Matrix3x4_VectorTransform( g_studio.bonestransform[pattachments[i].bone], pattachments[i].org, v[0] );
Matrix3x4_VectorTransform( g_studio.bonestransform[pattachments[i].bone], pattachments[i].vectors[0], v[1] );
Matrix3x4_VectorTransform( g_studio.bonestransform[pattachments[i].bone], pattachments[i].vectors[1], v[2] );
Matrix3x4_VectorTransform( g_studio.bonestransform[pattachments[i].bone], pattachments[i].vectors[2], v[3] );
pglBegin( GL_LINES );
pglColor3f( 1, 0, 0 );
pglVertex3fv( v[0] );
pglColor3f( 1, 1, 1 );
pglVertex3fv (v[1] );
pglColor3f( 1, 0, 0 );
pglVertex3fv (v[0] );
pglColor3f( 1, 1, 1 );
pglVertex3fv (v[2] );
pglColor3f( 1, 0, 0 );
pglVertex3fv (v[0] );
pglColor3f( 1, 1, 1 );
pglVertex3fv( v[3] );
pglEnd();
pglPointSize( 5.0f );
pglColor3f( 0, 1, 0 );
pglBegin( GL_POINTS );
pglVertex3fv( v[0] );
pglEnd();
pglPointSize( 1.0f );
}
pglEnable( GL_TEXTURE_2D );
pglEnable( GL_DEPTH_TEST );
#endif
}
/*
@ -2627,10 +2493,6 @@ static void R_StudioSetupRenderer( int rendermode )
if( rendermode > kRenderTransAdd ) rendermode = 0;
g_studio.rendermode = bound( 0, rendermode, kRenderTransAdd );
//pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
//pglDisable( GL_ALPHA_TEST );
//pglShadeModel( GL_SMOOTH );
// a point to setup local to world transform for boneweighted models
if( phdr && FBitSet( phdr->flags, STUDIO_HAS_BONEINFO ))
{
@ -2650,11 +2512,6 @@ R_StudioRestoreRenderer
*/
static void R_StudioRestoreRenderer( void )
{
//if( g_studio.rendermode != kRenderNormal )
//pglDisable( GL_BLEND );
//pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
//pglShadeModel( GL_FLAT );
m_fDoRemap = false;
}
@ -2755,32 +2612,6 @@ set rendermode for studiomodel
static void GL_StudioSetRenderMode( int rendermode )
{
GL_SetRenderMode( rendermode );
#if 0
switch( rendermode )
{
case kRenderNormal:
break;
case kRenderTransColor:
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglEnable( GL_BLEND );
break;
case kRenderTransAdd:
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4f( tr.blend, tr.blend, tr.blend, 1.0f );
pglBlendFunc( GL_ONE, GL_ONE );
pglDepthMask( GL_FALSE );
pglEnable( GL_BLEND );
break;
default:
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( 1.0f, 1.0f, 1.0f, tr.blend );
pglDepthMask( GL_TRUE );
pglEnable( GL_BLEND );
break;
}
#endif
}
/*
@ -2794,28 +2625,6 @@ studio shadows with some asm tricks
*/
static void GL_StudioDrawShadow( void )
{
#if 0
pglDepthMask( GL_TRUE );
if( r_shadows.value && g_studio.rendermode != kRenderTransAdd && !FBitSet( RI.currentmodel->flags, STUDIO_AMBIENT_LIGHT ))
{
float color = 1.0 - (tr.blend * 0.5);
pglDisable( GL_TEXTURE_2D );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglEnable( GL_BLEND );
pglColor4f( 0.0f, 0.0f, 0.0f, 1.0f - color );
pglDepthFunc( GL_LESS );
R_StudioDrawPointsShadow();
pglDepthFunc( GL_LEQUAL );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
pglShadeModel( GL_SMOOTH );
}
#endif
}
/*
@ -2867,42 +2676,8 @@ static void R_StudioRenderFinal( void )
{
R_StudioDrawAttachments();
}
#if 0
if( r_drawentities->value == 7 )
{
vec3_t origin;
pglDisable( GL_TEXTURE_2D );
pglDisable( GL_DEPTH_TEST );
Matrix3x4_OriginFromMatrix( g_studio.rotationmatrix, origin );
pglBegin( GL_LINES );
pglColor3f( 1, 0.5, 0 );
pglVertex3fv( origin );
pglVertex3fv( g_studio.lightspot );
pglEnd();
pglBegin( GL_LINES );
pglColor3f( 0, 0.5, 1 );
VectorMA( g_studio.lightspot, -64.0f, g_studio.lightvec, origin );
pglVertex3fv( g_studio.lightspot );
pglVertex3fv( origin );
pglEnd();
pglPointSize( 5.0f );
pglColor3f( 1, 0, 0 );
pglBegin( GL_POINTS );
pglVertex3fv( g_studio.lightspot );
pglEnd();
pglPointSize( 1.0f );
pglEnable( GL_DEPTH_TEST );
pglEnable( GL_TEXTURE_2D );
}
R_StudioRestoreRenderer();
#endif
}
/*

View file

@ -64,8 +64,6 @@ surfcache_t *sc_rover, *sc_base;
static int rtable[MOD_FRAMES][MOD_FRAMES];
#if 1
static void R_BuildLightMap( void );
/*
===============
@ -235,99 +233,6 @@ static void R_BuildLightMap( void )
blocklights[i] = t;
}
}
#else
/*
===============
R_BuildLightMap
Combine and scale multiple lightmaps into the 8.8 format in blocklights
===============
*/
void R_BuildLightMap (void)
{
int smax, tmax;
int t;
int i, size;
byte *lightmap;
unsigned scale;
int maps;
msurface_t *surf;
surf = r_drawsurf.surf;
//smax = (surf->extents[0]>>4)+1;
//tmax = (surf->extents[1]>>4)+1;
mextrasurf_t *info = surf->info;
int sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
smax = ( info->lightextents[0] / sample_size ) + 1;
tmax = ( info->lightextents[1] / sample_size ) + 1;
size = smax*tmax;
if (r_fullbright->value )
{
for (i=0 ; i<size ; i++)
blocklights[i] = 0;
return;
}
// clear to no light
for (i=0 ; i<size ; i++)
blocklights[i] = 0;
// add all the lightmaps
lightmap = surf->samples;
if (lightmap)
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
maps++)
{
scale = r_drawsurf.lightadj[maps]; // 8.8 fraction
for (i=0 ; i<size ; i++)
{
blocklights[i] += lightmap[i*3] * 2.5; // * scale;
blocklights[i] += lightmap[i*3+1] * 2.5; // * scale;
blocklights[i] += lightmap[i*3+2] * 2.5; // * scale;
}
lightmap += size; // skip to next lightmap
}
// add all the dynamic lights
//if (surf->dlightframe == r_framecount)
//R_AddDynamicLights ();
// bound, invert, and shift
/*for (i=0 ; i<size ; i++)
{
t = (int)blocklights[i];
if (t < 0)
t = 0;
t = (255*256 - t) >> (8 - VID_CBITS);
if (t < (1 << 6))
t = (1 << 6);
blocklights[i] = t;
}*/
for (i=0 ; i<size ; i++)
{
t = (int)blocklights[i];
if (t < 0)
t = 0;
if( t > 767 )
t = 767;
t = t * 31 / 256/3;//(255*256 - t) >> (8 - VID_CBITS);
//if (t < (1 << 6))
//t = (1 << 6);
t = t << 8;
blocklights[i] = t;
}
}
#endif
void GL_InitRandomTable( void )
{
@ -594,7 +499,6 @@ void R_DrawSurface (void)
//=============================================================================
#if !id386
#define BLEND_LM(pix, light) vid.colormap[(pix >> 3) | ((light & 0x1f00) << 5)] | ( pix & 7 );
/*
@ -920,12 +824,7 @@ void R_DrawSurfaceBlock8_mip3 (void)
}
}
#endif
//============================================================================
/*
================
R_InitCaches

View file

@ -23,11 +23,11 @@ static struct
vec4_t triRGBA;
} ds;
finalvert_t triv[3];
int vertcount, n;
int mode;
short s,t;
uint light;
static finalvert_t triv[3];
static int vertcount, n;
static int mode;
static short s, t;
static uint light;
/*
===============================================================
@ -46,33 +46,6 @@ set rendermode
void GAME_EXPORT TriRenderMode( int mode )
{
ds.renderMode = vid.rendermode = mode;
#if 0
switch( mode )
{
case kRenderNormal:
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglDisable( GL_BLEND );
pglDepthMask( GL_TRUE );
break;
case kRenderTransAlpha:
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglDepthMask( GL_FALSE );
break;
case kRenderTransColor:
case kRenderTransTexture:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
break;
case kRenderGlow:
case kRenderTransAdd:
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglEnable( GL_BLEND );
pglDepthMask( GL_FALSE );
break;
}
#endif
}
/*
@ -84,38 +57,6 @@ begin triangle sequence
*/
void GAME_EXPORT TriBegin( int mode1 )
{
#if 0
switch( mode )
{
case TRI_POINTS:
mode = GL_POINTS;
break;
case TRI_TRIANGLES:
mode = GL_TRIANGLES;
break;
case TRI_TRIANGLE_FAN:
mode = GL_TRIANGLE_FAN;
break;
case TRI_QUADS:
mode = GL_QUADS;
break;
case TRI_LINES:
mode = GL_LINES;
break;
case TRI_TRIANGLE_STRIP:
mode = GL_TRIANGLE_STRIP;
break;
case TRI_QUAD_STRIP:
mode = GL_QUAD_STRIP;
break;
case TRI_POLYGON:
default:
mode = GL_POLYGON;
break;
}
pglBegin( mode );
#endif
if( mode1 == TRI_QUADS )
mode1 = TRI_TRIANGLE_FAN;
mode = mode1;
@ -131,8 +72,6 @@ draw triangle sequence
*/
void GAME_EXPORT TriEnd( void )
{
//if( vertcount == 3 )
//pglEnd( );
}
/*
@ -272,7 +211,6 @@ TriVertex3fv
*/
void GAME_EXPORT TriVertex3fv( const float *v )
{
//pglVertex3fv( v );
TriVertex3f( v[0], v[1], v[2] );
}
@ -322,29 +260,6 @@ void GAME_EXPORT TriVertex3f( float x, float y, float z )
R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
}
}
#if 0
if( mode == TRI_TRIANGLE_STRIP )
{
R_SetupFinalVert( &triv[vertcount], x, y, z, 0,s,t);
vertcount++;
if( vertcount == 3 )
{
R_RenderTriangle( triv );
finalvert_t fv = triv[0];
triv[0] = triv[2];
triv[2] = fv;
R_RenderTriangle( triv );
fv = triv[0];
triv[0] = triv[2];
triv[2] = fv;
triv[0] = triv[1];
triv[1] = triv[2];
vertcount = 2;
}
}
#endif
}
/*
@ -390,39 +305,6 @@ enables global fog on the level
*/
void GAME_EXPORT TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
{
#if 0
// overrided by internal fog
if( RI.fogEnabled ) return;
RI.fogCustom = bOn;
// check for invalid parms
if( flEnd <= flStart )
{
RI.fogCustom = false;
pglDisable( GL_FOG );
return;
}
if( RI.fogCustom )
pglEnable( GL_FOG );
else pglDisable( GL_FOG );
// copy fog params
RI.fogColor[0] = flFogColor[0] / 255.0f;
RI.fogColor[1] = flFogColor[1] / 255.0f;
RI.fogColor[2] = flFogColor[2] / 255.0f;
RI.fogStart = flStart;
RI.fogColor[3] = 1.0f;
RI.fogDensity = 0.0f;
RI.fogSkybox = true;
RI.fogEnd = flEnd;
pglFogi( GL_FOG_MODE, GL_LINEAR );
pglFogfv( GL_FOG_COLOR, RI.fogColor );
pglFogf( GL_FOG_START, RI.fogStart );
pglFogf( GL_FOG_END, RI.fogEnd );
pglHint( GL_FOG_HINT, GL_NICEST );
#endif
}
/*
@ -434,7 +316,6 @@ very strange export
*/
void GAME_EXPORT TriGetMatrix( const int pname, float *matrix )
{
//pglGetFloatv( pname, matrix );
}
/*
@ -445,8 +326,6 @@ TriForParams
*/
void GAME_EXPORT TriFogParams( float flDensity, int iFogSkybox )
{
//RI.fogDensity = flDensity;
//RI.fogSkybox = iFogSkybox;
}
/*
@ -457,21 +336,6 @@ TriCullFace
*/
void GAME_EXPORT TriCullFace( TRICULLSTYLE mode )
{
#if 0
int glMode;
switch( mode )
{
case TRI_FRONT:
glMode = GL_FRONT;
break;
default:
glMode = GL_NONE;
break;
}
GL_Cull( mode );
#endif
}
/*
@ -483,13 +347,9 @@ void TriBrightness( float brightness )
{
float r, g, b;
//if( brightness < 0.5 )
// brightness = 1; //0.5;
//ds.triRGBA[3] = 1;
r = ds.triRGBA[0] * ds.triRGBA[3] * brightness;
g = ds.triRGBA[1] * ds.triRGBA[3] * brightness;
b = ds.triRGBA[2] * ds.triRGBA[3] * brightness;
_TriColor4f( r, g, b, 1.0f );
}