From ae2ab25a34fcb6107489bd48e50c6784528cc344 Mon Sep 17 00:00:00 2001 From: Tony Tyson Date: Fri, 28 Apr 2000 03:38:01 +0000 Subject: [PATCH] Added cvar "crosshairalpha" for crosshair 2 & 3. Defaults to 255 which is opaque (0 is clear). --- common/gl_draw.c | 30 ++++++++++++++++++++++++------ common/view.c | 2 ++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/common/gl_draw.c b/common/gl_draw.c index 18a25c5..234bf64 100644 --- a/common/gl_draw.c +++ b/common/gl_draw.c @@ -41,7 +41,7 @@ #include extern unsigned char d_15to8table[65536]; -extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor; +extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor, *crosshairalpha; cvar_t *gl_nobind; cvar_t *gl_max_size; @@ -532,15 +532,21 @@ Draw_Crosshair(void) { int x, y; extern vrect_t scr_vrect; - unsigned char *pColor; + unsigned uColor; if (crosshair->value == 3) { x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value; y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value; + glDisable(GL_ALPHA_TEST); + glEnable (GL_BLEND); + glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value]; - glColor4ubv ( pColor ); + + uColor = d_8to24table[(byte) crosshaircolor->value] & 0x00ffffff; + uColor |= ((unsigned)crosshairalpha->value & 0xff) << 24; + glColor4ubv((unsigned char *)&uColor); + GL_Bind (cs_texture3); glBegin (GL_QUADS); @@ -557,13 +563,22 @@ Draw_Crosshair(void) glEnd (); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); + + glEnable(GL_ALPHA_TEST); + glDisable (GL_BLEND); } else if (crosshair->value == 2) { x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value; y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->value; + glDisable(GL_ALPHA_TEST); + glEnable (GL_BLEND); + glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - pColor = (unsigned char *) &d_8to24table[(byte) crosshaircolor->value]; - glColor4ubv ( pColor ); + + uColor = d_8to24table[(byte) crosshaircolor->value] & 0x00ffffff; + uColor |= ((unsigned)crosshairalpha->value & 0xff) << 24; + glColor4ubv((unsigned char *)&uColor); + GL_Bind (cs_texture); glBegin (GL_QUADS); @@ -580,6 +595,9 @@ Draw_Crosshair(void) glEnd (); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); + + glEnable(GL_ALPHA_TEST); + glDisable (GL_BLEND); } else if (crosshair->value) Draw_Character (scr_vrect.x + scr_vrect.width/2-4 + cl_crossx->value, scr_vrect.y diff --git a/common/view.c b/common/view.c index dbe03fc..867e9b4 100644 --- a/common/view.c +++ b/common/view.c @@ -79,6 +79,7 @@ cvar_t *v_idlescale; cvar_t *crosshair; cvar_t *crosshaircolor; +cvar_t *crosshairalpha; cvar_t *cl_crossx; cvar_t *cl_crossy; @@ -1072,6 +1073,7 @@ V_Init ( void ) v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, "None"); crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, "Crosshair Color"); + crosshairalpha = Cvar_Get ("crosshairalpha", "255", CVAR_ARCHIVE, "Crosshair Alpha"); crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, "Crosshair selection"); cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, "Crosshair X location"); cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, "Crosshair Y location");