{
if (!strcmp(path, "gfx/conchars"))
{
- unsigned char *pix;
- // conchars is a raw image and with the wrong transparent color
- pix = (unsigned char *)p;
- for (i = 0;i < 128 * 128;i++)
- if (pix[i] == 0)
- pix[i] = 255;
- pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, pix, TEXTYPE_PALETTE, flags, palette_complete);
+ // conchars is a raw image and with color 0 as transparent instead of 255
+ pic->tex = R_LoadTexture2D(drawtexturepool, path, 128, 128, (unsigned char *)p, TEXTYPE_PALETTE, flags, palette_font);
}
else
- pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, flags, palette_complete);
+ pic->tex = R_LoadTexture2D(drawtexturepool, path, p->width, p->height, p->data, TEXTYPE_PALETTE, flags, palette_transparent);
}
}
else
{
image_buffer = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
- Image_Copy8bitRGBA(f + 8, image_buffer, image_width * image_height, palette_complete);
+ Image_Copy8bitRGBA(f + 8, image_buffer, image_width * image_height, palette_transparent);
}
return image_buffer;
}
menuplyr_bottom = setup_bottom;
M_BuildTranslationTable(menuplyr_top*16, menuplyr_bottom*16);
for (i = 0;i < menuplyr_width * menuplyr_height;i++)
- menuplyr_translated[i] = palette_complete[translationTable[menuplyr_pixels[i]]];
+ menuplyr_translated[i] = palette_transparent[translationTable[menuplyr_pixels[i]]];
Draw_NewPic("gfx/menuplyr", menuplyr_width, menuplyr_height, true, (unsigned char *)menuplyr_translated);
}
M_DrawPic(160, 48, "gfx/bigbox");
Mem_Free(temp1);
}
// use either a custom palette, or the quake palette
- if (palette)
- skinframe->base = skinframe->merged = GL_TextureForSkinLayer(skindata, width, height, va("%s_merged", basename), palette, textureflags); // all
- else if (loadglowtexture)
- {
+ skinframe->base = skinframe->merged = GL_TextureForSkinLayer(skindata, width, height, va("%s_merged", basename), palette ? palette : (loadglowtexture ? palette_nofullbrights : palette_complete), textureflags); // all
+ if (!palette && loadglowtexture)
skinframe->glow = GL_TextureForSkinLayer(skindata, width, height, va("%s_glow", basename), palette_onlyfullbrights, textureflags); // glow
- skinframe->base = skinframe->merged = GL_TextureForSkinLayer(skindata, width, height, va("%s_merged", basename), palette_nofullbrights, textureflags); // all but fullbrights
- if (loadpantsandshirt)
- {
- skinframe->pants = GL_TextureForSkinLayer(skindata, width, height, va("%s_pants", basename), palette_pantsaswhite, textureflags); // pants
- skinframe->shirt = GL_TextureForSkinLayer(skindata, width, height, va("%s_shirt", basename), palette_shirtaswhite, textureflags); // shirt
- if (skinframe->pants || skinframe->shirt)
- skinframe->base = GL_TextureForSkinLayer(skindata, width, height, va("%s_nospecial", basename), palette_nocolormapnofullbrights, textureflags); // no special colors
- }
- }
- else
+ if (!palette && loadpantsandshirt)
{
- skinframe->base = skinframe->merged = GL_TextureForSkinLayer(skindata, width, height, va("%s_merged", basename), palette_complete, textureflags); // all
- if (loadpantsandshirt)
- {
- skinframe->pants = GL_TextureForSkinLayer(skindata, width, height, va("%s_pants", basename), palette_pantsaswhite, textureflags); // pants
- skinframe->shirt = GL_TextureForSkinLayer(skindata, width, height, va("%s_shirt", basename), palette_shirtaswhite, textureflags); // shirt
- if (skinframe->pants || skinframe->shirt)
- skinframe->base = GL_TextureForSkinLayer(skindata, width, height, va("%s_nospecial", basename), palette_nocolormap, textureflags); // no pants or shirt
- }
+ skinframe->pants = GL_TextureForSkinLayer(skindata, width, height, va("%s_pants", basename), palette_pantsaswhite, textureflags); // pants
+ skinframe->shirt = GL_TextureForSkinLayer(skindata, width, height, va("%s_shirt", basename), palette_shirtaswhite, textureflags); // shirt
}
+ if (skinframe->pants || skinframe->shirt)
+ skinframe->base = GL_TextureForSkinLayer(skindata, width, height, va("%s_nospecial", basename),loadglowtexture ? palette_nocolormapnofullbrights : palette_nocolormap, textureflags); // no special colors
if (textureflags & TEXF_ALPHA)
{
// if not using a custom alphapalette, use the quake one
#include "quakedef.h"
unsigned int palette_complete[256];
+unsigned int palette_font[256];
+unsigned int palette_alpha[256];
+unsigned int palette_nocolormap[256];
+unsigned int palette_nocolormapnofullbrights[256];
unsigned int palette_nofullbrights[256];
unsigned int palette_onlyfullbrights[256];
-unsigned int palette_nocolormapnofullbrights[256];
-unsigned int palette_nocolormap[256];
unsigned int palette_pantsaswhite[256];
unsigned int palette_shirtaswhite[256];
-unsigned int palette_alpha[256];
-unsigned int palette_font[256];
+unsigned int palette_transparent[256];
// John Carmack said the quake palette.lmp can be considered public domain because it is not an important asset to id, so I include it here as a fallback if no external palette file is found.
unsigned char host_quakepal[768] =
int pants_start, pants_end;
int shirt_start, shirt_end;
int reversed_start, reversed_end;
+ int transparentcolor;
unsigned char *colormap;
fs_offset_t filesize;
shirt_end = 32;
reversed_start = 128;
reversed_end = 224;
+ transparentcolor = 255;
+
+ for (i = 0;i < 256;i++)
+ palette_transparent[i] = palette_complete[i];
+ palette_transparent[transparentcolor] = 0;
for (i = 0;i < fullbright_start;i++)
palette_nofullbrights[i] = palette_complete[i];
- for (i = fullbright_start;i < 255;i++)
+ for (i = fullbright_start;i < fullbright_end;i++)
palette_nofullbrights[i] = palette_complete[0];
- palette_nofullbrights[255] = 0;
for (i = 0;i < 256;i++)
palette_onlyfullbrights[i] = palette_complete[0];
for (i = fullbright_start;i < fullbright_end;i++)
palette_onlyfullbrights[i] = palette_complete[i];
- palette_onlyfullbrights[255] = 0;
for (i = 0;i < 256;i++)
palette_nocolormapnofullbrights[i] = palette_complete[i];
palette_nocolormapnofullbrights[i] = palette_complete[0];
for (i = fullbright_start;i < fullbright_end;i++)
palette_nocolormapnofullbrights[i] = palette_complete[0];
- palette_nocolormapnofullbrights[255] = 0;
for (i = 0;i < 256;i++)
palette_nocolormap[i] = palette_complete[i];
palette_nocolormap[i] = palette_complete[0];
for (i = shirt_start;i < shirt_end;i++)
palette_nocolormap[i] = palette_complete[0];
- palette_nocolormap[255] = 0;
for (i = 0;i < 256;i++)
palette_pantsaswhite[i] = palette_complete[0];
palette_shirtaswhite[i] = palette_complete[i - shirt_start];
}
- for (i = 0;i < 255;i++)
+ for (i = 0;i < 256;i++)
palette_alpha[i] = 0xFFFFFFFF;
- palette_alpha[255] = 0;
+ palette_alpha[transparentcolor] = 0;
- palette_font[0] = 0;
- for (i = 1;i < 255;i++)
+ for (i = 0;i < 256;i++)
palette_font[i] = palette_complete[i];
- palette_font[255] = 0;
+ palette_font[0] = 0;
}
void BuildGammaTable8(float prescale, float gamma, float scale, float base, unsigned char *out)
in = host_quakepal;
}
out = (unsigned char *) palette_complete; // palette is accessed as 32bit for speed reasons, but is created as 8bit bytes
- for (i = 0;i < 255;i++)
+ for (i = 0;i < 256;i++)
{
*out++ = texturegammaramp[*in++];
*out++ = texturegammaramp[*in++];
*out++ = texturegammaramp[*in++];
*out++ = 255;
}
- palette_complete[255] = 0; // completely transparent black
if (palfile)
Mem_Free(palfile);
#define PALLETE_H
extern unsigned int palette_complete[256];
+extern unsigned int palette_font[256];
+extern unsigned int palette_alpha[256];
+extern unsigned int palette_nocolormap[256];
+extern unsigned int palette_nocolormapnofullbrights[256];
extern unsigned int palette_nofullbrights[256];
extern unsigned int palette_onlyfullbrights[256];
-extern unsigned int palette_nocolormapnofullbrights[256];
-extern unsigned int palette_nocolormap[256];
extern unsigned int palette_pantsaswhite[256];
extern unsigned int palette_shirtaswhite[256];
-extern unsigned int palette_alpha[256];
-extern unsigned int palette_font[256];
+extern unsigned int palette_transparent[256];
// used by hardware gamma functions in vid_* files
void BuildGammaTable8(float prescale, float gamma, float scale, float base, unsigned char *out);