Added cvar "crosshairalpha" for crosshair 2 & 3. Defaults to 255 which is opaque (0 is clear).

This commit is contained in:
Tony Tyson 2000-04-28 03:38:01 +00:00
parent 341eacbc53
commit ae2ab25a34
2 changed files with 26 additions and 6 deletions

View File

@ -41,7 +41,7 @@
#include <lib_replace.h> #include <lib_replace.h>
extern unsigned char d_15to8table[65536]; 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_nobind;
cvar_t *gl_max_size; cvar_t *gl_max_size;
@ -532,15 +532,21 @@ Draw_Crosshair(void)
{ {
int x, y; int x, y;
extern vrect_t scr_vrect; extern vrect_t scr_vrect;
unsigned char *pColor; unsigned uColor;
if (crosshair->value == 3) { if (crosshair->value == 3) {
x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value; x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value;
y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->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 ); 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); GL_Bind (cs_texture3);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -557,13 +563,22 @@ Draw_Crosshair(void)
glEnd (); glEnd ();
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glEnable(GL_ALPHA_TEST);
glDisable (GL_BLEND);
} else if (crosshair->value == 2) { } else if (crosshair->value == 2) {
x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value; x = scr_vrect.x + scr_vrect.width/2 - 3 + cl_crossx->value;
y = scr_vrect.y + scr_vrect.height/2 - 3 + cl_crossy->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 ); 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); GL_Bind (cs_texture);
glBegin (GL_QUADS); glBegin (GL_QUADS);
@ -580,6 +595,9 @@ Draw_Crosshair(void)
glEnd (); glEnd ();
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glEnable(GL_ALPHA_TEST);
glDisable (GL_BLEND);
} else if (crosshair->value) } else if (crosshair->value)
Draw_Character (scr_vrect.x + scr_vrect.width/2-4 Draw_Character (scr_vrect.x + scr_vrect.width/2-4
+ cl_crossx->value, scr_vrect.y + cl_crossx->value, scr_vrect.y

View File

@ -79,6 +79,7 @@ cvar_t *v_idlescale;
cvar_t *crosshair; cvar_t *crosshair;
cvar_t *crosshaircolor; cvar_t *crosshaircolor;
cvar_t *crosshairalpha;
cvar_t *cl_crossx; cvar_t *cl_crossx;
cvar_t *cl_crossy; cvar_t *cl_crossy;
@ -1072,6 +1073,7 @@ V_Init ( void )
v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, "None"); v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, "None");
crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, "Crosshair Color"); 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"); crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, "Crosshair selection");
cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, "Crosshair X location"); cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, "Crosshair X location");
cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, "Crosshair Y location"); cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, "Crosshair Y location");