Skip to content

Commit

Permalink
OpenGL: perform alpha tests after vertex color multiplication in VBO …
Browse files Browse the repository at this point in the history
…shaders, fixes #308

FS: remove trailing newlines from mod descriptions
  • Loading branch information
ec- committed Dec 23, 2024
1 parent 4de47f8 commit 0d48d97
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ static void CL_CompleteRecordName(const char *args, int argNum )
{
char demoExt[ 16 ];

Com_sprintf( demoExt, sizeof( demoExt ), ".%s%d", DEMOEXT, com_protocol->integer );
Com_sprintf( demoExt, sizeof( demoExt ), "." DEMOEXT "%d", com_protocol->integer );
Field_CompleteFilename( "demos", demoExt, qtrue, FS_MATCH_EXTERN | FS_MATCH_STICK );
}
}
Expand Down
9 changes: 7 additions & 2 deletions code/qcommon/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,11 @@ static void FS_GetModDescription( const char *modDir, char *description, int des
nDescLen = FS_Read( description, nDescLen, descHandle );
if ( nDescLen >= 0 ) {
description[ nDescLen ] = '\0';
while ( nDescLen > 0 && description[ nDescLen - 1 ] == '\n' ) {
// strip ending newlines
description[ nDescLen - 1 ] = '\0';
nDescLen--;
}
}
} else {
Q_strncpyz( description, modDir, descriptionLen );
Expand Down Expand Up @@ -3884,9 +3889,9 @@ static int FS_PathCmp( const char *s1, const char *s2 ) {
FS_SortFileList
================
*/
static void FS_SortFileList( char **list, int n ) {
static void FS_SortFileList( const char **list, int n ) {
const char *m;
char *temp;
const char *temp;
int i, j;
i = 0;
j = n;
Expand Down
28 changes: 17 additions & 11 deletions code/renderer/tr_vbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,26 @@ const char *BuildFP( int multitexture, int alphatest, int fogMode )
return buf;
}

if ( alphatest || multitexture == GL_ADD || multitexture == GL_MODULATE ) {
strcat( buf, "TEMP t; \n" );
}

switch ( multitexture ) {
case 0:
strcat( buf, "TEMP t; \n" );
strcat( buf, "TEX base, fragment.texcoord[0], texture[0], 2D; \n" );
strcat( buf, genATestFP( alphatest ) );
break;
case GL_ADD:
strcat( buf, "TEMP t; \n" );
strcat( buf, "TEX base, fragment.texcoord[0], texture[0], 2D; \n" );
strcat( buf, genATestFP( alphatest ) );
strcat( buf, "TEX t, fragment.texcoord[1], texture[1], 2D; \n"
"ADD base, base, t; \n" );
break;
case GL_MODULATE:
strcat( buf, "TEMP t; \n" );
strcat( buf, "TEX base, fragment.texcoord[0], texture[0], 2D; \n" );
strcat( buf, genATestFP( alphatest ) );
strcat( buf, "TEX t, fragment.texcoord[1], texture[1], 2D; \n" );
strcat( buf, "MUL base, base, t; \n" );
break;
case GL_REPLACE:
strcat( buf, "TEX base, fragment.texcoord[1], texture[1], 2D; \n" );
//strcat( buf, genATestFP( alphatest ) );
break;
default:
ri.Error( ERR_DROP, "Invalid multitexture mode %04x", multitexture );
Expand All @@ -271,15 +268,24 @@ const char *BuildFP( int multitexture, int alphatest, int fogMode )

if ( fogMode == FP_FOG_BLEND ) {
strcat( buf, "MUL base, base, fragment.color; \n" );
strcat( buf, genATestFP( alphatest ) );
strcat( buf, "TEMP fog; \n"
"TEX fog, fragment.texcoord[4], texture[2], 2D; \n"
"MUL fog, fog, program.local[0]; \n"
"LRP_SAT result.color, fog.a, fog, base; \n"
"END \n" );
} else {
strcat( buf,
"MUL result.color, base, fragment.color; \n"
"END \n" );
if ( alphatest ) {
strcat( buf, "MUL base, base, fragment.color; \n" );
strcat( buf, genATestFP( alphatest ) );
strcat( buf,
"MOV result.color, base; \n"
"END \n" );
} else {
strcat( buf,
"MUL result.color, base, fragment.color; \n"
"END \n" );
}
}

return buf;
Expand Down Expand Up @@ -333,7 +339,7 @@ static int getFPindex( int multitexture, int atest, int fogmode )
index <<= 2; // reserve bits for atest
switch ( atest )
{
case GLS_ATEST_GT_0: index |= 1; break;
case GLS_ATEST_GT_0: index |= 1; break;
case GLS_ATEST_LT_80: index |= 2; break;
case GLS_ATEST_GE_80: index |= 3; break;
default: break;
Expand Down

0 comments on commit 0d48d97

Please sign in to comment.