[Scummvm-git-logs] scummvm master -> 66e1029071757575207019d50505408ef703f50f
neuromancer
noreply at scummvm.org
Mon Nov 17 13:36:12 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
66e1029071 TINYGL: Clamp viewport coordinates to INT_MAX and INT_MIN to avoid overflow
Commit: 66e1029071757575207019d50505408ef703f50f
https://github.com/scummvm/scummvm/commit/66e1029071757575207019d50505408ef703f50f
Author: neuromancer (neuromancer at users.noreply.github.com)
Date: 2025-11-17T14:36:08+01:00
Commit Message:
TINYGL: Clamp viewport coordinates to INT_MAX and INT_MIN to avoid overflow
Changed paths:
graphics/tinygl/clip.cpp
diff --git a/graphics/tinygl/clip.cpp b/graphics/tinygl/clip.cpp
index d0b0b968873..8dfc7b7ecb4 100644
--- a/graphics/tinygl/clip.cpp
+++ b/graphics/tinygl/clip.cpp
@@ -37,13 +37,37 @@ namespace TinyGL {
#define CLIP_ZMAX (1 << 5)
void GLContext::gl_transform_to_viewport(GLVertex *v) {
- float winv;
+ float winv, result;
// coordinates
winv = (float)(1.0 / v->pc.W);
- v->zp.x = (int)(v->pc.X * winv * viewport.scale.X + viewport.trans.X);
- v->zp.y = (int)(v->pc.Y * winv * viewport.scale.Y + viewport.trans.Y);
- v->zp.z = (int)(v->pc.Z * winv * viewport.scale.Z + viewport.trans.Z);
+ // Compute and clamp X coordinate
+ result = v->pc.X * winv * viewport.scale.X + viewport.trans.X;
+ if (result > (float)INT_MAX)
+ v->zp.x = INT_MAX;
+ else if (result < (float)INT_MIN)
+ v->zp.x = INT_MIN;
+ else
+ v->zp.x = (int)result;
+
+ // Compute and clamp Y coordinate
+ result = v->pc.Y * winv * viewport.scale.Y + viewport.trans.Y;
+ if (result > (float)INT_MAX)
+ v->zp.y = INT_MAX;
+ else if (result < (float)INT_MIN)
+ v->zp.y = INT_MIN;
+ else
+ v->zp.y = (int)result;
+
+ // Compute and clamp Z coordinate
+ result = v->pc.Z * winv * viewport.scale.Z + viewport.trans.Z;
+ if (result > (float)INT_MAX)
+ v->zp.z = INT_MAX;
+ else if (result < (float)INT_MIN)
+ v->zp.z = INT_MIN;
+ else
+ v->zp.z = (int)result;
+
// color
v->zp.r = (int)(v->color.X * ZB_POINT_RED_MAX);
More information about the Scummvm-git-logs
mailing list