r_menutint added, changes background tint for gl and sw

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1394 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-09-29 23:20:29 +00:00
parent f7425dd4d7
commit 12a172bc95
3 changed files with 203 additions and 11 deletions

View File

@ -234,6 +234,8 @@ extern cvar_t r_waterlayers;
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", NULL, CVAR_ARCHIVE};
cvar_t vid_hardwaregamma = {"vid_hardwaregamma", "1", NULL, CVAR_ARCHIVE};
cvar_t r_menutint = {"r_menutint", "0.68 0.4 0.13"};
void GLRenderer_Init(void)
{
extern cvar_t gl_contrast;
@ -520,6 +522,7 @@ void Renderer_Init(void)
Cvar_Register (&r_fastskycolour, GRAPHICALNICETIES);
Cvar_Register (&r_drawflat, GRAPHICALNICETIES);
Cvar_Register (&r_menutint, GRAPHICALNICETIES);
//bulletens
Cvar_Register(&bul_nowater, BULLETENVARS);

View File

@ -1320,8 +1320,33 @@ void GLDraw_Crosshair(void)
if (crosshair.modified || crosshaircolor.modified || crosshair.value >= FIRSTANIMATEDCROSHAIR)
{
int c = d_8to24rgbtable[(qbyte) crosshaircolor.value];
int c2 = d_8to24rgbtable[(qbyte) crosshaircolor.value];
char *t;
int c, c2, i;
t = strstr(crosshaircolor.string, " ");
if (!t) // use standard coloring
c = d_8to24rgbtable[(qbyte) crosshaircolor.value];
else // use RGB coloring
{
t++;
// abusing the fact that atof considers whitespace to be a delimiter...
i = crosshaircolor.value;
i = bound(0, i, 255);
c = i; // red channel (first 8 bits)
i = atoi(t);
i = bound(0, i, 255);
c |= (i << 8); // green channel
t = strstr(t, " "); // find last value
if (t)
{
i = atoi(t+1);
i = bound(0, i, 255);
c |= (i << 16); // blue channel
}
c |= 0xff000000; // alpha channel (always full)
} // i contains the crosshair color
c2 = c;
crosshair.modified = false;
crosshaircolor.modified = false;
@ -1874,12 +1899,73 @@ Draw_FadeScreen
================
*/
vec3_t fadecolor;
int faderender;
int fademodified;
void GLDraw_FadeScreen (void)
{
extern cvar_t r_menutint;
if (fademodified != r_menutint.modified)
{
char *t;
// parse r_menutint and clear defaults
fadecolor[0] = r_menutint.value;
fadecolor[1] = 0;
fadecolor[2] = 0;
faderender = GL_DST_COLOR;
t = strstr(r_menutint.string, " ");
if (t)
{
fadecolor[1] = atof(t+1);
t = strstr(t+1, " ");
if (t)
fadecolor[2] = atof(t+1);
}
// bounds check and inverse check
if (fadecolor[0] < 0)
{
faderender = GL_ONE_MINUS_DST_COLOR;
fadecolor[0] = -(fadecolor[0]);
}
if (fadecolor[0] > 1)
fadecolor[0] = 1;
if (fadecolor[1] < 0)
{
faderender = GL_ONE_MINUS_DST_COLOR;
fadecolor[1] = -(fadecolor[1]);
}
if (fadecolor[1] > 1)
fadecolor[1] = 1;
if (fadecolor[2] < 0)
{
faderender = GL_ONE_MINUS_DST_COLOR;
fadecolor[2] = -(fadecolor[2]);
}
if (fadecolor[2] > 1)
fadecolor[2] = 1;
if (faderender == GL_DST_COLOR && fadecolor[0] == 1 && fadecolor[1] == 1 && fadecolor[2] == 1)
faderender = 0;
fademodified = r_menutint.modified;
}
if (!faderender)
return;
qglEnable (GL_BLEND);
qglBlendFunc(faderender, GL_ZERO);
qglDisable(GL_ALPHA_TEST);
qglDisable (GL_TEXTURE_2D);
qglColor4f (0, 0, 0, 0.5);
qglColor4f (fadecolor[0], fadecolor[1], fadecolor[2], 1);
qglBegin (GL_QUADS);
qglVertex2f (0,0);
@ -1891,6 +1977,7 @@ void GLDraw_FadeScreen (void)
qglColor4f (1,1,1,1);
qglEnable (GL_TEXTURE_2D);
qglDisable (GL_BLEND);
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
qglEnable(GL_ALPHA_TEST);
Sbar_Changed();

View File

@ -62,6 +62,8 @@ typedef struct cachepic_s
swcachepic_t swmenu_cachepics[MAX_CACHED_PICS];
int swmenu_numcachepics;
qbyte sw_crosshaircolor;
/*
================
Draw_CachePic
@ -861,11 +863,42 @@ void SWDraw_Crosshair(void)
int x, y;
extern cvar_t crosshair, cl_crossx, cl_crossy, crosshaircolor;
extern vrect_t scr_vrect;
qbyte c = (qbyte)crosshaircolor.value;
qbyte c2 = (qbyte)crosshaircolor.value;
qbyte c, c2;
int sc;
if (crosshaircolor.modified)
{ // redo color every modification to crosshaircolor
char *t;
t = strstr(crosshaircolor.string, " ");
if (!t) // use standard coloring
sw_crosshaircolor = (qbyte) crosshaircolor.value;
else // use RGB coloring
{
int rc,gc,bc;
t++;
// abusing the fact that atof considers whitespace to be a delimiter...
rc = (int)crosshaircolor.value;
rc = bound(0, rc, 255);
gc = atoi(t);
gc = bound(0, gc, 255);
t = strstr(t, " "); // find last value
if (t)
{
bc = atoi(t+1);
bc = bound(0, bc, 255);
}
else
bc = 0;
sw_crosshaircolor = GetPalette(rc,gc,bc);
}
crosshaircolor.modified = false;
}
c2 = c = sw_crosshaircolor;
for (sc = 0; sc < cl.splitclients; sc++)
{
SCR_CrosshairPosition(sc, &x, &y);
@ -2340,14 +2373,86 @@ Draw_FadeScreen
================
*/
char fscolormap[256];
int fsnodraw = 1;
int fsmodified;
void SWDraw_FadeScreen (void)
{
int x,y;
extern cvar_t r_menutint;
VID_UnlockBuffer ();
S_ExtraUpdate ();
VID_LockBuffer ();
if (fsmodified != r_menutint.modified)
{
char *t;
int s;
float r, g, b;
qbyte invmask = 0;
qbyte *rgb = (qbyte *)d_8to24rgbtable;
// parse r_menutint
fsnodraw = 0;
r = r_menutint.value;
g = 0;
b = 0;
t = strstr(r_menutint.string, " ");
if (t)
{
g = atof(t+1);
t = strstr(t+1, " ");
if (t)
b = atof(t+1);
}
// bounds check and inverse check
if (r < 0)
{
invmask = 0xff;
r = -r;
}
if (r > 1)
r = 1;
if (g < 0)
{
invmask = 0xff;
g = -g;
}
if (g > 1)
g = 1;
if (b < 0)
{
invmask = 0xff;
b = -b;
}
if (b > 1)
b = 1;
if (!invmask && r == 1 && g == 1 && b == 1)
fsnodraw = 1;
// generate colormap
for (x = 0; x < 256; x++)
{
// convert to grayscale value
s = rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114;
fscolormap[x] = GetPalette((int)(s*r)^invmask, (int)(s*g)^invmask, (int)(s*b)^invmask);
rgb += 4;
}
fsmodified = r_menutint.modified;
}
if (fsnodraw)
return;
if (r_pixbytes == 4)
{
qbyte *pbuf;
@ -2383,15 +2488,12 @@ void SWDraw_FadeScreen (void)
qbyte *pbuf;
for (y=0 ; y<vid.height ; y++)
{
int t;
pbuf = (qbyte *)(vid.buffer + vid.rowbytes*y);
t = (y & 1) << 1;
for (x=0 ; x<vid.width ; x++)
{
if ((x & 3) != t)
pbuf[x] = 0;
pbuf[x] = fscolormap[pbuf[x]];
}
}
}