shithub: tinygl

Download patch

ref: 2ff44fe298a8040c0b0870915939ea3c1fc978a2
parent: a458bd7e8689e64876f30353c6a0ea8bc7233fd4
author: MHS <gek@katherine>
date: Tue Mar 23 09:55:54 EDT 2021

Automatic commit.

--- a/src/clip.c
+++ b/src/clip.c
@@ -20,9 +20,9 @@
 		v->zp.z = (GLint)(v->pc.Z * winv * c->viewport.scale.Z + c->viewport.trans.Z);
 	}
 	/* color */
-	v->zp.r = (GLuint)(v->color.v[0] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
-	v->zp.g = (GLuint)(v->color.v[1] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
-	v->zp.b = (GLuint)(v->color.v[2] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.r = (GLint)(v->color.v[0] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.g = (GLint)(v->color.v[1] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.b = (GLint)(v->color.v[2] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
 
 	/* texture */
 
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -68,12 +68,15 @@
 			gl_M4_Inv(&tmp, c->matrix_stack_ptr[0]);
 			gl_M4_Transpose(&c->matrix_model_view_inv, &tmp);
 		} else {
-			GLfloat* m = &c->matrix_model_projection.m[0][0];
+			//GLfloat* m = &c->matrix_model_projection.m[0][0];
 			/* precompute projection matrix */
 			gl_M4_Mul(&c->matrix_model_projection, c->matrix_stack_ptr[1], c->matrix_stack_ptr[0]);
 			/* test to accelerate computation */
 			c->matrix_model_projection_no_w_transform = 0;
-			if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0)
+			//if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0)
+			if(c->matrix_model_projection.m[3][0] == 0.0 &&
+				c->matrix_model_projection.m[3][1] == 0.0 &&
+				c->matrix_model_projection.m[3][2] == 0.0)
 				c->matrix_model_projection_no_w_transform = 1;
 		}
 
@@ -127,8 +130,6 @@
 
 static inline void gl_transform_to_viewport_vertex_c(GLVertex* v) {
 	GLContext* c = gl_get_context();
-
-	
 	{
 		GLfloat winv = 1.0 / v->pc.W;
 		v->zp.x = (GLint)(v->pc.X * winv * c->viewport.scale.X + c->viewport.trans.X);
@@ -136,9 +137,9 @@
 		v->zp.z = (GLint)(v->pc.Z * winv * c->viewport.scale.Z + c->viewport.trans.Z);
 	}
 	
-	v->zp.r = (GLuint)(v->color.v[0] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
-	v->zp.g = (GLuint)(v->color.v[1] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
-	v->zp.b = (GLuint)(v->color.v[2] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.r = (GLint)(v->color.v[0] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.g = (GLint)(v->color.v[1] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
+	v->zp.b = (GLint)(v->color.v[2] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;