improve colormap generation for 16-bpp software

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2085 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-03-11 07:55:04 +00:00
parent 768b92f08b
commit 09998a6f7a
2 changed files with 29 additions and 6 deletions

View file

@ -77,6 +77,7 @@ void R_GammaCorrectAndSetPalette(const unsigned char *pal)
{
extern qbyte gammatable[256];
int j, i;
int r, g, b;
float f;
unsigned short *data;
r_flushcache++;
@ -87,11 +88,22 @@ void R_GammaCorrectAndSetPalette(const unsigned char *pal)
{
f = (1 - ((float)j/VID_GRADES));
f = (float)gammatable[(int)(f*255)]/255;
f *= 2;
for (i = 0; i < 256; i++)
{
data[i] = ((int)(pal[i*3+0]*f*(1<<redbits)/256)<<redshift) +
((int)(pal[i*3+1]*f*(1<<greenbits)/256)<<greenshift) +
((int)(pal[i*3+2]*f*(1<<bluebits)/256)<<blueshift);
r = pal[i*3+0]*f;
g = pal[i*3+1]*f;
b = pal[i*3+2]*f;
if (r > 255)
r = 255;
if (g > 255)
g = 255;
if (b > 255)
b = 255;
r >>= 8 - redbits;
g >>= 8 - greenbits;
b >>= 8 - bluebits;
data[i] = (r<<redshift) + (g<<greenshift) + (b<<blueshift);
}
data+=256;
}

View file

@ -703,11 +703,22 @@ printf("%8x\n", (int)vid_dpy);
{
f = (1 - ((float)j/VID_GRADES));
f = (float)gammatable[(int)(f*255)]/255;
f *= 2;
for (i = 0; i < 256; i++)
{
data[i] = ((int)(pal[i*3+0]*f*(1<<redbits)/256)<<redshift) +
((int)(pal[i*3+1]*f*(1<<greenbits)/256)<<greenshift) +
((int)(pal[i*3+2]*f*(1<<bluebits)/256)<<blueshift);
r = pal[i*3+0]*f;
g = pal[i*3+1]*f;
b = pal[i*3+2]*f;
if (r > 255)
r = 255;
if (g > 255)
g = 255;
if (b > 255)
b = 255;
r >>= 8 - redbits;
g >>= 8 - greenbits;
b >>= 8 - bluebits;
data[i] = (r<<redshift) + (g<<greenshift) + (b<<blueshift);
}
data+=256;
}