Browse Source

ref_soft: studiomodel texturing, finally fix TRIANGLE_STRIP

pull/2/head
mittorn 6 years ago
parent
commit
dbabb861f2
  1. 2
      r_local.h
  2. 8
      r_polyse.c
  3. 5
      r_studio.c
  4. 14
      r_trialias.c
  5. 51
      r_triapi.c

2
r_local.h

@ -1329,7 +1329,7 @@ void R_RenderFace (msurface_t *fa, int clipflags);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
void R_RenderTriangle( finalvert_t *pfv ); 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 R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, int s, int t );
// //

8
r_polyse.c

@ -1170,7 +1170,7 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
{ {
int lsfrac, ltfrac; int lsfrac, ltfrac;
pixel_t *lpdest; pixel_t *lpdest;
byte *lptex; pixel_t *lptex;
int llight; int llight;
int lzi; int lzi;
short *lpz; short *lpz;
@ -1191,7 +1191,7 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
/*if(r_newrefdef.rdflags & RDF_IRGOGGLES && RI.currententity->flags & RF_IR_VISIBLE) /*if(r_newrefdef.rdflags & RDF_IRGOGGLES && RI.currententity->flags & RF_IR_VISIBLE)
*lpdest = ((byte *)vid.colormap)[irtable[*lptex]]; *lpdest = ((byte *)vid.colormap)[irtable[*lptex]];
else*/ else*/
*lpdest = color; //((byte *)vid.colormap)[*lptex + (llight & 0xFF00)]; *lpdest = *lptex; //((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
//PGM //PGM
*lpz = lzi >> 16; *lpz = lzi >> 16;
} }
@ -1253,7 +1253,7 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1]; ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0]; d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) + d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth; (plefttop[3] >> 16) * r_affinetridesc.skinwidth;
//#if id386ALIAS //#if id386ALIAS
#if id386 #if id386
@ -1398,7 +1398,7 @@ void R_RasterizeAliasPolySmooth (void)
ystart = plefttop[1]; ystart = plefttop[1];
d_aspancount = plefttop[0] - prighttop[0]; d_aspancount = plefttop[0] - prighttop[0];
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) + d_ptex = (pixel_t*)r_affinetridesc.pskin + (plefttop[2] >> 16) +
(plefttop[3] >> 16) * r_affinetridesc.skinwidth; (plefttop[3] >> 16) * r_affinetridesc.skinwidth;
d_sfrac = 0; d_sfrac = 0;
d_tfrac = 0; d_tfrac = 0;

5
r_studio.c

@ -1813,6 +1813,7 @@ R_StudioSetupSkin
static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index ) static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index )
{ {
mstudiotexture_t *ptexture = NULL; mstudiotexture_t *ptexture = NULL;
image_t *image;
if( FBitSet( g_nForceFaceFlags, STUDIO_NF_CHROME )) if( FBitSet( g_nForceFaceFlags, STUDIO_NF_CHROME ))
return; return;
@ -1827,6 +1828,10 @@ static void R_StudioSetupSkin( studiohdr_t *ptexturehdr, int index )
if( r_lightmap->value && !r_fullbright->value ) if( r_lightmap->value && !r_fullbright->value )
GL_Bind( XASH_TEXTURE0, tr.whiteTexture ); GL_Bind( XASH_TEXTURE0, tr.whiteTexture );
else GL_Bind( XASH_TEXTURE0, ptexture[index].index ); else GL_Bind( XASH_TEXTURE0, ptexture[index].index );
image = R_GetTexture(ptexture[index].index);
r_affinetridesc.pskin = image->pixels[0];
r_affinetridesc.skinwidth = image->width;
r_affinetridesc.skinheight = image->height;
} }
/* /*

14
r_trialias.c

@ -205,23 +205,23 @@ void R_SetupFinalVert( finalvert_t *fv, float x, float y, float z, int light, in
fv->t = t << 16; fv->t = t << 16;
} }
void R_RenderTriangle( finalvert_t *pfv ) void R_RenderTriangle( finalvert_t *fv1, finalvert_t *fv2, finalvert_t *fv3 )
{ {
if ( pfv[0].flags & pfv[1].flags & pfv[2].flags ) if ( fv1->flags & fv2->flags & fv3->flags )
return ; // completely clipped return ; // completely clipped
if ( ! (pfv[0].flags | pfv[1].flags | pfv[2].flags) ) if ( ! (fv1->flags | fv2->flags | fv3->flags) )
{ // totally unclipped { // totally unclipped
aliastriangleparms.a = &pfv[0]; aliastriangleparms.a = fv1;
aliastriangleparms.b = &pfv[1]; aliastriangleparms.b = fv2;
aliastriangleparms.c = &pfv[2]; aliastriangleparms.c = fv3;
R_DrawTriangle(); R_DrawTriangle();
} }
else else
{ // partially clipped { // partially clipped
R_AliasClipTriangle (&pfv[0], &pfv[1], &pfv[2]); R_AliasClipTriangle (fv1, fv2, fv3);
} }
} }

51
r_triapi.c

@ -24,8 +24,9 @@ static struct
} ds; } ds;
finalvert_t triv[3]; finalvert_t triv[3];
int vertcount; int vertcount, n;
int mode; int mode;
short s,t;
/* /*
=============================================================== ===============================================================
@ -115,7 +116,7 @@ void TriBegin( int mode1 )
pglBegin( mode ); pglBegin( mode );
#endif #endif
mode = mode1; mode = mode1;
vertcount = 0; vertcount = n = vertcount = 0;
} }
/* /*
@ -128,7 +129,6 @@ draw triangle sequence
void TriEnd( void ) void TriEnd( void )
{ {
//if( vertcount == 3 ) //if( vertcount == 3 )
R_RenderTriangle( triv );
//pglEnd( ); //pglEnd( );
} }
@ -209,6 +209,8 @@ TriTexCoord2f
void TriTexCoord2f( float u, float v ) void TriTexCoord2f( float u, float v )
{ {
//pglTexCoord2f( u, v ); //pglTexCoord2f( u, v );
s = r_affinetridesc.skinwidth * u;
t = r_affinetridesc.skinheight * v;
} }
/* /*
@ -233,26 +235,53 @@ void TriVertex3f( float x, float y, float z )
{ {
if( mode == TRI_TRIANGLE_FAN ) if( mode == TRI_TRIANGLE_FAN )
{ {
R_SetupFinalVert( &triv[vertcount], x, y, z, 0,0,0); R_SetupFinalVert( &triv[vertcount], x, y, z, 0,s,t);
vertcount++; vertcount++;
if( vertcount >= 3 ) if( vertcount >= 3 )
{ {
R_RenderTriangle( triv ); R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
triv[1] = triv[2]; triv[1] = triv[2];
vertcount = 2; vertcount = 2;
} }
} }
if( mode == TRI_TRIANGLE_STRIP ) if( mode == TRI_TRIANGLE_STRIP )
{ {
if( vertcount > 2 ) R_SetupFinalVert( &triv[n], x, y, z, 0,s,t);
n++;
vertcount++;
if( n == 3 )
n = 0;
if (vertcount >= 3)
{ {
R_SetupFinalVert( &triv[(vertcount + 1) & 1 + 1], x, y, z, 0,0,0); if( vertcount & 1 )
R_RenderTriangle( triv ); R_RenderTriangle( &triv[0], &triv[1], &triv[2] );
else
R_RenderTriangle( &triv[2], &triv[1], &triv[0] );
} }
else
R_SetupFinalVert( &triv[vertcount], x, y, z, 0,0,0);
vertcount++;
} }
#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
} }
/* /*

Loading…
Cancel
Save