shithub: tinygl

Download patch

ref: 07eeeb88a263f338c4df4bd991b562d801b64f99
parent: b6aeeec09556c095669e279222d90c673266b80f
author: MHS <gek@katherine>
date: Mon Mar 15 21:36:52 EDT 2021

Automatic commit.

--- a/src/arrays.c
+++ b/src/arrays.c
@@ -6,7 +6,7 @@
 //Code for buffers is here too!
 
 
-GLint free_buffer(GLint handle){
+static GLint free_buffer(GLint handle){
 	GLContext* c = gl_get_context();
 	GLSharedState* s = &(c->shared_state);
 	if(handle == 0 || handle > MAX_BUFFERS) return 1; //error flag
@@ -31,7 +31,7 @@
 		return 0;
 	}
 }
-GLint check_buffer(GLint handle){ //1 means used, 0 means free, 2 means invalid
+static GLint check_buffer(GLint handle){ //1 means used, 0 means free, 2 means invalid
 	GLContext* c = gl_get_context();
 	GLSharedState* s = &(c->shared_state);
 	if(handle == 0 || handle > MAX_BUFFERS) return 2; //error flag
@@ -52,7 +52,7 @@
 	handle--;
 	return s->buffers[handle];
 }
-GLint create_buffer(GLint handle){
+static inline GLint create_buffer(GLint handle){
 	GLContext* c = gl_get_context();
 	GLSharedState* s = &(c->shared_state);
 	if(handle == 0 || handle > MAX_BUFFERS) return 1; //error flag
@@ -83,7 +83,7 @@
 
 	{	
 		GLint n_left = n;
-		GLuint names[n];
+		GLuint names[MAX_BUFFERS];
 		for(int i = 1; i <= MAX_BUFFERS && n_left > 0; i++)
 			if(!check_buffer(i)) names[(n_left--)-1] = i;
 
--- a/src/clip.c
+++ b/src/clip.c
@@ -53,7 +53,7 @@
 */
 
 #define clip_funcdef(name, sign, dir, dir1, dir2)                                                                                                                 \
-	GLfloat name(V4* c, V4* a, V4* b) {                                                                                                                 \
+	static GLfloat name(V4* c, V4* a, V4* b) {                                                                                                                 \
 		GLfloat t, dX, dY, dZ, dW, den;                                                                                                                        \
 		dX = (b->X - a->X);                                                                                                                                    \
 		dY = (b->Y - a->Y);                                                                                                                                    \
@@ -83,7 +83,7 @@
 
 					clip_funcdef(clip_zmax, +, Z, X, Y)
 
-GLfloat (*clip_proc[6])(V4*, V4*, V4*) = {clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax};
+static GLfloat (*clip_proc[6])(V4*, V4*, V4*) = {clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax};
 /* point */
 static void gl_add_select1(GLint z1, GLint z2, GLint z3) {
 	GLint min, max;
--- a/src/font8x8_basic.h
+++ b/src/font8x8_basic.h
@@ -20,7 +20,7 @@
 
 // Constant: font8x8_basic
 // Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
-GLbyte font8x8_basic[256][8] = {
+static GLbyte font8x8_basic[256][8] = {
 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
--- a/src/init.c
+++ b/src/init.c
@@ -1,7 +1,7 @@
 #include "zgl.h"
 #include "msghandling.h"
 GLContext gl_ctx;
-const GLContext empty_gl_ctx = {0};
+static const GLContext empty_gl_ctx = {0};
 
 void initSharedState(GLContext* c) {
 	GLSharedState* s = &c->shared_state;
@@ -347,4 +347,5 @@
 	}
 #endif
 	endSharedState(c);
+	gl_ctx = empty_gl_ctx;
 }
--- a/src/msghandling.c
+++ b/src/msghandling.c
@@ -1,5 +1,6 @@
 #include "../include/GL/gl.h"
 #include "zgl.h"
+#include "msghandling.h"
 #include <stdarg.h>
 
 //#define NDEBUG
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -434,7 +434,7 @@
  * adr must be aligned on an 'int'
  */
 // Used in 16 bit mode
-void memset_s(void* adr, GLint val, GLint count) {
+static void memset_s(void* adr, GLint val, GLint count) {
 	GLint i, n, v;
 	GLuint* p;
 	GLushort* q;
@@ -458,7 +458,7 @@
 }
 
 // Used in 32 bit mode
-void memset_l(void* adr, GLint val, GLint count) {
+static void memset_l(void* adr, GLint val, GLint count) {
 	GLint i, n, v;
 	GLuint* p;
 
@@ -480,7 +480,7 @@
 
 /* count must be a multiple of 4 and >= 4 */
 // Gek's note: Should never be used.
-void memset_RGB24(void* adr, GLint r, GLint v, GLint b, long count) {
+static void memset_RGB24(void* adr, GLint r, GLint v, GLint b, long count) {
 	long i, n;
 	register long v1, v2, v3, *pt = (long*)(adr);
 	GLubyte *p, R = (GLubyte)r, V = (GLubyte)v, B = (GLubyte)b;
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -22,7 +22,7 @@
 	gl_add_op(p);
 }
 void glopTextSize(GLParam* p) { GLContext* c = gl_get_context(); c->textsize = p[1].ui; } // Set text size
-void renderchar(GLbyte* bitmap, GLint _x, GLint _y, GLuint p) {
+static void renderchar(GLbyte* bitmap, GLint _x, GLint _y, GLuint p) {
 	GLint x, y;
 	GLint set;
 	GLContext* c = gl_get_context();