X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=palette.c;h=c7dd2e85b99a5eb3280d9a66b37b6057e9a6d610;hp=6b4aa922186cc04150160269d18809a5c01f7c8d;hb=f6ceea1f7d2795192dbadb0407fcfcf0d76a923d;hpb=c4ee1bbcc6b2f917465f07269ad09942bbf40849 diff --git a/palette.c b/palette.c index 6b4aa922..c7dd2e85 100644 --- a/palette.c +++ b/palette.c @@ -2,9 +2,7 @@ #include "quakedef.h" unsigned int d_8to24table[256]; -//qbyte d_15to8table[32768]; qbyte host_basepal[768]; -qbyte texgamma[256]; cvar_t v_gamma = {CVAR_SAVE, "v_gamma", "1"}; cvar_t v_contrast = {CVAR_SAVE, "v_contrast", "1"}; @@ -14,8 +12,8 @@ cvar_t v_hwgamma = {0, "v_hwgamma", "1"}; void Palette_Setup8to24(void) { + int i; qbyte *in, *out; - unsigned short i; in = host_basepal; out = (qbyte *) d_8to24table; // d_8to24table is accessed as 32bit for speed reasons, but is created as 8bit bytes @@ -29,38 +27,6 @@ void Palette_Setup8to24(void) d_8to24table[255] = 0; // completely transparent black } -/* -void Palette_Setup15to8(void) -{ - qbyte *pal; - unsigned r,g,b; - unsigned v; - int r1,g1,b1; - int j,k,l; - unsigned short i; - - for (i = 0;i < 32768;i++) - { - r = ((i & 0x001F) << 3)+4; - g = ((i & 0x03E0) >> 2)+4; - b = ((i & 0x7C00) >> 7)+4; - pal = (unsigned char *)d_8to24table; - for (v = 0, k = 0, l = 1000000000;v < 256;v++, pal += 4) - { - r1 = r - pal[0]; - g1 = g - pal[1]; - b1 = b - pal[2]; - j = r1*r1+g1*g1+b1*b1; - if (j < l) - { - k = v; - l = j; - } - } - d_15to8table[i] = k; - } -} -*/ void BuildGammaTable8(float prescale, float gamma, float scale, float base, qbyte *out) { @@ -174,13 +140,37 @@ void Gamma_Init(void) void Palette_Init(void) { + int i; + float gamma, scale, base; qbyte *pal; + qbyte temp[256]; pal = (qbyte *)COM_LoadFile ("gfx/palette.lmp", false); if (!pal) Sys_Error ("Couldn't load gfx/palette.lmp"); memcpy(host_basepal, pal, 765); Mem_Free(pal); host_basepal[765] = host_basepal[766] = host_basepal[767] = 0; // LordHavoc: force the transparent color to black + + gamma = 1; + scale = 1; + base = 0; + i = COM_CheckParm("-texgamma"); + if (i) + gamma = atof(com_argv[i + 1]); + i = COM_CheckParm("-texcontrast"); + if (i) + scale = atof(com_argv[i + 1]); + i = COM_CheckParm("-texbrightness"); + if (i) + base = atof(com_argv[i + 1]); + gamma = bound(0.01, gamma, 10.0); + scale = bound(0.01, scale, 10.0); + base = bound(0, base, 0.95); + + BuildGammaTable8(1.0f, gamma, scale, base, temp); + for (i = 3;i < 765;i++) + host_basepal[i] = temp[host_basepal[i]]; + Palette_Setup8to24(); -// Palette_Setup15to8(); } +