shithub: tinygl

Download patch

ref: 095742492b37a269ec364f01149c97ebb7122866
parent: b6f3eeab8fd341aa9ead5625fbd6e0f2e53110b9
author: MHS <gek@katherine>
date: Fri Mar 19 09:31:00 EDT 2021

Automatic commit.

--- a/include/zfeatures.h
+++ b/include/zfeatures.h
@@ -27,6 +27,8 @@
 #define TGL_FEATURE_LIT_TEXTURES   1
 //Enable the patternized "discard"-ing of pixels.
 #define TGL_FEATURE_POLYGON_STIPPLE 0
+//Enable the use of GL_SELECT and GL_FEEDBACK
+#define TGL_FEATURE_ALT_RENDERMODES 0
 //Enable the rendering of large polygons (in terms of vertex count)
 //Also enabled the rendering of line loops.
 //the maximum number of vertices in a polygon is defined in zgl.h
--- a/src/clip.c
+++ b/src/clip.c
@@ -85,6 +85,7 @@
 
 static GLfloat (*clip_proc[6])(V4*, V4*, V4*) = {clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax};
 /* point */
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 static void gl_add_select1(GLint z1, GLint z2, GLint z3) {
 	GLint min, max;
 	min = max = z1;
@@ -99,14 +100,21 @@
 
 	gl_add_select(0xffffffff - min, 0xffffffff - max);
 }
+#else
+#define gl_add_select1(a, b, c) /*a comment*/
+#endif
 void gl_draw_point(GLVertex* p0) {
 	GLContext* c = gl_get_context();
 	if (p0->clip_code == 0) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 		if (c->render_mode == GL_SELECT) {
 			gl_add_select(p0->zp.z, p0->zp.z);
+
 		}else if (c->render_mode == GL_FEEDBACK){
 			gl_add_feedback(GL_POINT_TOKEN,p0,NULL,NULL,0);
-		} else {
+		} else 
+#endif
+		{
 			ZB_plot(c->zb, &p0->zp);
 		}
 	}
@@ -166,6 +174,7 @@
 	cc2 = p2->clip_code;
 
 	if ((cc1 | cc2) == 0) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 		if (c->render_mode == GL_SELECT) {
 			gl_add_select1(p1->zp.z, p2->zp.z, p2->zp.z);
 		}else if (c->render_mode == GL_FEEDBACK){
@@ -176,7 +185,9 @@
 				NULL,
 				0
 			);
-		} else {
+		} else 
+#endif
+		{
 			if (c->zb->depth_test)
 				ZB_line_z(c->zb, &p1->zp, &p2->zp);
 			else
@@ -203,7 +214,7 @@
 			GLinterpolate(&q2, p1, p2, tmax);
 			gl_transform_to_viewport_clip_c(&q1);
 			gl_transform_to_viewport_clip_c(&q2);
-
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 			if (c->render_mode == GL_SELECT) {
 				gl_add_select1(q1.zp.z, q2.zp.z, q2.zp.z);
 			}else if (c->render_mode == GL_FEEDBACK){
@@ -214,7 +225,9 @@
 					NULL,
 					0
 				);
-			} else {
+			} else 
+#endif
+			{
 				if (c->zb->depth_test)
 					ZB_line_z(c->zb, &q1.zp, &q2.zp);
 				else
--- a/src/select.c
+++ b/src/select.c
@@ -3,7 +3,7 @@
 GLint glRenderMode(GLint mode) {
 	GLContext* c = gl_get_context();
 	GLint result = 0;
-
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	switch (c->render_mode) {
 	case GL_RENDER:break;
 	case GL_SELECT:
@@ -73,9 +73,16 @@
 #endif
 	}
 	return result;
+#else
+//GL_SELECT and GL_FEEDBACK are disabled.
+	return 0;
+#endif
+	
 }
 
 void glSelectBuffer(GLint size, GLuint* buf) {
+	
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 #if TGL_FEATURE_ERROR_CHECK == 1
 	if(c->render_mode == GL_SELECT)
@@ -84,11 +91,16 @@
 #else
 	if(c->render_mode == GL_SELECT) return;
 #endif
+
 	c->select_buffer = buf;
 	c->select_size = size;
+#else
+	return;
+#endif
 }
 
 void glFeedbackBuffer(GLint size, GLenum type, GLfloat* buf){
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 #if TGL_FEATURE_ERROR_CHECK == 1
 	if(c->render_mode == GL_FEEDBACK ||
@@ -116,6 +128,9 @@
 	c->feedback_buffer = buf;
 	c->feedback_size = size;
 	c->feedback_type = type;
+#else
+return;
+#endif
 }
 
 void gl_add_feedback(GLfloat token,
@@ -123,7 +138,9 @@
 										GLVertex* v2,
 										GLVertex* v3,
 										GLfloat passthrough_token_value
-){GLContext* c = gl_get_context();
+){
+#if TGL_FEATURE_ALT_RENDERMODES == 1
+GLContext* c = gl_get_context();
 	if(c->feedback_overflow) return;
 	GLuint feedback_hits_needed = 2;
 	GLuint vertex_feedback_hits_needed = 0;
@@ -236,6 +253,8 @@
 	if(done != feedback_hits_needed)
 		gl_fatal_error("Failed to write enough information to the buffer.");
 #endif
+//End of gl_add_feedback
+#endif
 	return;
 }
 void glPassThrough(GLfloat token){
@@ -284,10 +303,11 @@
 }
 
 void gl_add_select(GLuint zmin, GLuint zmax) {
+
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 	GLuint* ptr;
 	GLint n, i;
-
 	if (!c->select_overflow) {
 		if (c->select_hit == NULL) {
 			n = c->name_stack_size;
@@ -311,4 +331,7 @@
 				c->select_hit[2] = zmax;
 		}
 	}
+#else
+return;
+#endif
 }
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -103,6 +103,7 @@
 		c->viewport.updated = 0;
 	}
 	/* triangle drawing functions */
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	if (c->render_mode == GL_SELECT) {
 		c->draw_triangle_front = gl_draw_triangle_select;
 		c->draw_triangle_back = gl_draw_triangle_select;
@@ -109,7 +110,9 @@
 	}else if (c->render_mode == GL_FEEDBACK){
 		c->draw_triangle_front = gl_draw_triangle_feedback;
 		c->draw_triangle_back = gl_draw_triangle_feedback;
-	} else {
+	} else 
+#endif
+	{
 		switch (c->polygon_mode_front) {
 		case GL_POINT:
 			c->draw_triangle_front = gl_draw_triangle_point;
--- a/src/zraster.c
+++ b/src/zraster.c
@@ -139,6 +139,7 @@
 #endif
 #endif
 	//Looping over the source pixels.
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	if(c->render_mode == GL_SELECT){
 		gl_add_select( zz, zz);
 		return;
@@ -152,7 +153,7 @@
 		);
 		return;
 	}
-
+#endif
 // Works.
 #if TGL_FEATURE_MULTITHREADED_DRAWPIXELS == 1