shithub: tinygl

Download patch

ref: 757ecd0728d4a249ddf72ce0ac0e0acd1df76744
parent: e0cafbd6a4156ab0b4167465a422ee6d135cf2c3
author: David <gek@katherine>
date: Mon Feb 22 17:58:35 EST 2021

Discovery!

--- a/SDL_Examples/helloworld.c
+++ b/SDL_Examples/helloworld.c
@@ -80,11 +80,11 @@
 	glTranslatef(0.0f, 14.0f, 0.0f);
 	glRotatef(0.3f * (GLfloat)x + (GLfloat)time_passed * 100.0f, 0.0f, 0.0f, 1.0f);
 	glBegin(GL_TRIANGLES);
-	glColor4f(1.0f, 0.0f, 0.0f, 0.0f);
+	glColor4f(1.0f, 0.01f, 0.01f, 0.0f);
 	glVertex3f(-5.0f, 0.0f, -4.0f);
-	glColor4f(0.0f, 1.0f, 0.0f, 0.0f);
+	glColor4f(0.01f, 1.0f, 0.01f, 0.0f);
 	glVertex3f(5.0f, 0.0f, -4.0f);
-	glColor4f(0.0f, 0.0f, 1.0f, 0.0f);
+	glColor4f(0.01f, 0.01f, 1.0f, 0.0f);
 	glVertex3f(0.0f, 0.0f, 6.0f);
 	glEnd();
 }
--- a/include/zbuffer.h
+++ b/include/zbuffer.h
@@ -54,7 +54,7 @@
 /* 32 bit mode */
 //#define RGB_TO_PIXEL(r,g,b) ( ((b&65280)<<8) | ((g&65280)) | ((r&65280)>>8) )
 #define RGB_TO_PIXEL(r,g,b) \
-  ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8))
+  ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b & 0xff00) >> 8))
 #define GET_RED(p) ((p & 0xff0000)>>16)
 #define GET_REDDER(p) ((p & 0xff0000)>>8)
 #define GET_GREEN(p) ((p & 0xff00)>>8)
@@ -68,7 +68,7 @@
 #elif TGL_FEATURE_RENDER_BITS == 16
 
 /* 16 bit mode */
-#define RGB_TO_PIXEL(r,g,b) (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11))
+#define RGB_TO_PIXEL(r,g,b) (((r) & 0xF800) | (((g & 0xff00) >> 5) & 0x07E0) | ((b & 0xff00) >> 11))
 
 #define GET_RED(p) ((p & 0xF800)>>8)
 #define GET_REDDER(p) ((p & 0xF800))