From cef3fd53abd23749665f3c5f696f91517ed9c60c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 8 Dec 2019 00:41:24 +0100 Subject: [PATCH] Clamp vColor --- src/rendering/polyrenderer/drawers/screen_triangle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/polyrenderer/drawers/screen_triangle.cpp b/src/rendering/polyrenderer/drawers/screen_triangle.cpp index 1bd948aec..38023ff23 100644 --- a/src/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/src/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -376,7 +376,7 @@ static void WriteVaryingColor(float pos, float step, int x0, int x1, const float { for (int x = x0; x < x1; x++) { - varying[x] = (int)(pos * w[x] * 255.0f); + varying[x] = clamp(static_cast(pos * w[x] * 255.0f), 0, 255); pos += step; } } @@ -401,7 +401,7 @@ static void WriteVaryingColor(float pos, float step, int x0, int x1, const float pos += ssecount * step; for (int x = sseend; x < x1; x++) { - varying[x] = (int)(pos * w[x] * 255.0f); + varying[x] = clamp(static_cast(pos * w[x] * 255.0f), 0, 255); pos += step; } }