shithub: tinygl

Download patch

ref: 3c2622aa007b32a3c1e11ea6532c42c2481aca3f
parent: a3cc2043c7aa88b779ff556d74d936aa06a36972
author: David <gek@katherine>
date: Wed Feb 17 08:10:55 EST 2021

B

--- a/SDL_Examples/gears.c
+++ b/SDL_Examples/gears.c
@@ -243,6 +243,7 @@
 	int winSizeY = 480;
 	unsigned int fps = 0;
 	unsigned int flat = 0;
+	unsigned int blending = 0;
 	char needsRGBAFix = 0;
 	if (argc > 1) {
 		char* larg = "";
@@ -257,6 +258,8 @@
 				flat = 1;
 			if (!strcmp(argv[i],"-smooth"))
 				flat = 0;
+			if (!strcmp(argv[i],"-blend"))
+				blending = 1;
 			larg = argv[i];
 		}
 	}
@@ -338,18 +341,23 @@
 if(flat)	glShadeModel(GL_FLAT); else glShadeModel(GL_SMOOTH);
 //TESTING BLENDING...
 	//glDisable(GL_DEPTH_TEST);
-	glEnable(GL_DEPTH_TEST);
 
-	//glEnable(GL_BLEND);
-	glDisable(GL_BLEND);
-	
-	glDepthMask(GL_TRUE);
-	//glDepthMask(GL_FALSE);
 
 	//glDisable( GL_LIGHTING );
 	glEnable(GL_LIGHTING);
 	glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ZERO);
 	glBlendEquation(GL_FUNC_ADD);
+	if(blending){
+		glEnable(GL_DEPTH_TEST);
+		glEnable(GL_BLEND);
+		glDepthMask(GL_TRUE);
+		glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ZERO);
+		glBlendEquation(GL_FUNC_ADD);
+	}else{
+		glEnable(GL_DEPTH_TEST);
+		glDisable(GL_BLEND);
+		glDepthMask(GL_TRUE);
+	}
 	GLfloat h = (GLfloat)winSizeY / (GLfloat)winSizeX;
 	glMatrixMode(GL_PROJECTION);
 	glLoadIdentity();
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -47,6 +47,7 @@
 #undef INTERP_STZ
 
 #define INTERP_Z
+//#define INTERP_RGB
 
 #define DRAW_INIT()                                                                                                                                            \
 	{  }
@@ -72,8 +73,9 @@
 #undef INTERP_RGB
 #undef INTERP_ST
 #undef INTERP_STZ
-#define INTERP_Z
 
+#define INTERP_Z
+//#define INTERP_RGB
 #define DRAW_INIT()                                                                                                                                            \
 	{  }