ref: 5e84e3b1d87b1224a6aab1ea590edebd6a8dc025
parent: 3b961717be648d0810bb364e3cacbd4be8f7ce0b
author: David <gek@katherine>
date: Sun Feb 14 16:25:19 EST 2021
Code consistency improvement
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -701,47 +701,47 @@
#endif
/* functions */
-void glEnable(int code);
-void glDisable(int code);
+void glEnable(GLint code);
+void glDisable(GLint code);
-void glShadeModel(int mode);
-void glCullFace(int mode);
-void glPolygonMode(int face,int mode);
+void glShadeModel(GLint mode);
+void glCullFace(GLint mode);
+void glPolygonMode(GLint face,GLint mode);
-void glBegin(int type);
+void glBegin(GLint type);
void glEnd(void);
//NEW functions added by GEK!!!
-void glSetEnableSpecular(int s); //Toggle specular rendering (Speedup!!!)
-void* glGetTexturePixmap(int text, int level, int* xsize, int* ysize); //Get the raw data of a texture!
-void glDrawText(const unsigned char* text, int x, int y, unsigned int pixel); //Blit 8x8 text to he screen
+void glSetEnableSpecular(GLint s); //Toggle specular rendering (Speedup!!!)
+void* glGetTexturePixmap(GLint text, GLint level, GLint* xsize, GLint* ysize); //Get the raw data of a texture!
+void glDrawText(const GLubyte* text, GLint x, GLint y, GLuint pixel); //Blit 8x8 text to he screen
void glTextSize(GLTEXTSIZE mode); //Set text size
-void glPlotPixel(int x, int y, unsigned int pixel); //plot a pixel to the screen.
+void glPlotPixel(GLint x, GLint y, GLuint pixel); //plot a pixel to the screen.
#define PROTO_GL1(name) \
-void gl ## name ## 1f(float); \
-void gl ## name ## 1d(double); \
-void gl ## name ## 1fv(float *); \
-void gl ## name ## 1dv(double *);
+void gl ## name ## 1f(GLfloat); \
+void gl ## name ## 1d(GLdouble); \
+void gl ## name ## 1fv(GLfloat *); \
+void gl ## name ## 1dv(GLdouble *);
#define PROTO_GL2(name) \
-void gl ## name ## 2f(float ,float); \
-void gl ## name ## 2d(double ,double); \
-void gl ## name ## 2fv(float *); \
-void gl ## name ## 2dv(double *);
+void gl ## name ## 2f(GLfloat ,GLfloat); \
+void gl ## name ## 2d(GLdouble ,GLdouble); \
+void gl ## name ## 2fv(GLfloat *); \
+void gl ## name ## 2dv(GLdouble *);
#define PROTO_GL3(name) \
-void gl ## name ## 3f(float ,float ,float); \
-void gl ## name ## 3d(double ,double ,double); \
-void gl ## name ## 3fv(float *); \
-void gl ## name ## 3dv(double *);
+void gl ## name ## 3f(GLfloat ,GLfloat ,GLfloat); \
+void gl ## name ## 3d(GLdouble ,GLdouble ,GLdouble); \
+void gl ## name ## 3fv(GLfloat *); \
+void gl ## name ## 3dv(GLdouble *);
#define PROTO_GL4(name) \
-void gl ## name ## 4f(float ,float ,float, float ); \
-void gl ## name ## 4d(double ,double ,double, double ); \
-void gl ## name ## 4fv(float *); \
-void gl ## name ## 4dv(double *);
+void gl ## name ## 4f(GLfloat ,GLfloat ,GLfloat, GLfloat ); \
+void gl ## name ## 4d(GLdouble ,GLdouble ,GLdouble, GLdouble ); \
+void gl ## name ## 4fv(GLfloat *); \
+void gl ## name ## 4dv(GLdouble *);
PROTO_GL2(Vertex)
PROTO_GL3(Vertex)
@@ -757,74 +757,74 @@
PROTO_GL3(TexCoord)
PROTO_GL4(TexCoord)
-void glEdgeFlag(int flag);
+void glEdgeFlag(GLint flag);
/* matrix */
-void glMatrixMode(int mode);
-void glLoadMatrixf(const float *m);
+void glMatrixMode(GLint mode);
+void glLoadMatrixf(const GLfloat *m);
void glLoadIdentity(void);
-void glMultMatrixf(const float *m);
+void glMultMatrixf(const GLfloat *m);
void glPushMatrix(void);
void glPopMatrix(void);
-void glRotatef(float angle,float x,float y,float z);
-void glTranslatef(float x,float y,float z);
-void glScalef(float x,float y,float z);
+void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
+void glScalef(GLfloat x,GLfloat y,GLfloat z);
-void glViewport(int x,int y,int width,int height);
-void glFrustum(double left,double right,double bottom,double top,
- double near,double far);
+void glViewport(GLint x,GLint y,GLint width,GLint height);
+void glFrustum(GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,
+ GLdouble near,GLdouble far);
/* lists */
-unsigned int glGenLists(int range);
-int glIsList(unsigned int list);
-void glNewList(unsigned int list,int mode);
+GLuint glGenLists(GLint range);
+int glIsList(GLuint list);
+void glNewList(GLuint list,GLint mode);
void glEndList(void);
-void glCallList(unsigned int list);
-void glDeleteList(unsigned int list);
-void glDeleteLists(unsigned int list, unsigned int range);
+void glCallList(GLuint list);
+void glDeleteList(GLuint list);
+void glDeleteLists(GLuint list, GLuint range);
/* clear */
-void glClear(int mask);
-void glClearColor(float r,float g,float b,float a);
-void glClearDepth(double depth);
+void glClear(GLint mask);
+void glClearColor(GLfloat r,GLfloat g,GLfloat b,GLfloat a);
+void glClearDepth(GLdouble depth);
/* selection */
-int glRenderMode(int mode);
-void glSelectBuffer(int size,unsigned int *buf);
+int glRenderMode(GLint mode);
+void glSelectBuffer(GLint size,GLuint *buf);
void glInitNames(void);
-void glPushName(unsigned int name);
+void glPushName(GLuint name);
void glPopName(void);
-void glLoadName(unsigned int name);
+void glLoadName(GLuint name);
/* textures */
-void glGenTextures(int n, unsigned int *textures);
-void glDeleteTextures(int n, const unsigned int *textures);
-void glBindTexture(int target,int texture);
-void glTexImage2D( int target, int level, int components,
- int width, int height, int border,
- int format, int type, void *pixels);
-void glTexEnvi(int target,int pname,int param);
-void glTexParameteri(int target,int pname,int param);
-void glPixelStorei(int pname,int param);
+void glGenTextures(GLint n, GLuint *textures);
+void glDeleteTextures(GLint n, const GLuint *textures);
+void glBindTexture(GLint target,GLint texture);
+void glTexImage2D( GLint target, GLint level, GLint components,
+ GLint width, GLint height, GLint border,
+ GLint format, GLint type, void *pixels);
+void glTexEnvi(GLint target,GLint pname,GLint param);
+void glTexParameteri(GLint target,GLint pname,GLint param);
+void glPixelStorei(GLint pname,GLint param);
/* lighting */
-void glMaterialfv(int mode,int type,float *v);
-void glMaterialf(int mode,int type,float v);
-void glColorMaterial(int mode,int type);
+void glMaterialfv(GLint mode,GLint type,GLfloat *v);
+void glMaterialf(GLint mode,GLint type,GLfloat v);
+void glColorMaterial(GLint mode,GLint type);
-void glLightfv(int light,int type,float *v);
-void glLightf(int light,int type,float v);
-void glLightModeli(int pname,int param);
-void glLightModelfv(int pname,float *param);
+void glLightfv(GLint light,GLint type,GLfloat *v);
+void glLightf(GLint light,GLint type,GLfloat v);
+void glLightModeli(GLint pname,GLint param);
+void glLightModelfv(GLint pname,GLfloat *param);
/* misc */
void glFlush(void);
-void glHint(int target,int mode);
-void glGetIntegerv(int pname,int *params);
-void glGetFloatv(int pname, float *v);
-void glFrontFace(int mode);
+void glHint(GLint target,GLint mode);
+void glGetIntegerv(GLint pname,GLint *params);
+void glGetFloatv(GLint pname, GLfloat *v);
+void glFrontFace(GLint mode);
/* opengl 1.2 arrays */
void glEnableClientState(GLenum array);
@@ -844,26 +844,26 @@
/* not implemented, just added to compile */
/*
-inline void glPointSize(float) {}
-inline void glLineWidth(float) {}
-inline void glDeleteLists(int, int) {}
-inline void glDepthFunc(int) {}
-inline void glBlendFunc(int, int) {}
-inline void glTexEnvf(int, int, int) {}
-inline void glOrtho(float,float,float,float,float,float){}
-inline void glVertex2i(int,int) {}
-inline void glDepthMask(int) {}
-inline void glFogi(int, int) {}
-inline void glFogfv(int, const float*) {}
-inline void glFogf(int, float) {}
-inline void glRasterPos2f(float, float) {}
+inline void glPointSize(GLfloat) {}
+inline void glLineWidth(GLfloat) {}
+inline void glDeleteLists(GLint, GLint) {}
+inline void glDepthFunc(GLint) {}
+inline void glBlendFunc(GLint, GLint) {}
+inline void glTexEnvf(GLint, GLint, GLint) {}
+inline void glOrtho(GLfloat,GLfloat,GLfloat,GLfloat,GLfloat,GLfloat){}
+inline void glVertex2i(GLint,GLint) {}
+inline void glDepthMask(GLint) {}
+inline void glFogi(GLint, GLint) {}
+inline void glFogfv(GLint, const GLfloat*) {}
+inline void glFogf(GLint, GLfloat) {}
+inline void glRasterPos2f(GLfloat, GLfloat) {}
inline void glPolygonStipple(void*) {}
-inline void glTexParameterf(int, int, int) {};
+inline void glTexParameterf(GLint, GLint, GLint) {};
*/
void glPolygonStipple(void* a); //TODO: implement
/* non compatible functions */
-void glDebug(int mode);
+void glDebug(GLint mode);
void glInit(void *zbuffer);
void glClose(void);
--- a/src/image_util.c
+++ b/src/image_util.c
@@ -4,7 +4,7 @@
* image conversion
*/
-void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,GLubyte *rgb,
+void gl_convertRGB_to_5R6G5B(GLushort *pixmap,GLubyte *rgb,
GLint xsize,GLint ysize)
{
GLint i,n;
--- a/src/quick.sh
+++ b/src/quick.sh
@@ -7,6 +7,7 @@
#sed -i 's/float/GLfloat/g' *.c *.h
#sed -i 's/char/GLbyte/g' *.c *.h
#sed -i 's/unsigned GLbyte/GLubyte/g' *.c *.h
-sed -i 's/double/GLdouble/g' *.c *.h
+#sed -i 's/ int/ GLint/g' *.c *.h
+sed -i 's/unsigned GLshort/GLushort/g' *.c *.h
#gcc *.c -o executable.out -lglut -lGL -lm -lGLU
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -357,7 +357,7 @@
gl_draw_line(c, &c->vertex[0], &c->vertex[2]);
}
} else if (c->begin_type == GL_POLYGON) {
- int i = c->vertex_cnt;
+ GLint i = c->vertex_cnt;
while (i >= 3) {
i--;
gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]);
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -47,7 +47,7 @@
goto error;
}
- size = zb->xsize * zb->ysize * sizeof(unsigned short);
+ size = zb->xsize * zb->ysize * sizeof(GLushort);
zb->zbuf = gl_malloc(size);
if (zb->zbuf == NULL)
@@ -98,7 +98,7 @@
zb->ysize = ysize;
zb->linesize = (xsize * PSZB + 3) & ~3;
- size = zb->xsize * zb->ysize * sizeof(unsigned short);
+ size = zb->xsize * zb->ysize * sizeof(GLushort);
gl_free(zb->zbuf);
zb->zbuf = gl_malloc(size);
@@ -184,7 +184,7 @@
void *buf,
GLint linesize)
{
- unsigned short *q;
+ GLushort *q;
GLuint *p, *p1, v, w0, w1;
GLint y, n;
@@ -266,7 +266,7 @@
void *buf,
GLint linesize)
{
- unsigned short *q;
+ GLushort *q;
GLuint *p, *p1, w0, w1, w2, v0, v1;
GLint y, n;
@@ -299,7 +299,7 @@
void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
- int linesize)
+ GLint linesize)
{
ZB_copyBuffer(zb, buf, linesize);
@@ -347,11 +347,11 @@
void *buf, GLint linesize)
{
PIXEL *q;
- unsigned short *p, *p1;
+ GLushort *p, *p1;
GLint y, n;
q = zb->pbuf;
- p1 = (unsigned short *) buf;
+ p1 = (GLushort *) buf;
for (y = 0; y < zb->ysize; y++) {
p = p1;
@@ -364,12 +364,12 @@
q = (PIXEL *)((GLbyte *)q + 4 * PSZB);
p += 4;
} while (--n > 0);
- p1 = (unsigned short *)((GLbyte *)p1 + linesize);
+ p1 = (GLushort *)((GLbyte *)p1 + linesize);
}
}
void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
- int linesize)
+ GLint linesize)
{
switch (zb->mode) {
#ifdef TGL_FEATURE_16_BITS
@@ -403,11 +403,11 @@
void *buf, GLint linesize)
{
PIXEL *q;
- unsigned short *p, *p1;
+ GLushort *p, *p1;
GLint y, n;
q = zb->pbuf;
- p1 = (unsigned short *) buf;
+ p1 = (GLushort *) buf;
for (y = 0; y < zb->ysize; y++) {
p = p1;
@@ -420,12 +420,12 @@
q += 4;
p += 4;
} while (--n > 0);
- p1 = (unsigned short *)((GLbyte *)p1 + linesize);
+ p1 = (GLushort *)((GLbyte *)p1 + linesize);
}
}
*/
void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
- int linesize)
+ GLint linesize)
{
ZB_copyBuffer(zb, buf, linesize);
//switch (zb->mode) {
@@ -459,7 +459,7 @@
{
GLint i, n, v;
GLuint *p;
- unsigned short *q;
+ GLushort *q;
p = adr;
v = val | (val << 16);
@@ -473,7 +473,7 @@
p += 4;
}
- q = (unsigned short *) p;
+ q = (GLushort *) p;
n = count & 7;
for (i = 0; i < n; i++)
*q++ = val;
--- a/src/zdither.c
+++ b/src/zdither.c
@@ -95,7 +95,7 @@
r=(((v & 0xF800F800) >> 2) + r_d) & 0x70007000; \
t=r | g; \
c=ctable[t & 0xFFFF] | (ctable[t >> 16] << 8); \
- *(unsigned short *)(dest+(a))=c; \
+ *(GLushort *)(dest+(a))=c; \
}
/* NOTE: all the memory access are 16 bit aligned, so if buf or
@@ -107,11 +107,11 @@
{
GLint xk,yk,x,y,c1,c2;
GLubyte *dest1;
- unsigned short *pp1;
+ GLushort *pp1;
GLint r_d,g_d,b_d;
GLubyte *ctable=zb->dctable;
register GLubyte *dest;
- register unsigned short *pp;
+ register GLushort *pp;
assert( ((long)buf & 1) == 0 && (linesize & 1) == 0);
@@ -135,8 +135,8 @@
dest1=buf + (yk * linesize) + 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;
+ //casting zb->pbuf to GLushort*
+ pp1=(GLushort*)(zb->pbuf) + (yk * zb->xsize) + xk;
for(y=yk;y<zb->ysize;y+=4) {
dest=dest1;
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -313,7 +313,7 @@
GLTexture *alloc_texture(GLContext *c,GLint h);
/* image_util.c */
-void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,GLubyte *rgb,
+void gl_convertRGB_to_5R6G5B(GLushort *pixmap,GLubyte *rgb,
GLint xsize,GLint ysize);
void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, GLubyte *rgb,
GLint xsize, GLint ysize);
--- a/src/zline.c
+++ b/src/zline.c
@@ -5,7 +5,7 @@
void ZB_plot(ZBuffer * zb, ZBufferPoint * p)
{
- unsigned short *pz;
+ GLushort *pz;
PIXEL *pp;
GLint zz;
--- a/src/zline.h
+++ b/src/zline.h
@@ -9,7 +9,7 @@
register GLuint rinc, ginc, binc;
#endif
#ifdef INTERP_Z
- register unsigned short *pz;
+ register GLushort *pz;
GLint zinc;
register GLint z, zz;
#endif
--- a/src/zmath.c
+++ b/src/zmath.c
@@ -11,7 +11,7 @@
void gl_M4_Id(M4 *a)
{
- int i,j;
+ GLint i,j;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if (i==j) a->m[i][j]=1.0; else a->m[i][j]=0.0;
@@ -19,7 +19,7 @@
int gl_M4_IsId(M4 *a)
{
- int i,j;
+ GLint i,j;
for(i=0;i<4;i++)
for(j=0;j<4;j++) {
if (i==j) {
@@ -120,7 +120,7 @@
/* inversion of an orthogonal matrix of type Y=M.X+P */
void gl_M4_InvOrtho(M4 *a,M4 b)
{
- int i,j;
+ GLint i,j;
GLfloat s;
for(i=0;i<3;i++)
for(j=0;j<3;j++) a->m[i][j]=b.m[j][i];
--- 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 renderGLbyte(GLbyte *bitmap, GLint _x, GLint _y, GLuint p) {
+void renderchar(GLbyte *bitmap, GLint _x, GLint _y, GLuint p) {
GLint x,y;
GLint set;
//int mask;
@@ -27,15 +27,15 @@
void glPlotPixel(GLint x, GLint y, GLuint p){
-// int x = p[1].i;
-// int y = p[2].i;
+// GLint x = p[1].i;
+// GLint y = p[2].i;
// GLuint p = p[3].ui;
#if TGL_FEATURE_RENDER_BITS == 16
p = RGB_TO_PIXEL( ( (p & 255) << 8) , ( p & 65280) , ( (p >>16)<<8 ) );
#endif
PIXEL* pbuf = gl_get_context()->zb->pbuf;
- int w = gl_get_context()->zb->xsize;
- int h = gl_get_context()->zb->ysize;
+ GLint w = gl_get_context()->zb->xsize;
+ GLint h = gl_get_context()->zb->ysize;
if(x>0 && x<w && y>0 && y < h)
pbuf[x+y*w] = p;
@@ -43,15 +43,15 @@
void glDrawText(const GLubyte* text, GLint x, GLint y, GLuint p){
if(!text)return;
//PIXEL* pbuf = gl_get_context()->zb->pbuf;
- int w = gl_get_context()->zb->xsize;
- int h = gl_get_context()->zb->ysize;
- int xoff = 0;
- int yoff = 0;
- int mult = textsize;
+ GLint w = gl_get_context()->zb->xsize;
+ GLint h = gl_get_context()->zb->ysize;
+ GLint xoff = 0;
+ GLint yoff = 0;
+ GLint mult = textsize;
for(GLint i = 0; text[i] != '\0' && y+7 < h; i++){
if(text[i] != '\n' && text[i] < 127 && xoff+x < w)
{
- renderGLbyte(font8x8_basic[text[i]],x+xoff,y+yoff, p);
+ renderchar(font8x8_basic[text[i]],x+xoff,y+yoff, p);
xoff+=8*mult;
}else if(text[i] == '\n'){
xoff=0;
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -19,7 +19,7 @@
#if TGL_FEATURE_POLYGON_STIPPLE
-#define THE_X (((unsigned short)(pp-pp1)))
+#define THE_X (((GLushort)(pp-pp1)))
#define XSTIP(_a) ((THE_X+_a)& TGL_POLYGON_STIPPLE_MASK_X)
#define YSTIP (the_y & TGL_POLYGON_STIPPLE_MASK_Y)
//NOTES Divide by 8 to get the byte Get the actual bit
@@ -76,7 +76,7 @@
ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
{
#if TGL_FEATURE_RENDER_BITS == 16
-// int _drgbdx;
+// GLint _drgbdx;
#endif
//GLuint color;
#define INTERP_Z
@@ -153,7 +153,7 @@
/*
#define DRAW_LINE() \
{ \
- register unsigned short *pz; \
+ register GLushort *pz; \
register PIXEL *pp; \
register GLuint tmp,z,zz,rgb,drgbdx; \
register GLint n; \
@@ -270,7 +270,7 @@
#define DRAW_LINE() \
{ \
- register unsigned short *pz; \
+ register GLushort *pz; \
register PIXEL *pp; \
register GLuint s,t,z,zz; \
register GLint n,dsdx,dtdx; \
--- a/src/ztriangle.h
+++ b/src/ztriangle.h
@@ -5,13 +5,13 @@
{
ZBufferPoint *t,*pr1,*pr2,*l1,*l2;
GLfloat fdx1, fdx2, fdy1, fdy2, fz, d1, d2;
- unsigned short *pz1;
+ GLushort *pz1;
PIXEL *pp1;
GLint part,update_left,update_right;
GLint nb_lines,dx1,dy1,tmp,dx2,dy2;
#if TGL_FEATURE_POLYGON_STIPPLE
- unsigned short the_y;
+ GLushort the_y;
#endif
GLint error,derror;
GLint x1,dxdy_min,dxdy_max;
@@ -251,7 +251,7 @@
register PIXEL *pp;
register GLint n;
#ifdef INTERP_Z
- register unsigned short *pz;
+ register GLushort *pz;
register GLuint z,zz;
#endif
#ifdef INTERP_RGB