beat sw gamma handling till GL works. after a fasion. it /looks/ like it was

beaten on.
This commit is contained in:
Bill Currie 2002-09-10 06:35:32 +00:00
parent ab9e37654b
commit ecdd537183
13 changed files with 27 additions and 21 deletions

View file

@ -54,6 +54,7 @@ typedef struct {
void *buffer; // invisible buffer
short *zbuffer;
void *surfcache;
byte *basepal; // 256 * 3
byte *palette; // 256 * 3
byte *colormap8; // 256 * VID_GRADES size
unsigned short *colormap16; // 256 * VID_GRADES size

View file

@ -350,7 +350,7 @@ SCR_ApplyBlend (void) // Used to be V_UpdatePalette
int r, g, b, i;
byte *basepal, *newpal;
byte pal[768];
basepal = vid.palette;
basepal = vid.basepal;
newpal = pal;
for (i = 0; i < 256; i++) {

View file

@ -354,7 +354,7 @@ SCR_ApplyBlend (void) // Used to be V_UpdatePalette
switch(r_pixbytes) {
case 1:
{
basepal = vid.palette;
basepal = vid.basepal;
newpal = pal;
for (i = 0; i < 256; i++) {

View file

@ -31,6 +31,12 @@ static const char rcsid[] =
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <math.h>
#include "QF/console.h"
@ -146,16 +152,14 @@ VID_UpdateGamma (cvar_t *vid_gamma)
Con_DPrintf ("Setting hardware gamma to %g\n", gamma);
VID_BuildGammaTable (1.0); // hardware gamma wants a linear palette
VID_SetGamma (gamma);
memcpy (vid.palette, vid.basepal, 256 * 3);
} else { // We have to hack the palette
int i;
byte pal[768];
Con_DPrintf ("Setting software gamma to %g\n", gamma);
VID_BuildGammaTable (gamma);
if (vid.initialized) {
for (i = 0; i < sizeof (pal); i++)
pal[i] = gammatable[vid.palette[i]];
VID_SetPalette (pal); // update with the new palette
}
for (i = 0; i < 256 * 3; i++)
vid.palette[i] = gammatable[vid.basepal[i]];
VID_SetPalette (vid.palette); // update with the new palette
}
}
@ -170,7 +174,8 @@ VID_InitGamma (unsigned char *pal)
int i;
double gamma = 1.45;
vid.palette = pal;
vid.basepal = pal;
vid.palette = malloc (256 * 3);
if ((i = COM_CheckParm ("-gamma"))) {
gamma = atof (com_argv[i + 1]);
}

View file

@ -343,7 +343,7 @@ VID_Init (unsigned char *palette)
GL_Init ();
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
// Check for 3DFX Extensions and initialize them.
VID_Init8bitPalette ();

View file

@ -523,7 +523,7 @@ VID_Init (unsigned char *palette)
Con_CheckResize (); // Now that we have a window size, fix console
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
vid.initialized = true;
}

View file

@ -250,7 +250,7 @@ VID_Init (unsigned char *palette)
// Check for 8-bit extension and initialize if present
VID_Init8bitPalette ();
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);

View file

@ -103,7 +103,7 @@ VID_Init (unsigned char *palette)
if (!(screen = SDL_SetVideoMode (vid.width, vid.height, 8, flags)))
Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ());
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
// now know everything we need to know about the buffer
VGA_width = vid.conwidth = vid.width;

View file

@ -115,7 +115,7 @@ VID_Init (unsigned char *palette)
vid_bitdepth->int_val, flags)))
Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ());
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
switch (vid_bitdepth->int_val) {
case 8:

View file

@ -172,7 +172,7 @@ VID_Init (unsigned char *palette)
VID_SDL_GammaCheck ();
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
VID_Init8bitPalette (); // Check for 3DFX Extensions and initialize them.

View file

@ -498,7 +498,7 @@ VID_Init (unsigned char *palette)
Con_CheckResize (); // Now that we have a window size, fix console
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
vid.initialized = true;
}

View file

@ -1103,7 +1103,7 @@ VID_Init (unsigned char *palette)
VID_InitGamma (palette);
VID_Init8bitPalette ();
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
vid.initialized = true;

View file

@ -502,7 +502,7 @@ VID_Init (unsigned char *palette)
}
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetPalette (vid.palette);
// create the GC
{
@ -580,9 +580,9 @@ VID_SetPalette (unsigned char *palette)
for (i = 0; i < 256; i++) {
colors[i].pixel = i;
colors[i].flags = DoRed | DoGreen | DoBlue;
colors[i].red = gammatable[(byte) palette[(i * 3)]] << 8;
colors[i].green = gammatable[(byte) palette[(i * 3) + 1]] << 8;
colors[i].blue = gammatable[(byte) palette[(i * 3) + 2]] << 8;
colors[i].red = palette[(i * 3)] << 8;
colors[i].green = palette[(i * 3) + 1] << 8;
colors[i].blue = palette[(i * 3) + 2] << 8;
}
XStoreColors (x_disp, x_cmap, colors, 256);
}