mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
beat sw gamma handling till GL works. after a fasion. it /looks/ like it was
beaten on.
This commit is contained in:
parent
ab9e37654b
commit
ecdd537183
13 changed files with 27 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1103,7 +1103,7 @@ VID_Init (unsigned char *palette)
|
|||
|
||||
VID_InitGamma (palette);
|
||||
VID_Init8bitPalette ();
|
||||
VID_SetPalette (palette);
|
||||
VID_SetPalette (vid.palette);
|
||||
|
||||
vid.initialized = true;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue