]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix 'flashing' crosshair bug caused by negative colors (clamp them before drawing...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 30 Jul 2002 03:15:09 +0000 (03:15 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 30 Jul 2002 03:15:09 +0000 (03:15 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2121 d7cf8633-e32d-0410-b094-e92efae38249

r_crosshairs.c

index 79cef91f552aa17282d294f0fed1c14625edd1a8..b888f9466ed7efe921ca3dfe3b4ace75aa857e9a 100644 (file)
@@ -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);
        }
 }