From ee3582f692613394472ecf1826e462fe0b808fbf Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 30 Jul 2002 03:15:09 +0000 Subject: [PATCH] fix 'flashing' crosshair bug caused by negative colors (clamp them before drawing the sprite) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2121 d7cf8633-e32d-0410-b094-e92efae38249 --- r_crosshairs.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/r_crosshairs.c b/r_crosshairs.c index 79cef91f..b888f946 100644 --- a/r_crosshairs.c +++ b/r_crosshairs.c @@ -243,6 +243,7 @@ void R_DrawCrosshair(void) float scale, base; vec3_t v1, v2, spriteorigin; vec_t spritescale; + float cr, cg, cb, ca; num = crosshair.integer - 1; if (num < 0) return; @@ -279,8 +280,21 @@ void R_DrawCrosshair(void) spritescale = 4.0f + (CL_TraceLine(v1, v2, spriteorigin, NULL, 0, true) * 8192.0f) * (1.0f / 48.0f); spritescale = bound(0.0f, spritescale, 32.0f); //VectorMA(spriteorigin, -4, vpn, spriteorigin); - // put the sprite there - R_DrawCrosshairSprite(crosshairtexture[num], spriteorigin, spritescale, color[0] * scale + base, color[1] * scale + base, color[2] * scale + base, crosshair_alpha.value); + + cr = color[0] * scale + base; + cg = color[1] * scale + base; + cb = color[2] * scale + base; + ca = crosshair_alpha.value; + + // clamp the colors so they don't go negative + cr = max(0, cr); + cg = max(0, cg); + cb = max(0, cb); + // might as well clamp the alpha + ca = bound(0, ca, 1.0f); + + // finally draw the sprite + R_DrawCrosshairSprite(crosshairtexture[num], spriteorigin, spritescale, cr, cg, cb, ca); } } -- 2.39.2