[Scummvm-git-logs] scummvm master -> a9cbcf58e7efdbbb7142515715716456dca6dd43

aquadran noreply at scummvm.org
Fri Oct 3 10:40:27 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:
a9cbcf58e7 TINYGL: Corrected stencilOP


Commit: a9cbcf58e7efdbbb7142515715716456dca6dd43
    https://github.com/scummvm/scummvm/commit/a9cbcf58e7efdbbb7142515715716456dca6dd43
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-10-03T12:40:22+02:00

Commit Message:
TINYGL: Corrected stencilOP

Changed paths:
    graphics/tinygl/zbuffer.h


diff --git a/graphics/tinygl/zbuffer.h b/graphics/tinygl/zbuffer.h
index 43a7f712474..27925d1f508 100644
--- a/graphics/tinygl/zbuffer.h
+++ b/graphics/tinygl/zbuffer.h
@@ -300,34 +300,35 @@ private:
 
 	FORCEINLINE void stencilOp(bool stencilTestResult, bool depthTestResult, byte *sDst) {
 		int op = !stencilTestResult ? _stencilSfail : !depthTestResult ? _stencilDpfail : _stencilDppass;
-		byte value = *sDst;
+		byte oldValue = *sDst;
+		byte newValue = oldValue;
 		switch (op) {
 		case TGL_KEEP:
 			return;
 		case TGL_ZERO:
-			value = 0;
+			newValue = 0;
 			break;
 		case TGL_REPLACE:
-			value = _stencilRefVal;
+			newValue = _stencilRefVal;
 			break;
 		case TGL_INCR:
-			if (value < 255)
-				value++;
+			if (newValue < 255)
+				newValue++;
 			break;
 		case TGL_INCR_WRAP:
-			value++;
+			newValue++;
 			break;
 		case TGL_DECR:
-			if (value > 0)
-				value--;
+			if (newValue > 0)
+				newValue--;
 			break;
 		case TGL_DECR_WRAP:
-			value--;
+			newValue--;
 			break;
 		case TGL_INVERT:
-			value = ~value;
+			newValue = ~newValue;
 		}
-		*sDst = value & _stencilWriteMask;
+		*sDst = (newValue & _stencilWriteMask) | (oldValue & ~_stencilWriteMask);
 	}
 
 	template <bool kEnableAlphaTest, bool kBlendingEnabled>




More information about the Scummvm-git-logs mailing list