shithub: tinygl

Download patch

ref: 2298e130a5cf4bbf8d828cca6ed3902da8faaa83
parent: 2b4c5ed7478d344ad416f1ebe12d4b23e214f3e5
author: David <gek@katherine>
date: Tue Feb 16 11:17:37 EST 2021

NO_DRAW_COLOR is now only used in the textured triangle rendering.

--- a/src/vertex.c
+++ b/src/vertex.c
@@ -228,8 +228,8 @@
 
 	if (c->texture_2d_enabled) {
 #if TGL_FEATURE_LIT_TEXTURES == 1
-		if(!(c->lighting_enabled))
-			v->color = gl_V4_New(1, 1, 1, 0); //Fix by GEK for unlit textured models.
+		if (!(c->lighting_enabled))
+			v->color = gl_V4_New(1, 1, 1, 0); // Fix by GEK for unlit textured models.
 #endif
 		if (c->apply_texture_matrix) {
 			gl_M4_MulV4(&v->tex_coord, c->matrix_stack_ptr[2], &c->current_tex_coord);
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -31,6 +31,7 @@
 #endif
 
 #define ZCMP(z, zpix, _a, c) ((z) >= (zpix) && STIPTEST(_a) && NODRAWTEST(c))
+#define ZCMPSIMP(z, zpix, _a, c) ((z) >= (zpix) && STIPTEST(_a))
 
 void ZB_fillTriangleFlat(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
 
@@ -44,7 +45,7 @@
 #define PUT_PIXEL(_a)                                                                                                                                          \
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
-		if (ZCMP(zz, pz[_a], _a, color)) {                                                                                                                     \
+		if (ZCMPSIMP(zz, pz[_a], _a, color)) {                                                                                                                 \
 			pp[_a] = color;                                                                                                                                    \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
@@ -77,7 +78,7 @@
 #define PUT_PIXEL(_a)                                                                                                                                          \
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
-		if (ZCMP(zz, pz[_a], _a, RGB_TO_PIXEL(or1, og1, ob1))) {                                                                                               \
+		if (ZCMPSIMP(zz, pz[_a], _a, RGB_TO_PIXEL(or1, og1, ob1))) {                                                                                           \
 			pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);                                                                                                              \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
@@ -91,7 +92,7 @@
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
 		c = RGB_TO_PIXEL(or1, og1, ob1);                                                                                                                       \
-		if (ZCMP(zz, pz[_a], _a, c)) {                                                                                                                         \
+		if (ZCMPSIMP(zz, pz[_a], _a, c)) {                                                                                                                     \
 			pp[_a] = c;                                                                                                                                        \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
@@ -126,7 +127,7 @@
 #define PUT_PIXEL(_a)                                                                                                                                          \
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
-		if (ZCMP(zz, pz[_a], _a, 0)) {                                                                                                                         \
+		if (ZCMPSIMP(zz, pz[_a], _a, 0)) {                                                                                                                     \
 			pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);                                                                                                              \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
@@ -140,7 +141,7 @@
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
 		c = RGB_TO_PIXEL(or1, og1, ob1);                                                                                                                       \
-		if (ZCMP(zz, pz[_a], _a, c)) {                                                                                                                         \
+		if (ZCMPSIMP(zz, pz[_a], _a, c)) {                                                                                                                     \
 			pp[_a] = c;                                                                                                                                        \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
@@ -237,11 +238,18 @@
 		ndtzdx = NB_INTERP * dtzdx;                                                                                                                            \
 	}
 #if TGL_FEATURE_LIT_TEXTURES == 1
-#define OR1OG1OB1DECL register GLuint or1, og1, ob1;or1=r1;og1=g1;ob1=b1;
-#define OR1G1B1INCR og1 += dgdx;or1 += drdx;ob1 += dbdx;
-#else 
+#define OR1OG1OB1DECL                                                                                                                                          \
+	register GLuint or1, og1, ob1;                                                                                                                             \
+	or1 = r1;                                                                                                                                                  \
+	og1 = g1;                                                                                                                                                  \
+	ob1 = b1;
+#define OR1G1B1INCR                                                                                                                                            \
+	og1 += dgdx;                                                                                                                                               \
+	or1 += drdx;                                                                                                                                               \
+	ob1 += dbdx;
+#else
 #define OR1OG1OB1DECL /*A comment*/
-#define OR1G1B1INCR /*Another comment*/
+#define OR1G1B1INCR   /*Another comment*/
 #define or1 0xffff
 #define og1 0xffff
 #define ob1 0xffff
@@ -251,13 +259,13 @@
 	{                                                                                                                                                          \
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
 		if (ZCMP(zz, pz[_a], _a, 0)) {                                                                                                                         \
-			pp[_a] = RGB_MIX_FUNC(or1,og1,ob1,   *(PIXEL*)((GLbyte*)texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))));                       \
+			pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, *(PIXEL*)((GLbyte*)texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))));                       \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
 		z += dzdx;                                                                                                                                             \
 		s += dsdx;                                                                                                                                             \
 		t += dtdx;                                                                                                                                             \
-		OR1G1B1INCR	\
+		OR1G1B1INCR                                                                                                                                            \
 	}
 #else
 #define PUT_PIXEL(_a)                                                                                                                                          \
@@ -265,13 +273,13 @@
 		zz = z >> ZB_POINT_Z_FRAC_BITS;                                                                                                                        \
 		c = *(PIXEL*)((GLbyte*)texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH)));                                                             \
 		if (ZCMP(zz, pz[_a], _a, c)) {                                                                                                                         \
-			pp[_a] = RGB_MIX_FUNC(or1,og1,ob1,c);                                                                                                                                        \
+			pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, c);                                                                                                           \
 			pz[_a] = zz;                                                                                                                                       \
 		}                                                                                                                                                      \
 		z += dzdx;                                                                                                                                             \
 		s += dsdx;                                                                                                                                             \
 		t += dtdx;                                                                                                                                             \
-		OR1G1B1INCR	\
+		OR1G1B1INCR                                                                                                                                            \
 	}
 #endif
 
@@ -281,7 +289,7 @@
 		register PIXEL* pp;                                                                                                                                    \
 		register GLuint s, t, z, zz;                                                                                                                           \
 		register GLint n, dsdx, dtdx;                                                                                                                          \
-		OR1OG1OB1DECL                                                                                                                         \
+		OR1OG1OB1DECL                                                                                                                                          \
 		GLfloat sz, tz, fz, zinv;                                                                                                                              \
 		n = (x2 >> 16) - x1;                                                                                                                                   \
 		fz = (GLfloat)z1;                                                                                                                                      \