shithub: tinygl

Download patch

ref: d07d0eee0119e1e4b793b5d6ee80ad5d32dc7702
parent: 1abd3333d5da9542e54dd6a89aa515e9e71a6c87
author: David <gek@katherine>
date: Fri Feb 19 08:10:57 EST 2021

Optimized glGetError stuff

--- a/src/api.c
+++ b/src/api.c
@@ -130,7 +130,8 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(mode == GL_FLAT || mode == GL_SMOOTH);
+//	assert(mode == GL_FLAT || mode == GL_SMOOTH);
+//Assume that they know what they're doing.
 #endif
 	p[0].op = OP_ShadeModel;
 	p[1].i = mode;
@@ -146,7 +147,8 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK);
+	//assert(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK);
+	//Assume it's alrgiht.
 #endif
 	p[0].op = OP_CullFace;
 	p[1].i = mode;
@@ -162,7 +164,8 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(mode == GL_CCW || mode == GL_CW);
+	//assert(mode == GL_CCW || mode == GL_CW);
+	//It's alright. No error checking!
 #endif
 	mode = (mode != GL_CCW);
 
@@ -181,10 +184,10 @@
   )
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
+#else
+	//assert(face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK);
+	//assert(mode == GL_POINT || mode == GL_LINE || mode == GL_FILL);
 #endif
-	assert(face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK);
-	assert(mode == GL_POINT || mode == GL_LINE || mode == GL_FILL);
-
 	p[0].op = OP_PolygonMode;
 	p[1].i = face;
 	p[2].i = mode;
@@ -365,7 +368,7 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK);
+	//assert(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK);
 #endif 
 	p[0].op = OP_Material;
 	p[1].i = mode;
--- a/src/arrays.c
+++ b/src/arrays.c
@@ -125,7 +125,7 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(type == GL_FLOAT);
+	//assert(type == GL_FLOAT); Everything is fine!
 #endif
 	p[0].op = OP_VertexPointer;
 	p[1].i = size;
@@ -148,7 +148,7 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(type == GL_FLOAT);
+	//assert(type == GL_FLOAT);
 #endif
 	p[0].op = OP_ColorPointer;
 	p[1].i = size;
@@ -170,7 +170,7 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(type == GL_FLOAT);
+	//assert(type == GL_FLOAT);
 #endif
 	p[0].op = OP_NormalPointer;
 	p[1].i = stride;
@@ -192,7 +192,7 @@
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
 #else
-	assert(type == GL_FLOAT);
+	//assert(type == GL_FLOAT);
 #endif
 	p[0].op = OP_TexCoordPointer;
 	p[1].i = size;
--- a/src/list.c
+++ b/src/list.c
@@ -71,8 +71,8 @@
 #include "error_check.h"
 
 #else
-if(!l || !ob)
-	gl_fatal_error("GL_OUT_OF_MEMORY");
+//if(!l || !ob) //Do no error checks!
+//	gl_fatal_error("GL_OUT_OF_MEMORY");
 #endif
 	ob->next = NULL;
 	l->first_op_buffer = ob;
@@ -125,11 +125,11 @@
 
 		ob1 = gl_zalloc(sizeof(GLParamBuffer));
 if(!ob1)
-#if TGL_FEATURE_ERROR_CHECK
+#if TGL_FEATURE_ERROR_CHECK == 1
 #define ERROR_FLAG GL_OUT_OF_MEMORY
 #include "error_check.h"
 #else
-	gl_fatal_error("GL_OUT_OF_MEMORY");
+	{}//gl_fatal_error("GL_OUT_OF_MEMORY");
 #endif
 		ob1->next = NULL;
 
@@ -180,8 +180,9 @@
 	list = p[1].ui;
 	l = find_list(c, list);
 
