-gamma for Linux! No you can't control it from the menu, it has to be

done on the cmdline at the moment.  Menu support later if possible.
This commit is contained in:
Joseph Carter 2000-05-31 17:46:59 +00:00
parent de18dc1c84
commit 0f9bcaf22f
4 changed files with 41 additions and 31 deletions

View file

@ -263,6 +263,7 @@ void GL_Set2D (void);
//
// gl_rmain.c
//
void GL_CheckGamma (unsigned char *pal);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
void R_RotateForEntity (entity_t *e);

View file

@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "qargs.h"
#include "bothdefs.h"
#include "commdef.h"
#include "console.h"
@ -123,6 +124,42 @@ cvar_t *r_skyname;
extern cvar_t *gl_ztrick;
extern cvar_t *scr_fov;
//byte gamma[256];
//byte lightgamma[1024];
static float vid_gamma = 1.0;
void
GL_CheckGamma (unsigned char *pal)
{
float f, inf;
unsigned char palette[768];
int i;
if ((i = COM_CheckParm("-gamma")) == 0) {
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
(gl_vendor && strstr(gl_vendor, "3Dfx")))
vid_gamma = 1;
else
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
} else
vid_gamma = atof(com_argv[i+1]);
for (i=0 ; i<768 ; i++)
{
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
inf = f*255 + 0.5;
if (inf < 0)
inf = 0;
if (inf > 255)
inf = 255;
palette[i] = inf;
}
memcpy (pal, palette, sizeof(palette));
}
/*
=================
R_CullBox

View file

@ -597,7 +597,8 @@ void VID_Init(unsigned char *palette)
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
Sys_mkdir (gldir);
VID_SetPalette(palette);
GL_CheckGamma (palette);
VID_SetPalette (palette);
// Check for 3DFX Extensions and initialize them.
VID_Init8bitPalette();

View file

@ -1567,35 +1567,6 @@ void VID_Init8bitPalette()
is8bit = TRUE;
}
static void Check_Gamma (unsigned char *pal)
{
float f, inf;
unsigned char palette[768];
int i;
if ((i = COM_CheckParm("-gamma")) == 0) {
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
(gl_vendor && strstr(gl_vendor, "3Dfx")))
vid_gamma = 1;
else
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
} else
vid_gamma = atof(com_argv[i+1]);
for (i=0 ; i<768 ; i++)
{
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
inf = f*255 + 0.5;
if (inf < 0)
inf = 0;
if (inf > 255)
inf = 255;
palette[i] = inf;
}
memcpy (pal, palette, sizeof(palette));
}
/*
===================
VID_Init
@ -1830,7 +1801,7 @@ void VID_Init (unsigned char *palette)
DestroyWindow (hwnd_dialog);
Check_Gamma(palette);
GL_CheckGamma(palette);
VID_SetPalette (palette);
VID_SetMode (vid_default, palette);