vid_gamma now seems to work :)

This commit is contained in:
Bill Currie 2001-04-23 04:16:17 +00:00
parent bd06625c55
commit 6a75c4e00d
12 changed files with 19 additions and 37 deletions

View file

@ -114,4 +114,6 @@ double VID_GetGamma (void);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);
extern struct cvar_s *vid_gamma;
#endif // __vid_h_

View file

@ -273,7 +273,10 @@ V_CheckGamma (void)
{
static float oldbrightness;
static float oldcontrast;
static float oldgamma;
if (oldgamma != vid_gamma->value)
VID_UpdateGamma (vid_gamma);
if ((brightness->value == oldbrightness) && contrast->value == oldcontrast)
return false;
oldbrightness = brightness->value;

View file

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

View file

@ -617,6 +617,7 @@ VID_Init (unsigned char *palette)
VID_SetMode (current_mode.name, palette);
Con_CheckResize (); // Now that we have a window size, fix console
VID_InitGamma (palette);
VID_SetPalette (palette);
}
}

View file

@ -354,6 +354,7 @@ VID_Init (unsigned char *pal)
}
}
VID_InitGamma (palette);
VID_SetPalette (pal);
usedbuf = havedbuf = 0;

View file

@ -204,6 +204,7 @@ VID_Init (unsigned char *palette)
GL_Init ();
GL_CheckBrightness (palette);
VID_InitGamma (palette);
VID_SetPalette (palette);
// Check for 8-bit extension and initialize if present

View file

@ -2062,6 +2062,7 @@ VID_Init (unsigned char *palette)
vid_realmode = vid_modenum;
VID_InitGamma (palette);
VID_SetPalette (palette);
vid_menudrawfn = VID_MenuDraw;

View file

@ -157,6 +157,7 @@ VID_Init (unsigned char *palette)
// Initialize display
if (!(screen = SDL_SetVideoMode (vid.width, vid.height, 8, flags)))
Sys_Error ("VID: Couldn't set video mode: %s\n", SDL_GetError ());
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetCaption ("");

View file

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

View file

@ -602,6 +602,7 @@ VID_Init (unsigned char *palette)
VID_SetMode (current_mode, palette);
Con_CheckResize (); // Now that we have a window size, fix console
VID_InitGamma (palette);
VID_SetPalette (palette);
}
}

View file

@ -1613,6 +1613,7 @@ VID_Init (unsigned char *palette)
#endif
GL_CheckBrightness (palette);
VID_InitGamma (palette);
VID_SetPalette (palette);
VID_SetMode (vid_default, palette);

View file

@ -302,38 +302,6 @@ D_EndDirectRect (int x, int y, int width, int height)
}
/*
VID_Gamma_f
Keybinding command
*/
byte vid_gamma[256];
void
VID_Gamma_f (void)
{
float g, f, inf;
int i;
if (Cmd_Argc () == 2) {
g = atof (Cmd_Argv (1));
for (i = 0; i < 255; i++) {
f = pow ((i + 1) / 256.0, g);
inf = f * 255 + 0.5;
inf = bound (0, inf, 255);
vid_gamma[i] = inf;
}
VID_SetPalette (current_palette);
vid.recalc_refdef = 1; // force a surface cache flush
}
}
static void
ResetFrameBuffer (void)
{
@ -501,8 +469,6 @@ VID_Init (unsigned char *palette)
// plugin_load ("in_x11.so");
// Cmd_AddCommand ("gamma", VID_Gamma_f, "Change brightness level");
for (i = 0; i < 256; i++)
vid_gamma[i] = i;
vid.width = vid_width->int_val;
vid.height = vid_height->int_val;
@ -575,6 +541,8 @@ VID_Init (unsigned char *palette)
/* Invisible cursor */
X11_CreateNullCursor ();
VID_InitGamma (palette);
VID_SetPalette (palette);
if (x_visinfo->depth == 8) {
/* Create and upload the palette */
if (x_visinfo->class == PseudoColor) {
@ -677,9 +645,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 = vid_gamma[palette[i * 3]] * 256;
colors[i].green = vid_gamma[palette[i * 3 + 1]] * 256;
colors[i].blue = vid_gamma[palette[i * 3 + 2]] * 256;
colors[i].red = gammatable[palette[i * 3]] * 256;
colors[i].green = gammatable[palette[i * 3 + 1]] * 256;
colors[i].blue = gammatable[palette[i * 3 + 2]] * 256;
}
XStoreColors (x_disp, x_cmap, colors, 256);
}