shithub: tinygl

Download patch

ref: 80ca2e40a207c0178f76eb7d7c35b325d87a484c
parent: fc6ea36848f15dd98741f2b0d07f5803727a15fb
author: David <gek@katherine>
date: Sun Feb 21 07:35:20 EST 2021

Bug fixes, error checking, and consistency

--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -823,7 +823,7 @@
 
 /* lists */
 GLuint glGenLists(GLint range);
-int glIsList(GLuint list);
+GLint glIsList(GLuint list);
 void glNewList(GLuint list,GLint mode);
 void glEndList(void);
 void glCallList(GLuint list);
@@ -835,7 +835,7 @@
 void glClearDepth(GLdouble depth);
 
 /* selection */
-int glRenderMode(GLint mode);
+GLint glRenderMode(GLint mode);
 void glSelectBuffer(GLint size,GLuint *buf);
 
 void glInitNames(void);
@@ -868,6 +868,7 @@
 /* misc */
 
 void glFlush(void);
+void glFinish(void);
 void glHint(GLint target,GLint mode);
 void glGetIntegerv(GLint pname,GLint *params);
 void glGetFloatv(GLint pname, GLfloat *v);
@@ -901,7 +902,7 @@
 				 	GLsizei size,
 				 	const void * data,
 				 	GLenum usage);
-//Bonus ducks!
+//Bonus ducks! OpenGL Buffer objects.
 void glBindBufferAsArray(GLenum target, GLuint buffer, GLenum type, GLint size, GLint stride);
 
 /* opengl 1.2 polygon offset */
@@ -925,7 +926,6 @@
 void glPixelZoom(GLfloat x, GLfloat y);
 /* not implemented, just added to compile  */
   /*
-inline void glPointSize(GLfloat) {}
 inline void glLineWidth(GLfloat) {}
 inline void glDepthFunc(GLint) {}
 
@@ -936,7 +936,6 @@
 inline void glFogi(GLint, GLint) {}
 inline void glFogfv(GLint, const GLfloat*) {}
 inline void glFogf(GLint, GLfloat) {}
-inline void glRasterPos2f(GLfloat, GLfloat) {}
 inline void glTexParameterf(GLint, GLint, GLint) {};
   */
 void glPolygonStipple(void* a);
--- a/src/clip.c
+++ b/src/clip.c
@@ -213,7 +213,7 @@
 
 static void gl_draw_triangle_clip(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2, GLint clip_bit);
 
-void gl_draw_triangle(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2) {
+inline void gl_draw_triangle(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2) {
 	GLint co, cc[3], front;
 	
 
@@ -364,12 +364,16 @@
 	}
 }
 
-void gl_draw_triangle_select(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2) { gl_add_select1(c, p0->zp.z, p1->zp.z, p2->zp.z); }
+//see vertex.c to see how the draw functions are assigned.
+void gl_draw_triangle_select(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2) { 
+	gl_add_select1(c, p0->zp.z, p1->zp.z, p2->zp.z); 
+}
 
 #ifdef PROFILE
 int count_triangles, count_triangles_textured, count_pixels;
 #endif
 
+//see vertex.c to see how the draw functions are assigned.
 void gl_draw_triangle_fill(GLContext* c, GLVertex* p0, GLVertex* p1, GLVertex* p2) {
 	// puts("\n <yes, it's draw_triangle_fill>");
 #ifdef PROFILE
@@ -388,16 +392,15 @@
 #define ERROR_FLAG GL_INVALID_VALUE
 #include "error_check.h"
 #else
-/*
-		assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
-		assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
-		assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize);
-
-		assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize);
-		assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize);
-		assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize);
-*/
-//Assume it's ok!
+	if(!(
+			(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize) &&
+			(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize) &&
+			(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize) &&
+			
+			(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize) &&
+			(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize) &&
+			(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize)
+		)) return;
 #endif
 		norm = (p1->zp.x - p0->zp.x) * (p2->zp.y - p0->zp.y) - (p2->zp.x - p0->zp.x) * (p1->zp.y - p0->zp.y);
 		count_pixels += abs(norm) / 2;
--- a/src/list.c
+++ b/src/list.c
@@ -257,7 +257,7 @@
 	c->exec_flag = 1;
 }
 
-int glIsList(GLuint list) {
+GLint glIsList(GLuint list) {
 	GLContext* c = gl_get_context();
 	GLList* l;
 	l = find_list(c, list);
--- a/src/misc.c
+++ b/src/misc.c
@@ -201,3 +201,8 @@
 	return GL_NO_ERROR;
 #endif
 }
+
+
+void glFinish(){
+	return;
+}
--- a/src/select.c
+++ b/src/select.c
@@ -1,7 +1,7 @@
 #include "zgl.h"
 //Gek does not maintain or test this feature.
 
-int glRenderMode(GLint mode) {
+GLint glRenderMode(GLint mode) {
 	GLContext* c = gl_get_context();
 	GLint result = 0;
 
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -68,7 +68,7 @@
 #define ERROR_FLAG GL_INVALID_OPERATION
 #include "error_check.h"
 #else
-	//assert(c->in_begin == 0);
+	if(c->in_begin != 0)return; //<COST>
 #endif
 	type = p[1].i;
 	c->begin_type = type;