shithub: tinygl

Download patch

ref: eef0a1f9ef57eda9f885ed651ca1fabf3f2648b7
parent: 095742492b37a269ec364f01149c97ebb7122866
author: MHS <gek@katherine>
date: Fri Mar 19 10:09:54 EDT 2021

Automatic commit.

--- a/src/get.c
+++ b/src/get.c
@@ -423,7 +423,11 @@
 		*params = GL_FLOAT;
 		break;
 	case GL_RENDER_MODE:
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 		*params = c->render_mode;
+#else
+		*params = GL_RENDER;
+#endif
 		break;
 	case GL_BLEND_EQUATION:
 		*params = c->zb->blendeq;
--- a/src/init.c
+++ b/src/init.c
@@ -153,7 +153,8 @@
 	v->ymin = 0;
 	v->xsize = zbuffer->xsize;
 	v->ysize = zbuffer->ysize;
-	v->updated = 1;
+	//v->updated = 1;
+	gl_eval_viewport(c);
 	/* buffer stuff GL 1.1 */
 	c->drawbuffer = GL_FRONT;
 	c->readbuffer = GL_FRONT;
@@ -263,6 +264,7 @@
 	c->clear_depth = 0;
 
 	/* selection */
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	c->render_mode = GL_RENDER;
 	c->select_buffer = NULL;
 	c->name_stack_size = 0;
@@ -273,6 +275,7 @@
 	c->feedback_size = 0;
 	c->feedback_hits = 0;
 	c->feedback_overflow = 0;
+#endif
 	/* matrix */
 	c->matrix_mode = 0;
 
--- a/src/misc.c
+++ b/src/misc.c
@@ -14,6 +14,8 @@
 #endif
 }
 
+
+
 void glopViewport( GLParam* p) {
 	GLContext* c = gl_get_context();
 	GLint xsize, ysize, 
@@ -45,7 +47,9 @@
 		c->viewport.xsize = xsize;
 		c->viewport.ysize = ysize;
 
-		c->viewport.updated = 1;
+		//c->viewport.updated = 1;
+		gl_eval_viewport(c);
+		//c->viewport.updated = 0;
 	}
 }
 void glBlendFunc(GLenum sfactor, GLenum dfactor) {
--- a/src/select.c
+++ b/src/select.c
@@ -263,14 +263,17 @@
 	gl_add_feedback(GL_PASS_THROUGH_TOKEN,NULL,NULL,NULL,token);
 }
 void glopInitNames(GLParam* p) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 	if (c->render_mode == GL_SELECT) {
 		c->name_stack_size = 0;
 		c->select_hit = NULL;
 	}
+#endif
 }
 
 void glopPushName(GLParam* p) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 	if (c->render_mode == GL_SELECT) {
 		//assert(c->name_stack_size < MAX_NAME_STACK_DEPTH);
@@ -277,6 +280,7 @@
 		c->name_stack[c->name_stack_size++] = p[1].i;
 		c->select_hit = NULL;
 	}
+#endif
 }
 
 
@@ -285,6 +289,7 @@
 
 
 void glopPopName(GLParam* p) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 	if (c->render_mode == GL_SELECT) {
 		//assert(c->name_stack_size > 0);
@@ -291,9 +296,11 @@
 		c->name_stack_size--;
 		c->select_hit = NULL;
 	}
+#endif
 }
 
 void glopLoadName(GLParam* p) {
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLContext* c = gl_get_context();
 	if (c->render_mode == GL_SELECT) {
 		//assert(c->name_stack_size > 0);
@@ -300,6 +307,7 @@
 		c->name_stack[c->name_stack_size - 1] = p[1].i;
 		c->select_hit = NULL;
 	}
+#endif
 }
 
 void gl_add_select(GLuint zmin, GLuint zmax) {
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -43,22 +43,7 @@
 	}
 }
 
-static inline void gl_eval_viewport() {
-	GLContext* c = gl_get_context();
-	GLViewport* v;
-	GLfloat zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
 
-	v = &c->viewport;
-
-	v->trans.X = ((v->xsize - 0.5) / 2.0) + v->xmin;
-	v->trans.Y = ((v->ysize - 0.5) / 2.0) + v->ymin;
-	v->trans.Z = ((zsize - 0.5) / 2.0) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2;
-
-	v->scale.X = (v->xsize - 0.5) / 2.0;
-	v->scale.Y = -(v->ysize - 0.5) / 2.0;
-	v->scale.Z = -((zsize - 0.5) / 2.0);
-}
-
 void glopBegin(GLParam* p) {
 	GLContext* c = gl_get_context();
 	GLint type;
@@ -97,11 +82,11 @@
 
 		c->matrix_model_projection_updated = 0;
 	}
-	/*  viewport */
-	if (c->viewport.updated) {
-		gl_eval_viewport(c);
-		c->viewport.updated = 0;
-	}
+	/*  viewport- this is now updated on a glViewport call. */
+	//if (c->viewport.updated) {
+	//	gl_eval_viewport(c);
+	//	c->viewport.updated = 0;
+	//}
 	/* triangle drawing functions */
 #if TGL_FEATURE_ALT_RENDERMODES == 1
 	if (c->render_mode == GL_SELECT) {
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -103,7 +103,7 @@
 	GLint xmin, ymin, xsize, ysize;
 	V3 scale;
 	V3 trans;
-	GLint updated;
+//	GLint updated;
 } GLViewport;
 
 typedef union {
@@ -233,6 +233,7 @@
 	gl_draw_triangle_func draw_triangle_front, draw_triangle_back;
 
 	/* selection */
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLint render_mode;
 	GLuint* select_buffer;
 	GLint select_size;
@@ -239,11 +240,13 @@
 	GLuint *select_ptr, *select_hit;
 	GLint select_overflow;
 	GLint select_hits;
+#endif
 	/* glDrawBuffer, glRenderBuffer */
 	GLenum drawbuffer;
 	GLenum readbuffer;
 	/* feedback */
 	//render_mode as seen above
+#if TGL_FEATURE_ALT_RENDERMODES == 1
 	GLfloat* feedback_buffer;
 	GLfloat* feedback_ptr;
 	GLuint feedback_size;
@@ -253,7 +256,10 @@
 	/* names */
 	GLuint name_stack[MAX_NAME_STACK_DEPTH];
 	GLint name_stack_size;
+#endif
+	
 
+
 	/* clear */
 	GLfloat clear_depth;
 	V4 clear_color;
@@ -477,7 +483,21 @@
 
 
 
+static inline void gl_eval_viewport() {
+	GLContext* c = gl_get_context();
+	GLViewport* v;
+	GLfloat zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
 
+	v = &c->viewport;
+
+	v->trans.X = ((v->xsize - 0.5) / 2.0) + v->xmin;
+	v->trans.Y = ((v->ysize - 0.5) / 2.0) + v->ymin;
+	v->trans.Z = ((zsize - 0.5) / 2.0) + ((1 << ZB_POINT_Z_FRAC_BITS)) / 2;
+
+	v->scale.X = (v->xsize - 0.5) / 2.0;
+	v->scale.Y = -(v->ysize - 0.5) / 2.0;
+	v->scale.Z = -((zsize - 0.5) / 2.0);
+}
 
 
 #endif /* _tgl_zgl_h_ */