shithub: tinygl

Download patch

ref: 100dc4ac891a7159b45d6463b8483b595e180241
parent: 412c8e8c65808f2f924eeebc084dabbf0f824006
author: David <gek@katherine>
date: Sun Mar 7 09:49:40 EST 2021

Automatic commit.

--- a/src/init.c
+++ b/src/init.c
@@ -1,6 +1,6 @@
 #include "zgl.h"
 #include "msghandling.h"
-GLContext* gl_ctx;
+GLContext gl_ctx;
 
 void initSharedState(GLContext* c) {
 	GLSharedState* s = &c->shared_state;
@@ -144,10 +144,11 @@
 #if TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST == 1
 	if(TinyGLRuntimeCompatibilityTest()) gl_fatal_error("TINYGL_FAILED_RUNTIME_COMPAT_TEST");
 #endif
-	c = gl_zalloc(sizeof(GLContext));
+	//c = gl_zalloc(sizeof(GLContext));
+	c = &gl_ctx;
 	if(!c) gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
-	gl_ctx = c;
-
+	//gl_ctx = c;
+	
 	c->zb = zbuffer;
 #if TGL_FEATURE_ERROR_CHECK == 1
 	c->error_flag = GL_NO_ERROR;
@@ -359,5 +360,5 @@
 	}
 #endif
 	endSharedState(c);
-	gl_free(c);
+	//gl_free(c);
 }
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -326,14 +326,14 @@
 	GLint boundtexcoordbuffer;
 } GLContext;
 
-extern GLContext* gl_ctx;
-static inline GLContext* gl_get_context(void) { return gl_ctx; }
+extern GLContext gl_ctx;
+static inline GLContext* gl_get_context(void) { return &gl_ctx; }
 //void gl_add_op(GLParam* p);
 extern void (*op_table_func[])(GLContext*, GLParam*);
 extern GLint op_table_size[];
 extern void gl_compile_op(GLContext* c, GLParam* p);
 static inline void gl_add_op(GLParam* p) {
-	GLContext* c = gl_ctx;
+	GLContext* c = gl_get_context();
 #if TGL_FEATURE_ERROR_CHECK == 1
 #include "error_check.h"
 #endif