1
0
Fork 0
forked from fte/fteqw

only attempt to load npr textures with r_drawflat 2, gamma/contrast use callbacks, vid_hardwaregamma switched to renderer latch (pretty much had to use vid_restart anyway)

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2244 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-06 05:50:33 +00:00
parent 551f37340b
commit 0f2a193838
11 changed files with 74 additions and 126 deletions

View file

@ -220,8 +220,8 @@ extern cvar_t r_novis;
extern cvar_t r_netgraph;
cvar_t r_drawflat = SCVARF("r_drawflat","0", CVAR_SEMICHEAT|CVAR_RENDERERCALLBACK);
cvar_t r_wallcolour = SCVAR("r_wallcolour","1 1 1");
cvar_t r_floorcolour = SCVAR("r_floorcolour","1 1 1");
cvar_t r_wallcolour = SCVARF("r_wallcolour","1 1 1", CVAR_RENDERERCALLBACK);
cvar_t r_floorcolour = SCVARF("r_floorcolour","1 1 1", CVAR_RENDERERCALLBACK);
cvar_t d_palconvwrite = SCVAR("d_palconvwrite", "1");
cvar_t d_palremapsize = SCVARF("d_palremapsize", "64", CVAR_RENDERERLATCH);
@ -263,7 +263,7 @@ cvar_t gl_lightmap_shift = SCVARF("gl_lightmap_shift", "0", CVAR_ARCHIVE | CVAR_
cvar_t gl_menutint_shader = SCVAR("gl_menutint_shader", "1");
extern cvar_t r_waterlayers;
cvar_t gl_triplebuffer = SCVARF("gl_triplebuffer", "1", CVAR_ARCHIVE);
cvar_t vid_hardwaregamma = SCVARF("vid_hardwaregamma", "1", CVAR_ARCHIVE);
cvar_t vid_hardwaregamma = SCVARF("vid_hardwaregamma", "1", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
cvar_t vid_desktopgamma = SCVARF("vid_desktopgamma", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH);
void GLRenderer_Init(void)
@ -1525,8 +1525,6 @@ qboolean R_ApplyRenderer (rendererstate_t *newr)
#ifndef CLIENTONLY
isDedicated = false;
#endif
v_gamma.modified = true; //force the gamma to be reset
Con_Printf("Setting mode %i*%i*%i*%i\n", newr->width, newr->height, newr->bpp, newr->rate);
if (host_basepal)
@ -1602,14 +1600,6 @@ TRACE(("dbg: R_ApplyRenderer: Palette loaded\n"));
}
TRACE(("dbg: R_ApplyRenderer: vid applied\n"));
#ifdef RGLQUAKE //fixme: should we scrap this in favor of only hardware gamma?
if (qrenderer == QR_OPENGL)
GLV_UpdatePalette();
#endif
TRACE(("dbg: R_ApplyRenderer: done palette\n"));
v_gamma.modified = true; //force the gamma to be reset
W_LoadWadFile("gfx.wad");
TRACE(("dbg: R_ApplyRenderer: wad loaded\n"));
Draw_Init();

View file

@ -304,7 +304,7 @@ cshift_t cshift_lava = { {255,80,0}, 150 };
cshift_t cshift_server = { {130,80,50}, 0 };
cvar_t v_gamma = SCVARF("gamma", "0.8", CVAR_ARCHIVE);
cvar_t v_gamma = SCVARF("gamma", "0.8", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK);
cvar_t v_contrast = SCVARF("contrast", "1.4", CVAR_ARCHIVE);
qbyte gammatable[256]; // palette is sent through this
@ -365,18 +365,22 @@ void BuildGammaTable (float g, float c)
V_CheckGamma
=================
*/
void SWV_Gamma_Callback(struct cvar_s *var, char *oldvalue)
{
BuildGammaTable (v_gamma.value, v_contrast.value);
vid.recalc_refdef = 1; // force a surface cache flush
SWV_UpdatePalette (true);
}
void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue)
{
BuildGammaTable (v_gamma.value, v_contrast.value);
vid.recalc_refdef = 1; // force a surface cache flush
GLV_UpdatePalette (true);
}
qboolean V_CheckGamma (void)
{
if (v_gamma.modified || v_contrast.modified)
{
v_contrast.modified = false;
v_gamma.modified = false;
BuildGammaTable (v_gamma.value, v_contrast.value);
vid.recalc_refdef = 1; // force a surface cache flush
return true;
}
return false;
}
@ -678,7 +682,7 @@ void GLV_CalcBlend (void)
V_UpdatePalette
=============
*/
void GLV_UpdatePalette (void)
void GLV_UpdatePalette (qboolean force)
{
qboolean ogw;
int i, j;
@ -687,10 +691,6 @@ void GLV_UpdatePalette (void)
// qbyte pal[768];
float r,g,b,a;
int ir, ig, ib;
qboolean force;
extern cvar_t vid_hardwaregamma;
float hwg;
RSpeedMark();
@ -723,54 +723,39 @@ void GLV_UpdatePalette (void)
}
}
force = V_CheckGamma ();
hwg = vid_hardwaregamma.value;
if (vid_hardwaregamma.modified && !hwg)
if (new || force)
{
vid_hardwaregamma.value = hwg;
force = true;
}
GLV_CalcBlend ();
if (!new && !force)
{
RSpeedEnd(RSPEED_PALETTEFLASHES);
return;
}
a = v_blend[3];
r = 255*v_blend[0]*a;
g = 255*v_blend[1]*a;
b = 255*v_blend[2]*a;
GLV_CalcBlend ();
a = 1-a;
for (i=0 ; i<256 ; i++)
{
ir = i*a + r;
ig = i*a + g;
ib = i*a + b;
if (ir > 255)
ir = 255;
if (ig > 255)
ig = 255;
if (ib > 255)
ib = 255;
//Con_Printf("b: %4.2f %4.2f %4.2f %4.6f\n", v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
ramps[0][i] = gammatable[ir]<<8;
ramps[1][i] = gammatable[ig]<<8;
ramps[2][i] = gammatable[ib]<<8;
}
a = v_blend[3];
r = 255*v_blend[0]*a;
g = 255*v_blend[1]*a;
b = 255*v_blend[2]*a;
a = 1-a;
for (i=0 ; i<256 ; i++)
{
ir = i*a + r;
ig = i*a + g;
ib = i*a + b;
if (ir > 255)
ir = 255;
if (ig > 255)
ig = 255;
if (ib > 255)
ib = 255;
ramps[0][i] = gammatable[ir]<<8;
ramps[1][i] = gammatable[ig]<<8;
ramps[2][i] = gammatable[ib]<<8;
}
ogw = gammaworks;
VID_ShiftPalette (NULL);
vid_hardwaregamma.value = hwg;
if (ogw != gammaworks)
{
Con_DPrintf("Gamma working state %i\n", gammaworks);
ogw = gammaworks;
VID_ShiftPalette (NULL);
if (ogw != gammaworks)
{
Con_DPrintf("Gamma working state %i\n", gammaworks);
}
}
RSpeedEnd(RSPEED_PALETTEFLASHES);
@ -782,21 +767,18 @@ V_UpdatePalette
=============
*/
#ifdef SWQUAKE
void SWV_UpdatePalette (void)
void SWV_UpdatePalette (qboolean force)
{
int i, j;
qboolean new;
qbyte *basepal, *newpal;
qbyte pal[768];
int r,g,b;
qboolean force;
V_CalcPowerupCshift ();
new = false;
force = V_CheckGamma ();
for (i=0 ; i<NUM_CSHIFTS ; i++)
{
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)

View file

@ -29,8 +29,8 @@ extern qboolean r_secondaryview;
void V_Init (void);
void V_RenderView (void);
float V_CalcRoll (vec3_t angles, vec3_t velocity);
void GLV_UpdatePalette (void);
void SWV_UpdatePalette (void);
void GLV_UpdatePalette (qboolean force);
void SWV_UpdatePalette (qboolean force);
qboolean V_CheckGamma (void);
void V_AddEntity(entity_t *in);
void V_AddLerpEntity(entity_t *in);

View file

@ -1262,6 +1262,9 @@ void GLR_Drawflat_Callback(struct cvar_s *var, char *oldvalue)
{
int i;
if (var->value != 2)
return;
for (i = 0; i < sizeof(nprtextures)/sizeof(nprtextures[0]); i++)
{
nprtextures[i] = Mod_LoadHiResTexture(va("sketch%i", i+1), "sketch", true, false, false);

View file

@ -654,7 +654,7 @@ if (!data)
*/
void GLR_TimeRefresh_f (void);
extern cvar_t gl_bump;
extern cvar_t gl_bump, v_contrast;
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount;
// callback defines
@ -677,6 +677,7 @@ void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue);
void GLR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue);
void GLR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue);
void GLR_Drawflat_Callback(struct cvar_s *var, char *oldvalue);
void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue);
void GLR_DeInit (void)
{
@ -701,6 +702,8 @@ void GLR_DeInit (void)
Cvar_Unhook(&r_wallcolour);
Cvar_Unhook(&r_floorcolour);
Cvar_Unhook(&r_drawflat);
Cvar_Unhook(&v_gamma);
Cvar_Unhook(&v_contrast);
GLDraw_DeInit();
@ -729,6 +732,8 @@ void GLR_Init (void)
Cvar_Hook(&r_floorcolour, GLR_Floorcolour_Callback);
Cvar_Hook(&r_wallcolour, GLR_Wallcolour_Callback);
Cvar_Hook(&r_drawflat, GLR_Drawflat_Callback);
Cvar_Hook(&v_gamma, GLV_Gamma_Callback);
Cvar_Hook(&v_contrast, GLV_Gamma_Callback);
R_InitBubble();

View file

@ -255,7 +255,7 @@ void GLSCR_UpdateScreen (void)
if (editormodal)
{
Editor_Draw();
GLV_UpdatePalette ();
GLV_UpdatePalette (false);
#if defined(_WIN32) && defined(RGLQUAKE)
Media_RecordFrame();
#endif
@ -272,7 +272,7 @@ void GLSCR_UpdateScreen (void)
if (Media_ShowFilm())
{
M_Draw(0);
GLV_UpdatePalette ();
GLV_UpdatePalette (false);
#if defined(_WIN32) && defined(RGLQUAKE)
Media_RecordFrame();
#endif
@ -323,7 +323,7 @@ void GLSCR_UpdateScreen (void)
SCR_DrawTwoDimensional(uimenu, nohud);
GLV_UpdatePalette ();
GLV_UpdatePalette (false);
#if defined(_WIN32) && defined(RGLQUAKE)
Media_RecordFrame();
#endif

View file

@ -456,7 +456,7 @@ static void GetEvent(void)
break;
case FocusIn:
v_gamma.modified = true;
Cvar_ForceCallback(&v_gamma);
ActiveApp = true;
#ifdef WITH_VMODE
if (vidmode_ext && vidmode_usemode>=0)

View file

@ -1245,7 +1245,7 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
IN_HideMouse ();
}
v_gamma.modified = true; //so that we can start doing palette flashes and things
Cvar_ForceCallback(&v_gamma);
}
if (!fActive)
@ -1265,7 +1265,7 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
IN_ShowMouse ();
}
v_gamma.modified = true; //wham bam thanks.
Cvar_ForceCallback(&v_gamma); //wham bam thanks.
if (qSetDeviceGammaRamp)
{
@ -1282,8 +1282,6 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
}
}
vid_hardwaregamma.modified = true;
return true;
}
@ -1503,39 +1501,6 @@ void VID_Init8bitPalette()
is8bit = TRUE;
}
static void Check_Gamma (unsigned char *pal, float usegammaval)
{
// float f, inf;
// unsigned char palette[768];
// int i;
/*
if (usegammaval)
vid_gamma = usegammaval;
else 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 = Q_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));
*/
}
void GLVID_DeInit (void)
{
GLVID_Shutdown();
@ -1587,7 +1552,6 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
if (hwnd_dialog)
DestroyWindow (hwnd_dialog);
Check_Gamma(palette, 0);
VID_SetPalette (palette);
if (!GLVID_SetMode (info, palette))

View file

@ -71,7 +71,6 @@ int D_MipLevelForScale (float scale)
return lmiplevel;
}
/*
==============
D_DrawSolidSurface

View file

@ -204,10 +204,11 @@ void SWR_InitTextures (void)
}*/
// callback declares
extern cvar_t crosshaircolor, r_skyboxname, r_menutint;
extern cvar_t crosshaircolor, r_skyboxname, r_menutint, v_contrast;
void SWCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue);
void SWV_Gamma_Callback(struct cvar_s *var, char *oldvalue);
void SWR_DeInit (void)
{
@ -217,6 +218,8 @@ void SWR_DeInit (void)
Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint);
Cvar_Unhook(&v_gamma);
Cvar_Unhook(&v_contrast);
SWDraw_Shutdown();
D_Shutdown();
@ -241,6 +244,8 @@ void SWR_Init (void)
Cvar_Hook(&crosshaircolor, SWCrosshaircolor_Callback);
Cvar_Hook(&r_skyboxname, SWR_Skyboxname_Callback);
Cvar_Hook(&r_menutint, SWR_Menutint_Callback);
Cvar_Hook(&v_gamma, SWV_Gamma_Callback);
Cvar_Hook(&v_contrast, SWV_Gamma_Callback);
if (!r_maxedges.value)
Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES);

View file

@ -86,7 +86,7 @@ void SWSCR_UpdateScreen (void)
if (editormodal)
{
Editor_Draw();
SWV_UpdatePalette ();
SWV_UpdatePalette (false);
vrect.x = 0;
vrect.y = 0;
@ -100,7 +100,7 @@ void SWSCR_UpdateScreen (void)
#endif
if (Media_ShowFilm())
{
SWV_UpdatePalette ();
SWV_UpdatePalette (false);
vrect.x = 0;
vrect.y = 0;
@ -156,7 +156,7 @@ void SWSCR_UpdateScreen (void)
D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
// for linear writes all the time
SWV_UpdatePalette ();
SWV_UpdatePalette (false);
//
// update one of three areas