ref: 79393818387bcbeddfc14a82a8f30af63bb2735d
parent: 832eb032a1ed49e8704e0178eab312a7aa47bcee
author: David <gek@katherine>
date: Sun Feb 14 15:42:43 EST 2021
Adding build test shit
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@
$(LIB):
cd src && $(MAKE) && cd ..
+ cp src/*.a ./lib/
SDL_Examples: $(LIB)
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -4,6 +4,9 @@
#ifndef GL_H
#define GL_H
+//Enable TinyGL's Compiletime Compatibility Test (Scroll down)
+#define COMPILETIME_TINYGL_COMPAT_TEST 1
+
#define GL_VERSION_1_1 1
#ifdef __cplusplus
@@ -680,8 +683,22 @@
typedef unsigned int GLuint; /* 4-byte unsigned */
typedef float GLfloat; /* single precision float */
typedef double GLdouble; /* double precision float */
-typedef int GLsizei;
+typedef int GLsizei;
+
+#if COMPILETIME_TINYGL_COMPAT_TEST == 1
+
+//NO
+extern char __BUILDT_GLbyte[ 1-2*(sizeof(GLbyte) != 1)];
+//extern char __BUILDT_error[ 1-2*(sizeof(GLbyte) != 4)];
+extern char __BUILDT_GLshort[ 1-2*(sizeof(GLshort) != 2)];
+extern char __BUILDT_GLint[ 1-2*(sizeof(GLint) != 4)];
+extern char __BUILDT_GLuint[ 1-2*(sizeof(GLuint) != 4)];
+extern char __BUILDT_GLfloat[ 1-2*(sizeof(GLfloat) != 4)];
+extern char __BUILDT_GLubyte[ 1-2*(sizeof(GLubyte) != 1)];
+extern char __BUILDT_GLushort[ 1-2*(sizeof(GLushort) != 2)];
+
+#endif
/* functions */
void glEnable(int code);
--- a/include/zbuffer.h
+++ b/include/zbuffer.h
@@ -6,6 +6,7 @@
*/
#include "zfeatures.h"
+#include "GL/gl.h"
#define ZB_Z_BITS 16
--- a/src/Makefile
+++ b/src/Makefile
@@ -16,7 +16,7 @@
LIB = libTinyGL.a
all: $(LIB)
- mv $(LIB) ../lib/
+# mv $(LIB) ../lib/
$(LIB): $(OBJS)
rm -f $(LIB)
--- a/src/api.c
+++ b/src/api.c
@@ -62,16 +62,16 @@
p[4].f=a;
/* direct convertion to integer to go faster if no shading */
/*
- p[5].ui = (unsigned int) (r * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
+ p[5].ui = (GLuint) (r * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
ZB_POINT_RED_MIN);
- p[6].ui = (unsigned int) (g * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) +
+ p[6].ui = (GLuint) (g * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) +
ZB_POINT_GREEN_MIN);
- p[7].ui = (unsigned int) (b * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) +
+ p[7].ui = (GLuint) (b * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) +
ZB_POINT_BLUE_MIN);
*/
- p[5].ui = (((unsigned int)(r * 65535)) & 65535);
- p[6].ui = (((unsigned int)(g * 65535)) & 65535);
- p[7].ui = (((unsigned int)(b * 65535)) & 65535);
+ p[5].ui = (((GLuint)(r * 65535)) & 65535);
+ p[6].ui = (((GLuint)(g * 65535)) & 65535);
+ p[7].ui = (((GLuint)(b * 65535)) & 65535);
gl_add_op(p);
}
@@ -86,16 +86,16 @@
p[4].f=v[3];
/* direct convertion to integer to go faster if no shading */
/*
- p[5].ui = (unsigned int) (v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
+ p[5].ui = (GLuint) (v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
ZB_POINT_RED_MIN);
- p[6].ui = (unsigned int) (v[1] * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) +
+ p[6].ui = (GLuint) (v[1] * (ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) +
ZB_POINT_GREEN_MIN);
- p[7].ui = (unsigned int) (v[2] * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) +
+ p[7].ui = (GLuint) (v[2] * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) +
ZB_POINT_BLUE_MIN);
*/
- p[5].ui = (((unsigned int)(v[0] * 65535)) & 65535);
- p[6].ui = (((unsigned int)(v[1] * 65535)) & 65535);
- p[7].ui = (((unsigned int)(v[2] * 65535)) & 65535);
+ p[5].ui = (((GLuint)(v[0] * 65535)) & 65535);
+ p[6].ui = (((GLuint)(v[1] * 65535)) & 65535);
+ p[7].ui = (((GLuint)(v[2] * 65535)) & 65535);
gl_add_op(p);
}
@@ -603,7 +603,7 @@
gl_add_op(p);
}
-void glPushName(unsigned int name)
+void glPushName(GLuint name)
{
GLParam p[2];
@@ -622,7 +622,7 @@
gl_add_op(p);
}
-void glLoadName(unsigned int name)
+void glLoadName(GLuint name)
{
GLParam p[2];
@@ -644,7 +644,7 @@
/* Special Functions */
-void glCallList(unsigned int list)
+void glCallList(GLuint list)
{
GLParam p[2];
--- a/src/clip.c
+++ b/src/clip.c
@@ -25,15 +25,15 @@
/* color */
//if (c->lighting_enabled) {
- v->zp.r=(unsigned int)(v->color.v[0] * 65535) & 65535;
- v->zp.g=(unsigned int)(v->color.v[1] * 65535) & 65535;
- v->zp.b=(unsigned int)(v->color.v[2] * 65535) & 65535;
+ v->zp.r=(GLuint)(v->color.v[0] * 65535) & 65535;
+ v->zp.g=(GLuint)(v->color.v[1] * 65535) & 65535;
+ v->zp.b=(GLuint)(v->color.v[2] * 65535) & 65535;
//} else {
//printf("\nRECEIVED COLOR %f, %f, %f, %f", v->color.v[0], v->color.v[1], v->color.v[2], v->color.v[3]);
- // v->zp.r=(unsigned int)(v->color.v[0] * 65535) & 65535;
- // v->zp.g=(unsigned int)(v->color.v[1] * 65535) & 65535;
- // v->zp.b=(unsigned int)(v->color.v[2] * 65535) & 65535;
+ // v->zp.r=(GLuint)(v->color.v[0] * 65535) & 65535;
+ // v->zp.g=(GLuint)(v->color.v[1] * 65535) & 65535;
+ // v->zp.b=(GLuint)(v->color.v[2] * 65535) & 65535;
//printf("\nCOLORS ARE %d, %d, %d", v->zp.r,v->zp.g,v->zp.b);
// }
@@ -50,7 +50,7 @@
static void gl_add_select1(GLContext *c,int z1,int z2,int z3)
{
- unsigned int min,max;
+ GLuint min,max;
min=max=z1;
if (z2<min) min=z2;
if (z3<min) min=z3;
--- a/src/image_util.c
+++ b/src/image_util.c
@@ -20,7 +20,7 @@
//This actually converts to ABGR!!!
//This is the format of the entire engine!!!
-void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb,
+void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, unsigned char *rgb,
int xsize, int ysize)
{
int i,n;
@@ -29,9 +29,9 @@
p=rgb;
n=xsize*ysize;
for(i=0;i<n;i++) {
- pixmap[i]=(((unsigned int)p[2])<<16) |
- (((unsigned int)p[1])<<8) |
- (((unsigned int)p[0]) );
+ pixmap[i]=(((GLuint)p[2])<<16) |
+ (((GLuint)p[1])<<8) |
+ (((GLuint)p[0]) );
p+=3;
}
}
--- a/src/list.c
+++ b/src/list.c
@@ -27,7 +27,7 @@
return gl_ctx;
}
-static GLList *find_list(GLContext *c,unsigned int list)
+static GLList *find_list(GLContext *c,GLuint list)
{
return c->shared_state.lists[list];
}
@@ -53,11 +53,11 @@
gl_free(l);
c->shared_state.lists[list]=NULL;
}
-void glDeleteLists(unsigned int list, unsigned int range){
- for(unsigned int i = 0; i < list + range; i++)
+void glDeleteLists(GLuint list, GLuint range){
+ for(GLuint i = 0; i < list + range; i++)
glDeleteList(list+i);
}
-void glDeleteList(unsigned int list){
+void glDeleteList(GLuint list){
delete_list(gl_get_context(), list);
}
@@ -195,7 +195,7 @@
-void glNewList(unsigned int list,int mode)
+void glNewList(GLuint list,int mode)
{
GLList *l;
GLContext *c=gl_get_context();
@@ -229,7 +229,7 @@
c->exec_flag=1;
}
-int glIsList(unsigned int list)
+int glIsList(GLuint list)
{
GLContext *c=gl_get_context();
GLList *l;
@@ -237,7 +237,7 @@
return (l != NULL);
}
-unsigned int glGenLists(int range)
+GLuint glGenLists(int range)
{
GLContext *c=gl_get_context();
int count,i,list;
--- a/src/quick.sh
+++ b/src/quick.sh
@@ -3,5 +3,6 @@
#This script was used to move these files to include.
#sed -i 's/\"zbuffer.h/\"include\/zbuffer.h/g' *.c *.h
#sed -i 's/\"zfeatures.h/\"include\/zfeatures.h/g' *.c *.h
-sed -i 's/\"include/\"..\/include/g' *.c *.h
+sed -i 's/unsigned int/GLuint/g' *.c *.h
+sed -i 's/\nint /GLint /g' *.c *.h
#gcc *.c -o executable.out -lglut -lGL -lm -lGLU
--- a/src/select.c
+++ b/src/select.c
@@ -39,7 +39,7 @@
return result;
}
-void glSelectBuffer(int size,unsigned int *buf)
+void glSelectBuffer(int size,GLuint *buf)
{
GLContext *c=gl_get_context();
@@ -85,9 +85,9 @@
}
}
-void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax)
+void gl_add_select(GLContext *c,GLuint zmin,GLuint zmax)
{
- unsigned int *ptr;
+ GLuint *ptr;
int n,i;
if (!c->select_overflow) {
--- a/src/texture.c
+++ b/src/texture.c
@@ -78,7 +78,7 @@
c->current_texture=find_texture(c,0);
}
-void glGenTextures(int n, unsigned int *textures)
+void glGenTextures(int n, GLuint *textures)
{
GLContext *c=gl_get_context();
int max,i;
@@ -99,7 +99,7 @@
}
-void glDeleteTextures(int n, const unsigned int *textures)
+void glDeleteTextures(int n, const GLuint *textures)
{
GLContext *c=gl_get_context();
int i;
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -246,9 +246,9 @@
v->color = c->current_color;
}
/* Added by Gek to fix bug with rendering*/
- //v->zp.r=(unsigned int)(v->color.v[0] * 65535) & 65535;
- //v->zp.g=(unsigned int)(v->color.v[1] * 65535) & 65535;
- //v->zp.b=(unsigned int)(v->color.v[2] * 65535) & 65535;
+ //v->zp.r=(GLuint)(v->color.v[0] * 65535) & 65535;
+ //v->zp.g=(GLuint)(v->color.v[1] * 65535) & 65535;
+ //v->zp.b=(GLuint)(v->color.v[2] * 65535) & 65535;
/* tex coords */
if (c->texture_2d_enabled) {
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <assert.h>
#include <string.h>
+//#include "../include/GL/gl.h"
#include "../include/zbuffer.h"
ZBuffer *ZB_open(int xsize, int ysize, int mode,
@@ -170,7 +171,7 @@
#define RGB16_TO_RGB32(p0,p1,v)\
{\
- unsigned int g,b,gb;\
+ GLuint g,b,gb;\
g = (v & 0x07E007E0) << 5;\
b = (v & 0x001F001F) << 3;\
gb = g | b;\
@@ -184,21 +185,21 @@
int linesize)
{
unsigned short *q;
- unsigned int *p, *p1, v, w0, w1;
+ GLuint *p, *p1, v, w0, w1;
int y, n;
q = zb->pbuf;
- p1 = (unsigned int *) buf;
+ p1 = (GLuint *) buf;
//puts("\nBEING CALLED\n");
for (y = 0; y < zb->ysize; y++) {
p = p1;
n = zb->xsize >> 2;
do {
- v = *(unsigned int *) q;
+ v = *(GLuint *) q;
RGB16_TO_RGB32(w1, w0, v);
p[0] = w0;
p[1] = w1;
- v = *(unsigned int *) (q + 2);
+ v = *(GLuint *) (q + 2);
RGB16_TO_RGB32(w1, w0, v);
p[2] = w0;
p[3] = 0;
@@ -226,7 +227,7 @@
#define RGB16_TO_RGB24(p0,p1,p2,v1,v2)\
{\
- unsigned int r1,g1,b1,gb1,g2,b2,gb2;\
+ GLuint r1,g1,b1,gb1,g2,b2,gb2;\
v1 = (v1 << 16) | (v1 >> 16);\
v2 = (v2 << 16) | (v2 >> 16);\
r1 = (v1 & 0xF800F800);\
@@ -245,7 +246,7 @@
#define RGB16_TO_RGB24(p0,p1,p2,v1,v2)\
{\
- unsigned int r1,g1,b1,gb1,g2,b2,gb2;\
+ GLuint r1,g1,b1,gb1,g2,b2,gb2;\
r1 = (v1 & 0xF800F800);\
g1 = (v1 & 0x07E007E0) << 5;\
b1 = (v1 & 0x001F001F) << 3;\
@@ -266,11 +267,11 @@
int linesize)
{
unsigned short *q;
- unsigned int *p, *p1, w0, w1, w2, v0, v1;
+ GLuint *p, *p1, w0, w1, w2, v0, v1;
int y, n;
q = zb->pbuf;
- p1 = (unsigned int *) buf;
+ p1 = (GLuint *) buf;
linesize = linesize * 3;
for (y = 0; y < zb->ysize; y++) {
@@ -277,8 +278,8 @@
p = p1;
n = zb->xsize >> 2;
do {
- v0 = *(unsigned int *) q;
- v1 = *(unsigned int *) (q + 2);
+ v0 = *(GLuint *) q;
+ v1 = *(GLuint *) (q + 2);
RGB16_TO_RGB24(w0, w1, w2, v0, v1);
p[0] = w0;
p[1] = w1;
@@ -457,7 +458,7 @@
void memset_s(void *adr, int val, int count)
{
int i, n, v;
- unsigned int *p;
+ GLuint *p;
unsigned short *q;
p = adr;
@@ -482,7 +483,7 @@
void memset_l(void *adr, int val, int count)
{
int i, n, v;
- unsigned int *p;
+ GLuint *p;
p = adr;
v = val;
--- a/src/zdither.c
+++ b/src/zdither.c
@@ -90,7 +90,7 @@
#define DITHER_PIXEL2(a) \
{ \
register int v,t,r,g,c; \
- v=*(unsigned int *)(pp+(a)); \
+ v=*(GLuint *)(pp+(a)); \
g=(v & 0x07DF07DF) + g_d; \
r=(((v & 0xF800F800) >> 2) + r_d) & 0x70007000; \
t=r | g; \
@@ -134,7 +134,9 @@
g_d=b_d | g_d;
dest1=buf + (yk * linesize) + xk;
- pp1=zb->pbuf + (yk * zb->xsize) + xk;
+ //NOTE BY GEK: The following line was modified to fix a compiler warning,
+ //casting zb->pbuf to unsigned short*
+ pp1=(unsigned short*)(zb->pbuf) + (yk * zb->xsize) + xk;
for(y=yk;y<zb->ysize;y+=4) {
dest=dest1;
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -99,7 +99,7 @@
int op;
float f;
int i;
- unsigned int ui;
+ GLuint ui;
void *p;
} GLParam;
@@ -216,14 +216,14 @@
/* selection */
int render_mode;
- unsigned int *select_buffer;
+ GLuint *select_buffer;
int select_size;
- unsigned int *select_ptr,*select_hit;
+ GLuint *select_ptr,*select_hit;
int select_overflow;
int select_hits;
/* names */
- unsigned int name_stack[MAX_NAME_STACK_DEPTH];
+ GLuint name_stack[MAX_NAME_STACK_DEPTH];
int name_stack_size;
/* clear */
@@ -232,7 +232,7 @@
/* current vertex state */
V4 current_color;
- //unsigned int longcurrent_color[3]; /* precomputed integer color */
+ //GLuint longcurrent_color[3]; /* precomputed integer color */
V4 current_normal;
V4 current_tex_coord;
int current_edge_flag;
@@ -304,7 +304,7 @@
void glopTranslate(GLContext *c,GLParam *p);*/
/* light.c */
-void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax);
+void gl_add_select(GLContext *c,GLuint zmin,GLuint zmax);
void gl_enable_disable_light(GLContext *c,int light,int v);
void gl_shade_vertex(GLContext *c,GLVertex *v);
@@ -315,7 +315,7 @@
/* image_util.c */
void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb,
int xsize,int ysize);
-void gl_convertRGB_to_8A8R8G8B(unsigned int *pixmap, unsigned char *rgb,
+void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, unsigned char *rgb,
int xsize, int ysize);
void gl_resizeImage(unsigned char *dest,int xsize_dest,int ysize_dest,
unsigned char *src,int xsize_src,int ysize_src);
--- a/src/zline.h
+++ b/src/zline.h
@@ -3,10 +3,10 @@
register int a;
register PIXEL *pp;
#if defined(INTERP_RGB) || TGL_FEATURE_RENDER_BITS == 24
- register unsigned int r, g, b;
+ register GLuint r, g, b;
#endif
#ifdef INTERP_RGB
- register unsigned int rinc, ginc, binc;
+ register GLuint rinc, ginc, binc;
#endif
#ifdef INTERP_Z
register unsigned short *pz;
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -9,7 +9,7 @@
GLTEXTSIZE textsize = 1;
void glTextSize(GLTEXTSIZE mode){textsize = mode;}//Set text size
-void renderchar(char *bitmap, int _x, int _y, unsigned int p) {
+void renderchar(char *bitmap, int _x, int _y, GLuint p) {
int x,y;
int set;
//int mask;
@@ -26,10 +26,10 @@
}
-void glPlotPixel(int x, int y, unsigned int p){
+void glPlotPixel(int x, int y, GLuint p){
// int x = p[1].i;
// int y = p[2].i;
-// unsigned int p = p[3].ui;
+// GLuint p = p[3].ui;
#if TGL_FEATURE_RENDER_BITS == 16
p = RGB_TO_PIXEL( ( (p & 255) << 8) , ( p & 65280) , ( (p >>16)<<8 ) );
#endif
@@ -40,7 +40,7 @@
if(x>0 && x<w && y>0 && y < h)
pbuf[x+y*w] = p;
}
-void glDrawText(const unsigned char* text, int x, int y, unsigned int p){
+void glDrawText(const unsigned char* text, int x, int y, GLuint p){
if(!text)return;
//PIXEL* pbuf = gl_get_context()->zb->pbuf;
int w = gl_get_context()->zb->xsize;
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -78,7 +78,7 @@
#if TGL_FEATURE_RENDER_BITS == 16
// int _drgbdx;
#endif
-//unsigned int color;
+//GLuint color;
#define INTERP_Z
#define INTERP_RGB
@@ -155,7 +155,7 @@
{ \
register unsigned short *pz; \
register PIXEL *pp; \
- register unsigned int tmp,z,zz,rgb,drgbdx; \
+ register GLuint tmp,z,zz,rgb,drgbdx; \
register int n; \
n=(x2 >> 16) - x1; \
pp=pp1+x1; \
@@ -272,7 +272,7 @@
{ \
register unsigned short *pz; \
register PIXEL *pp; \
- register unsigned int s,t,z,zz; \
+ register GLuint s,t,z,zz; \
register int n,dsdx,dtdx; \
float sz,tz,fz,zinv; \
n=(x2>>16)-x1; \
--- a/src/ztriangle.h
+++ b/src/ztriangle.h
@@ -252,13 +252,13 @@
register int n;
#ifdef INTERP_Z
register unsigned short *pz;
- register unsigned int z,zz;
+ register GLuint z,zz;
#endif
#ifdef INTERP_RGB
- register unsigned int or1,og1,ob1;
+ register GLuint or1,og1,ob1;
#endif
#ifdef INTERP_ST
- register unsigned int s,t;
+ register GLuint s,t;
#endif
#ifdef INTERP_STZ
float sz,tz;