-	if (l == NULL)
-		{tgl_warning("\nBAD CALL LIST OP");}
+#if TGL_FEATURE_ERROR_CHECK == 1
+	if (l == NULL) {gl_fatal_error("Bad list op, not defined");}
+#endif
 	p = l->first_op_buffer->ops;
 
 	while (1) {
@@ -213,8 +214,8 @@
 #include "error_check.h"
 
 #else
-	assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
-	assert(c->compile_flag == 0);
+	//assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
+	//assert(c->compile_flag == 0);
 #endif
 	l = find_list(c, list);
 	if (l != NULL)
@@ -226,7 +227,7 @@
 #define ERROR_FLAG GL_OUT_OF_MEMORY
 #include "error_check.h"
 #else
-	if(l==NULL) gl_fatal_error("Could not find or allocate list.");
+	//if(l==NULL) gl_fatal_error("Could not find or allocate list.");
 #endif
 	c->current_op_buffer = l->first_op_buffer;
 	c->current_op_buffer_index = 0;
@@ -244,7 +245,7 @@
 #define ERROR_FLAG GL_INVALID_OPERATION
 #include "error_check.h"
 #else
-	assert(c->compile_flag == 1);
+//	assert(c->compile_flag == 1);
 #endif
 	/* end of list */
 	p[0].op = OP_EndList;
--- a/src/texture.c
+++ b/src/texture.c
@@ -25,7 +25,7 @@
 #define RETVAL NULL
 #include "error_check.h"
 #else
-	assert(text >= 0 && level < MAX_TEXTURE_LEVELS);
+	//assert(text >= 0 && level < MAX_TEXTURE_LEVELS);
 #endif
 	tex = find_texture(c, text);
 	if (!tex)
@@ -177,11 +177,14 @@
 	GLubyte* pixels1;
 	GLint do_free;
 
-	if (!(target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE)) {
-#if TGL_FEATURE_ERROR_CHECK
+	 {
+#if TGL_FEATURE_ERROR_CHECK == 1
+	if (!(target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
 #define ERROR_FLAG GL_INVALID_ENUM
 #include "error_check.h"
+
 #else
+	if (!(target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
 		gl_fatal_error("glTexImage2D: combination of parameters not handled!!");
 #endif
 	}
@@ -205,7 +208,7 @@
 		gl_free(im->pixmap);
 #if TGL_FEATURE_RENDER_BITS == 24
 	im->pixmap = gl_malloc(width * height * 3);
-	if (im->pixmap  || !(TGL_FEATURE_ERROR_CHECK == 1)) {
+	if (im->pixmap) {
 		memcpy(im->pixmap, pixels1, width * height * 3);
 	} else {
 #if TGL_FEATURE_ERROR_CHECK == 1
@@ -212,12 +215,12 @@
 #define ERROR_FLAG GL_OUT_OF_MEMORY
 #include "error_check.h"
 #else
-		{}//gl_fatal_error("GL_OUT_OF_MEMORY");
+		gl_fatal_error("GL_OUT_OF_MEMORY");
 #endif
 	}
 #elif TGL_FEATURE_RENDER_BITS == 32
 	im->pixmap = gl_malloc(width * height * 4);
-	if (im->pixmap || !(TGL_FEATURE_ERROR_CHECK == 1)) {
+	if (im->pixmap) {
 		gl_convertRGB_to_8A8R8G8B(im->pixmap, pixels1, width, height);
 	}else {
 #if TGL_FEATURE_ERROR_CHECK == 1
@@ -224,12 +227,12 @@
 #define ERROR_FLAG GL_OUT_OF_MEMORY
 #include "error_check.h"
 #else
-		{}//gl_fatal_error("GL_OUT_OF_MEMORY");
+		gl_fatal_error("GL_OUT_OF_MEMORY");
 #endif
 	}
 #elif TGL_FEATURE_RENDER_BITS == 16
 	im->pixmap = gl_malloc(width * height * 2);
-	if (im->pixmap  || !(TGL_FEATURE_ERROR_CHECK == 1)) {
+	if (im->pixmap) {
 		gl_convertRGB_to_5R6G5B(im->pixmap, pixels1, width, height);
 	}else {
 #if TGL_FEATURE_ERROR_CHECK == 1
@@ -236,7 +239,7 @@
 #define ERROR_FLAG GL_OUT_OF_MEMORY
 #include "error_check.h"
 #else
-		{}//gl_fatal_error("GL_OUT_OF_MEMORY");
+		gl_fatal_error("GL_OUT_OF_MEMORY");
 #endif
 	}
 #else
@@ -261,7 +264,6 @@
 #include "error_check.h"
 #else
 		gl_fatal_error("glTexParameter: unsupported option");
-		exit(1);
 #endif
 		
 	}