Skip to content

Commit

Permalink
Fix index 255 rendering as fullbright with gl_fullbrights 0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Nov 25, 2023
1 parent fbeec35 commit 1689ac1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Quake/gl_texmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ static int numgltextures;
static gltexture_t *active_gltextures, *free_gltextures;
gltexture_t *notexture, *nulltexture, *whitetexture, *greytexture, *blacktexture;

unsigned int d_8to24table_opaque[256]; //standard palette with alpha 255 for all colors
unsigned int d_8to24table[256]; //standard palette, 255 is transparent
unsigned int d_8to24table_fbright[256]; //fullbright palette, 0-223 are black (for additive blending)
unsigned int d_8to24table_alphabright[256]; //palette with lighting mask in alpha channel (0=fullbright, 1=lit)
unsigned int d_8to24table_alphabright[256]; //palette with lighting mask in alpha channel (0=fullbright, 255=lit)
unsigned int d_8to24table_fbright_fence[256]; //fullbright palette, for fence textures
unsigned int d_8to24table_nobright[256]; //nobright palette, 224-255 are black (for additive blending)
unsigned int d_8to24table_nobright_fence[256]; //nobright palette, for fence textures
Expand Down Expand Up @@ -779,7 +780,7 @@ void TexMgr_LoadPalette (void)
src = pal;
for (i = 0; i < 256; i++, src += 3)
{
SetColor (&d_8to24table[i], src[0], src[1], src[2], 255);
SetColor (&d_8to24table_opaque[i], src[0], src[1], src[2], 255);
if (GetBit (is_fullbright, i))
{
SetColor (&d_8to24table_alphabright[i], src[0], src[1], src[2], 0);
Expand All @@ -793,6 +794,8 @@ void TexMgr_LoadPalette (void)
SetColor (&d_8to24table_nobright[i], src[0], src[1], src[2], 255);
}
}

memcpy(d_8to24table, d_8to24table_opaque, 256*4);
((byte *) &d_8to24table[255]) [3] = 0; //standard palette, 255 is transparent

//fullbright palette, for fence textures
Expand Down Expand Up @@ -1436,7 +1439,7 @@ static void TexMgr_LoadImage8 (gltexture_t *glt, byte *data)
// choose palette and padbyte
if (glt->flags & TEXPREF_ALPHABRIGHT)
{
usepal = gl_fullbrights.value ? d_8to24table_alphabright : d_8to24table;
usepal = gl_fullbrights.value ? d_8to24table_alphabright : d_8to24table_opaque;
padbyte = 0;
}
else if (glt->flags & TEXPREF_FULLBRIGHT)
Expand Down

0 comments on commit 1689ac1

Please sign in to comment.