ref: 892f234fe310efceac0cf20aed5f4c80c92b5909
parent: 79393818387bcbeddfc14a82a8f30af63bb2735d
author: David <gek@katherine>
date: Sun Feb 14 15:57:26 EST 2021
Feature update- code uses GL types
--- a/src/api.c
+++ b/src/api.c
@@ -2,7 +2,7 @@
#include <stdio.h>
/* glVertex */
-void glVertex4f(float x,float y,float z,float w)
+void glVertex4f(GLfloat x,GLfloat y,GLfloat z,GLfloat w)
{
GLParam p[5];
@@ -15,17 +15,17 @@
gl_add_op(p);
}
-void glVertex2f(float x,float y)
+void glVertex2f(GLfloat x,GLfloat y)
{
glVertex4f(x,y,0,1);
}
-void glVertex3f(float x,float y,float z)
+void glVertex3f(GLfloat x,GLfloat y,GLfloat z)
{
glVertex4f(x,y,z,1);
}
-void glVertex3fv(float *v)
+void glVertex3fv(GLfloat *v)
{
glVertex4f(v[0],v[1],v[2],1);
}
@@ -32,7 +32,7 @@
/* glNormal */
-void glNormal3f(float x,float y,float z)
+void glNormal3f(GLfloat x,GLfloat y,GLfloat z)
{
GLParam p[4];
@@ -44,7 +44,7 @@
gl_add_op(p);
}
-void glNormal3fv(float *v)
+void glNormal3fv(GLfloat *v)
{
glNormal3f(v[0],v[1],v[2]);
}
@@ -51,7 +51,7 @@
/* glColor */
-void glColor4f(float r,float g,float b,float a)
+void glColor4f(GLfloat r,GLfloat g,GLfloat b,GLfloat a)
{
GLParam p[8];
@@ -60,7 +60,7 @@
p[2].f=g;
p[3].f=b;
p[4].f=a;
- /* direct convertion to integer to go faster if no shading */
+ /* direct convertion to GLinteger to go faster if no shading */
/*
p[5].ui = (GLuint) (r * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
ZB_POINT_RED_MIN);
@@ -75,7 +75,7 @@
gl_add_op(p);
}
-void glColor4fv(float *v)
+void glColor4fv(GLfloat *v)
{
GLParam p[8];
@@ -84,7 +84,7 @@
p[2].f=v[1];
p[3].f=v[2];
p[4].f=v[3];
- /* direct convertion to integer to go faster if no shading */
+ /* direct convertion to GLinteger to go faster if no shading */
/*
p[5].ui = (GLuint) (v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) +
ZB_POINT_RED_MIN);
@@ -100,12 +100,12 @@
gl_add_op(p);
}
-void glColor3f(float x,float y,float z)
+void glColor3f(GLfloat x,GLfloat y,GLfloat z)
{
glColor4f(x,y,z,1);
}
-void glColor3fv(float *v)
+void glColor3fv(GLfloat *v)
{
glColor4f(v[0],v[1],v[2],1);
}
@@ -113,7 +113,7 @@
/* TexCoord */
-void glTexCoord4f(float s,float t,float r,float q)
+void glTexCoord4f(GLfloat s,GLfloat t,GLfloat r,GLfloat q)
{
GLParam p[5];
@@ -126,12 +126,12 @@
gl_add_op(p);
}
-void glTexCoord2f(float s,float t)
+void glTexCoord2f(GLfloat s,GLfloat t)
{
glTexCoord4f(s,t,0,1);
}
-void glTexCoord2fv(float *v)
+void glTexCoord2fv(GLfloat *v)
{
glTexCoord4f(v[0],v[1],0,1);
}
@@ -262,10 +262,10 @@
gl_add_op(p);
}
-void glLoadMatrixf(const float *m)
+void glLoadMatrixf(const GLfloat *m)
{
GLParam p[17];
- int i;
+ GLint i;
p[0].op=OP_LoadMatrix;
for(i=0;i<16;i++) p[i+1].f=m[i];
@@ -282,10 +282,10 @@
gl_add_op(p);
}
-void glMultMatrixf(const float *m)
+void glMultMatrixf(const GLfloat *m)
{
GLParam p[17];
- int i;
+ GLint i;
p[0].op=OP_MultMatrix;
for(i=0;i<16;i++) p[i+1].f=m[i];
@@ -311,7 +311,7 @@
gl_add_op(p);
}
-void glRotatef(float angle,float x,float y,float z)
+void glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLfloat z)
{
GLParam p[5];
@@ -324,7 +324,7 @@
gl_add_op(p);
}
-void glTranslatef(float x,float y,float z)
+void glTranslatef(GLfloat x,GLfloat y,GLfloat z)
{
GLParam p[4];
@@ -336,7 +336,7 @@
gl_add_op(p);
}
-void glScalef(float x,float y,float z)
+void glScalef(GLfloat x,GLfloat y,GLfloat z)
{
GLParam p[4];
@@ -380,10 +380,10 @@
/* lightening */
-void glMaterialfv(int mode,int type,float *v)
+void glMaterialfv(int mode,int type,GLfloat *v)
{
GLParam p[7];
- int i,n;
+ GLint i,n;
assert(mode == GL_FRONT || mode == GL_BACK || mode==GL_FRONT_AND_BACK);
@@ -398,10 +398,10 @@
gl_add_op(p);
}
-void glMaterialf(int mode,int type,float v)
+void glMaterialf(int mode,int type,GLfloat v)
{
GLParam p[7];
- int i;
+ GLint i;
p[0].op=OP_Material;
p[1].i=mode;
@@ -423,10 +423,10 @@
gl_add_op(p);
}
-void glLightfv(int light,int type,float *v)
+void glLightfv(int light,int type,GLfloat *v)
{
GLParam p[7];
- int i;
+ GLint i;
p[0].op=OP_Light;
p[1].i=light;
@@ -438,10 +438,10 @@
}
-void glLightf(int light,int type,float v)
+void glLightf(int light,int type,GLfloat v)
{
GLParam p[7];
- int i;
+ GLint i;
p[0].op=OP_Light;
p[1].i=light;
@@ -458,7 +458,7 @@
p[0].op=OP_LightModel;
p[1].i=pname;
- p[2].f=(float)param;
+ p[2].f=(GLfloat)param;
// for(i=0;i<4;i++) p[3+i].f=0;
// for(i=0;i<3;i++) p[3+i].f=0;
p[3].f=0;
@@ -467,10 +467,10 @@
gl_add_op(p);
}
-void glLightModelfv(int pname,float *param)
+void glLightModelfv(int pname,GLfloat *param)
{
GLParam p[6];
- int i;
+ GLint i;
p[0].op=OP_LightModel;
p[1].i=pname;
@@ -491,7 +491,7 @@
gl_add_op(p);
}
-void glClearColor(float r,float g,float b,float a)
+void glClearColor(GLfloat r,GLfloat g,GLfloat b,GLfloat a)
{
GLParam p[5];
@@ -517,9 +517,9 @@
/* textures */
-void glTexImage2D( int target, int level, int components,
- int width, int height, int border,
- int format, int type, void *pixels)
+void glTexImage2D( GLint target, GLint level, GLint components,
+ GLint width, GLint height, GLint border,
+ GLint format, GLint type, void *pixels)
{
GLParam p[10];
--- a/src/arrays.c
+++ b/src/arrays.c
@@ -10,13 +10,13 @@
void
glopArrayElement(GLContext *c, GLParam *param)
{
- int i;
- int states = c->client_states;
- int idx = param[1].i;
+ GLint i;
+ GLint states = c->client_states;
+ GLint idx = param[1].i;
if (states & COLOR_ARRAY) {
GLParam p[5];
- int size = c->color_array_size;
+ GLint size = c->color_array_size;
i = idx * (size + c->color_array_stride);
p[1].f = c->color_array[i];
p[2].f = c->color_array[i+1];
@@ -32,7 +32,7 @@
c->current_normal.Z = 0.0f;
}
if (states & TEXCOORD_ARRAY) {
- int size = c->texcoord_array_size;
+ GLint size = c->texcoord_array_size;
i = idx * (size + c->texcoord_array_stride);
c->current_tex_coord.X = c->texcoord_array[i];
c->current_tex_coord.Y = c->texcoord_array[i+1];
@@ -41,7 +41,7 @@
}
if (states & VERTEX_ARRAY) {
GLParam p[5];
- int size = c->vertex_array_size;
+ GLint size = c->vertex_array_size;
i = idx * (size + c->vertex_array_stride);
p[1].f = c->vertex_array[i];
p[2].f = c->vertex_array[i+1];
--- a/src/clear.c
+++ b/src/clear.c
@@ -16,11 +16,11 @@
void glopClear(GLContext *c,GLParam *p)
{
- int mask=p[1].i;
- int z=0;
- int r=(int)(c->clear_color.v[0]*65535);
- int g=(int)(c->clear_color.v[1]*65535);
- int b=(int)(c->clear_color.v[2]*65535);
+ GLint mask=p[1].i;
+ GLint z=0;
+ GLint r=(int)(c->clear_color.v[0]*65535);
+ GLint g=(int)(c->clear_color.v[1]*65535);
+ GLint b=(int)(c->clear_color.v[2]*65535);
/* TODO : correct value of Z */
--- a/src/clip.c
+++ b/src/clip.c
@@ -12,7 +12,7 @@
void gl_transform_to_viewport(GLContext *c,GLVertex *v)
{
- float winv;
+ GLfloat winv;
/* coordinates */
winv=1.0/v->pc.W;
@@ -75,7 +75,7 @@
/* line */
-static inline void interpolate(GLVertex *q,GLVertex *p0,GLVertex *p1,float t)
+static inline void GLinterpolate(GLVertex *q,GLVertex *p0,GLVertex *p1,GLfloat t)
{
q->pc.X=p0->pc.X+(p1->pc.X-p0->pc.X)*t;
q->pc.Y=p0->pc.Y+(p1->pc.Y-p0->pc.Y)*t;
@@ -93,9 +93,9 @@
/* Line Clipping algorithm from 'Computer Graphics', Principles and
Practice */
-static inline int ClipLine1(float denom,float num,float *tmin,float *tmax)
+static inline GLint ClipLine1(GLfloat denom,GLfloat num,GLfloat *tmin,GLfloat *tmax)
{
- float t;
+ GLfloat t;
if (denom>0) {
t=num/denom;
@@ -111,10 +111,10 @@
void gl_draw_line(GLContext *c,GLVertex *p1,GLVertex *p2)
{
- float dx,dy,dz,dw,x1,y1,z1,w1;
- float tmin,tmax;
+ GLfloat dx,dy,dz,dw,x1,y1,z1,w1;
+ GLfloat tmin,tmax;
GLVertex q1,q2;
- int cc1,cc2;
+ GLint cc1,cc2;
cc1=p1->clip_code;
cc2=p2->clip_code;
@@ -149,8 +149,8 @@
ClipLine1(dz+dw,-z1-w1,&tmin,&tmax) &&
ClipLine1(-dz+dw,z1-w1,&tmin,&tmax)) {
- interpolate(&q1,p1,p2,tmin);
- interpolate(&q2,p1,p2,tmax);
+ GLinterpolate(&q1,p1,p2,tmin);
+ GLinterpolate(&q2,p1,p2,tmax);
gl_transform_to_viewport(c,&q1);
gl_transform_to_viewport(c,&q2);
@@ -170,14 +170,14 @@
*/
/* We clip the segment [a,b] against the 6 planes of the normal volume.
- * We compute the point 'c' of intersection and the value of the parameter 't'
- * of the intersection if x=a+t(b-a).
+ * We compute the point 'c' of GLintersection and the value of the parameter 't'
+ * of the GLintersection if x=a+t(b-a).
*/
#define clip_func(name,sign,dir,dir1,dir2) \
-static float name(V4 *c,V4 *a,V4 *b) \
+static GLfloat name(V4 *c,V4 *a,V4 *b) \
{\
- float t,dX,dY,dZ,dW,den;\
+ GLfloat t,dX,dY,dZ,dW,den;\
dX = (b->X - a->X);\
dY = (b->Y - a->Y);\
dZ = (b->Z - a->Z);\
@@ -206,7 +206,7 @@
clip_func(clip_zmax,+,Z,X,Y)
-float (*clip_proc[6])(V4 *,V4 *,V4 *)= {
+GLfloat (*clip_proc[6])(V4 *,V4 *,V4 *)= {
clip_xmin,clip_xmax,
clip_ymin,clip_ymax,
clip_zmin,clip_zmax
@@ -213,7 +213,7 @@
};
static inline void updateTmp(GLContext *c,
- GLVertex *q,GLVertex *p0,GLVertex *p1,float t)
+ GLVertex *q,GLVertex *p0,GLVertex *p1,GLfloat t)
{
if (c->current_shade_model == GL_SMOOTH) {
q->color.v[0]=p0->color.v[0] + (p1->color.v[0] - p0->color.v[0])*t;
@@ -253,8 +253,8 @@
void gl_draw_triangle(GLContext *c,
GLVertex *p0,GLVertex *p1,GLVertex *p2)
{
- int co,c_and,cc[3],front;
- float norm;
+ GLint co,c_and,cc[3],front;
+ GLfloat norm;
cc[0]=p0->clip_code;
cc[1]=p1->clip_code;
@@ -265,8 +265,8 @@
/* we handle the non clipped case here to go faster */
if (co==0) {
- norm=(float)(p1->zp.x-p0->zp.x)*(float)(p2->zp.y-p0->zp.y)-
- (float)(p2->zp.x-p0->zp.x)*(float)(p1->zp.y-p0->zp.y);
+ norm=(GLfloat)(p1->zp.x-p0->zp.x)*(GLfloat)(p2->zp.y-p0->zp.y)-
+ (GLfloat)(p2->zp.x-p0->zp.x)*(GLfloat)(p1->zp.y-p0->zp.y);
if (norm == 0) return;
@@ -304,9 +304,9 @@
static void gl_draw_triangle_clip(GLContext *c,
GLVertex *p0,GLVertex *p1,GLVertex *p2,int clip_bit)
{
- int co,c_and,co1,cc[3],edge_flag_tmp,clip_mask;
+ GLint co,c_and,co1,cc[3],edge_flag_tmp,clip_mask;
GLVertex tmp1,tmp2,*q[3];
- float tt;
+ GLfloat tt;
cc[0]=p0->clip_code;
cc[1]=p1->clip_code;
@@ -398,7 +398,7 @@
//puts("\n <yes, it's draw_triangle_fill>");
#ifdef PROFILE
{
- int norm;
+ GLint norm;
assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize);
--- 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)
-char font8x8_basic[128][8] = {
+GLbyte font8x8_basic[128][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/get.c
+++ b/src/get.c
@@ -32,10 +32,10 @@
}
}
-void glGetFloatv(int pname, float *v)
+void glGetFloatv(int pname, GLfloat *v)
{
- int i;
- int mnr = 0; /* just a trick to return the correct matrix */
+ GLint i;
+ GLint mnr = 0; /* just a trick to return the correct matrix */
GLContext *c = gl_get_context();
switch (pname) {
case GL_TEXTURE_MATRIX:
@@ -44,7 +44,7 @@
mnr++;
case GL_MODELVIEW_MATRIX:
{
- float *p = &c->matrix_stack_ptr[mnr]->m[0][0];;
+ GLfloat *p = &c->matrix_stack_ptr[mnr]->m[0][0];;
for (i = 0; i < 4; i++) {
*v++ = p[0];
*v++ = p[4];
--- a/src/image_util.c
+++ b/src/image_util.c
@@ -4,11 +4,11 @@
* image conversion
*/
-void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb,
- int xsize,int ysize)
+void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,GLubyte *rgb,
+ GLint xsize,int ysize)
{
- int i,n;
- unsigned char *p;
+ GLint i,n;
+ GLubyte *p;
p=rgb;
n=xsize*ysize;
@@ -20,11 +20,11 @@
//This actually converts to ABGR!!!
//This is the format of the entire engine!!!
-void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, unsigned char *rgb,
- int xsize, int ysize)
+void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, GLubyte *rgb,
+ GLint xsize, GLint ysize)
{
- int i,n;
- unsigned char *p;
+ GLint i,n;
+ GLubyte *p;
p=rgb;
n=xsize*ysize;
@@ -37,13 +37,13 @@
}
/*
- * linear interpolation with xf,yf normalized to 2^16
+ * linear GLinterpolation with xf,yf normalized to 2^16
*/
#define INTERP_NORM_BITS 16
#define INTERP_NORM (1 << INTERP_NORM_BITS)
-static inline int interpolate(int v00,int v01,int v10,int xf,int yf)
+static inline GLint GLinterpolate(int v00,int v01,int v10,int xf,int yf)
{
return v00+(((v01-v00)*xf + (v10-v00)*yf) >> INTERP_NORM_BITS);
}
@@ -53,18 +53,18 @@
* TODO: more accurate resampling
*/
-void gl_resizeImage(unsigned char *dest,int xsize_dest,int ysize_dest,
- unsigned char *src,int xsize_src,int ysize_src)
+void gl_resizeImage(GLubyte *dest,int xsize_dest,int ysize_dest,
+ GLubyte *src,int xsize_src,int ysize_src)
{
- unsigned char *pix,*pix_src;
- float x1,y1,x1inc,y1inc;
- int xi,yi,j,xf,yf,x,y;
+ GLubyte *pix,*pix_src;
+ GLfloat x1,y1,x1inc,y1inc;
+ GLint xi,yi,j,xf,yf,x,y;
pix=dest;
pix_src=src;
- x1inc=(float) (xsize_src - 1) / (float) (xsize_dest - 1);
- y1inc=(float) (ysize_src - 1) / (float) (ysize_dest - 1);
+ x1inc=(GLfloat) (xsize_src - 1) / (GLfloat) (xsize_dest - 1);
+ y1inc=(GLfloat) (ysize_src - 1) / (GLfloat) (ysize_dest - 1);
y1=0;
for(y=0;y<ysize_dest;y++) {
@@ -77,7 +77,7 @@
if ((xf+yf) <= INTERP_NORM) {
for(j=0;j<3;j++) {
- pix[j]=interpolate(pix_src[(yi*xsize_src+xi)*3+j],
+ pix[j]=GLinterpolate(pix_src[(yi*xsize_src+xi)*3+j],
pix_src[(yi*xsize_src+xi+1)*3+j],
pix_src[((yi+1)*xsize_src+xi)*3+j],
xf,yf);
@@ -86,7 +86,7 @@
xf=INTERP_NORM - xf;
yf=INTERP_NORM - yf;
for(j=0;j<3;j++) {
- pix[j]=interpolate(pix_src[((yi+1)*xsize_src+xi+1)*3+j],
+ pix[j]=GLinterpolate(pix_src[((yi+1)*xsize_src+xi+1)*3+j],
pix_src[((yi+1)*xsize_src+xi)*3+j],
pix_src[(yi*xsize_src+xi+1)*3+j],
xf,yf);
@@ -102,20 +102,20 @@
#define FRAC_BITS 16
-/* resizing with no interlating nor nearest pixel */
+/* resizing with no GLinterlating nor nearest pixel */
-void gl_resizeImageNoInterpolate(unsigned char *dest,int xsize_dest,int ysize_dest,
- unsigned char *src,int xsize_src,int ysize_src)
+void gl_resizeImageNoInterpolate(GLubyte *dest,int xsize_dest,int ysize_dest,
+ GLubyte *src,int xsize_src,int ysize_src)
{
- unsigned char *pix,*pix_src,*pix1;
- int x1,y1,x1inc,y1inc;
- int xi,yi,x,y;
+ GLubyte *pix,*pix_src,*pix1;
+ GLint x1,y1,x1inc,y1inc;
+ GLint xi,yi,x,y;
pix=dest;
pix_src=src;
- x1inc=(int)((float) ((xsize_src)<<FRAC_BITS) / (float) (xsize_dest));
- y1inc=(int)((float) ((ysize_src)<<FRAC_BITS) / (float) (ysize_dest));
+ x1inc=(int)((GLfloat) ((xsize_src)<<FRAC_BITS) / (GLfloat) (xsize_dest));
+ y1inc=(int)((GLfloat) ((ysize_src)<<FRAC_BITS) / (GLfloat) (ysize_dest));
y1=0;
for(y=0;y<ysize_dest;y++) {
--- a/src/init.c
+++ b/src/init.c
@@ -16,7 +16,7 @@
void endSharedState(GLContext *c)
{
GLSharedState *s=&c->shared_state;
- int i;
+ GLint i;
for(i=0;i<MAX_DISPLAY_LISTS;i++) {
/* TODO */
@@ -32,7 +32,7 @@
ZBuffer *zbuffer=(ZBuffer *)zbuffer1;
GLContext *c;
GLViewport *v;
- int i;
+ GLint i;
c=gl_zalloc(sizeof(GLContext));
gl_ctx=c;
--- a/src/light.c
+++ b/src/light.c
@@ -3,14 +3,14 @@
void glopMaterial(GLContext *c,GLParam *p)
{
- int mode=p[1].i;
- int type=p[2].i;
- float v[4];
+ GLint mode=p[1].i;
+ GLint type=p[2].i;
+ GLfloat v[4];
v[0]= p[3].f;
v[1]= p[4].f;
v[2]= p[5].f;
v[3]= p[6].f;
- int i;
+ GLint i;
GLMaterial *m;
if (mode == GL_FRONT_AND_BACK) {
@@ -74,8 +74,8 @@
void glopColorMaterial(GLContext *c,GLParam *p)
{
- int mode=p[1].i;
- int type=p[2].i;
+ GLint mode=p[1].i;
+ GLint type=p[2].i;
c->current_color_material_mode=mode;
c->current_color_material_type=type;
@@ -83,11 +83,11 @@
void glopLight(GLContext *c,GLParam *p)
{
- int light=p[1].i;
- int type=p[2].i;
+ GLint light=p[1].i;
+ GLint type=p[2].i;
V4 v;
GLLight *l;
- int i;
+ GLint i;
assert(light >= GL_LIGHT0 && light < GL_LIGHT0+MAX_LIGHTS );
@@ -132,7 +132,7 @@
break;
case GL_SPOT_CUTOFF:
{
- float a=v.v[0];
+ GLfloat a=v.v[0];
assert(a == 180 || (a>=0 && a<=90));
l->spot_cutoff=a;
if (a != 180) l->cos_spot_cutoff=cos(a * M_PI / 180.0);
@@ -155,9 +155,9 @@
void glopLightModel(GLContext *c,GLParam *p)
{
- int pname=p[1].i;
- float *v=&p[2].f;
- int i;
+ GLint pname=p[1].i;
+ GLfloat *v=&p[2].f;
+ GLint i;
switch(pname) {
case GL_LIGHT_MODEL_AMBIENT:
@@ -178,7 +178,7 @@
}
-static inline float clampf(float a,float min,float max)
+static inline GLfloat clampf(GLfloat a,GLfloat min,GLfloat max)
{
if (a<min) return min;
else if (a>max) return max;
@@ -209,12 +209,12 @@
/* non optimized lightening model */
void gl_shade_vertex(GLContext *c,GLVertex *v)
{
- float R,G,B,A;
+ GLfloat R,G,B,A;
GLMaterial *m;
GLLight *l;
V3 n,s,d;
- float dist,tmp,att,dot,dot_spot,dot_spec;
- int twoside = c->light_model_two_side;
+ GLfloat dist,tmp,att,dot,dot_spot,dot_spec;
+ GLint twoside = c->light_model_two_side;
m=&c->materials[0];
@@ -228,7 +228,7 @@
A=clampf(m->diffuse.v[3],0,1);
for(l=c->first_light;l!=NULL;l=l->next) {
- float lR,lB,lG;
+ GLfloat lR,lB,lG;
/* ambient */
lR=l->ambient.v[0] * m->ambient.v[0];
@@ -304,7 +304,7 @@
if (twoside && dot_spec < 0) dot_spec = -dot_spec;
if (dot_spec>0) {
GLSpecBuf *specbuf;
- int idx;
+ GLint idx;
tmp=sqrt(s.X*s.X+s.Y*s.Y+s.Z*s.Z);
if (tmp > 1E-3) {
dot_spec=dot_spec / tmp;
--- a/src/list.c
+++ b/src/list.c
@@ -14,7 +14,7 @@
#include "opinfo.h"
};
-static int op_table_size[]=
+static GLint op_table_size[]=
{
#define ADD_OP(a,b,c) b + 1 ,
@@ -81,7 +81,7 @@
void gl_print_op(FILE *f,GLParam *p)
{
- int op;
+ GLint op;
char *s;
op=p[0].op;
@@ -110,9 +110,9 @@
void gl_compile_op(GLContext *c,GLParam *p)
{
- int op,op_size;
+ GLint op,op_size;
GLParamBuffer *ob,*ob1;
- int index,i;
+ GLint index,i;
op=p[0].op;
op_size=op_table_size[op];
@@ -144,7 +144,7 @@
void gl_add_op(GLParam *p)
{
GLContext *c=gl_get_context();
- int op;
+ GLint op;
op=p[0].op;
if (c->exec_flag) {
@@ -174,7 +174,7 @@
void glopCallList(GLContext *c,GLParam *p)
{
GLList *l;
- int list,op;
+ GLint list,op;
list=p[1].ui;
l=find_list(c,list);
@@ -240,7 +240,7 @@
GLuint glGenLists(int range)
{
GLContext *c=gl_get_context();
- int count,i,list;
+ GLint count,i,list;
GLList **lists;
lists=c->shared_state.lists;
--- a/src/matrix.c
+++ b/src/matrix.c
@@ -1,8 +1,8 @@
#include "zgl.h"
-void gl_print_matrix( const float *m)
+void gl_print_matrix( const GLfloat *m)
{
- int i;
+ GLint i;
for (i=0;i<4;i++) {
fprintf(stderr,"%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] );
@@ -17,7 +17,7 @@
void glopMatrixMode(GLContext *c,GLParam *p)
{
- int mode=p[1].i;
+ GLint mode=p[1].i;
switch(mode) {
case GL_MODELVIEW:
c->matrix_mode=0;
@@ -36,7 +36,7 @@
void glopLoadMatrix(GLContext *c,GLParam *p)
{
M4 *m;
- int i;
+ GLint i;
GLParam *q;
@@ -65,7 +65,7 @@
void glopMultMatrix(GLContext *c,GLParam *p)
{
M4 m;
- int i;
+ GLint i;
GLParam *q;
q=p+1;
@@ -86,7 +86,7 @@
void glopPushMatrix(GLContext *c,GLParam *p)
{
- int n=c->matrix_mode;
+ GLint n=c->matrix_mode;
M4 *m;
assert( (c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1 )
@@ -101,7 +101,7 @@
void glopPopMatrix(GLContext *c,GLParam *p)
{
- int n=c->matrix_mode;
+ GLint n=c->matrix_mode;
assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] );
c->matrix_stack_ptr[n]--;
@@ -112,9 +112,9 @@
void glopRotate(GLContext *c,GLParam *p)
{
M4 m;
- float u[3];
- float angle;
- int dir_code;
+ GLfloat u[3];
+ GLfloat angle;
+ GLint dir_code;
angle = p[1].f * M_PI / 180.0;
u[0]=p[2].f;
@@ -142,10 +142,10 @@
break;
default:
{
- float cost, sint;
+ GLfloat cost, sint;
/* normalize vector */
- float len = u[0]*u[0]+u[1]*u[1]+u[2]*u[2];
+ GLfloat len = u[0]*u[0]+u[1]*u[1]+u[2]*u[2];
if (len == 0.0f) return;
len = 1.0f / sqrt(len);
u[0] *= len;
@@ -181,8 +181,8 @@
void glopScale(GLContext *c,GLParam *p)
{
- float *m;
- float x=p[1].f,y=p[2].f,z=p[3].f;
+ GLfloat *m;
+ GLfloat x=p[1].f,y=p[2].f,z=p[3].f;
m=&c->matrix_stack_ptr[c->matrix_mode]->m[0][0];
@@ -195,8 +195,8 @@
void glopTranslate(GLContext *c,GLParam *p)
{
- float *m;
- float x=p[1].f,y=p[2].f,z=p[3].f;
+ GLfloat *m;
+ GLfloat x=p[1].f,y=p[2].f,z=p[3].f;
m=&c->matrix_stack_ptr[c->matrix_mode]->m[0][0];
@@ -211,15 +211,15 @@
void glopFrustum(GLContext *c,GLParam *p)
{
- float *r;
+ GLfloat *r;
M4 m;
- float left=p[1].f;
- float right=p[2].f;
- float bottom=p[3].f;
- float top=p[4].f;
- float near=p[5].f;
- float farp=p[6].f;
- float x,y,A,B,C,D;
+ GLfloat left=p[1].f;
+ GLfloat right=p[2].f;
+ GLfloat bottom=p[3].f;
+ GLfloat top=p[4].f;
+ GLfloat near=p[5].f;
+ GLfloat farp=p[6].f;
+ GLfloat x,y,A,B,C,D;
x = (2.0*near) / (right-left);
y = (2.0*near) / (top-bottom);
--- a/src/misc.c
+++ b/src/misc.c
@@ -5,7 +5,7 @@
void glPolygonStipple(void* a){
#if TGL_FEATURE_POLYGON_STIPPLE
- unsigned char* b = a;
+ GLubyte* b = a;
GLContext *c=gl_get_context();
ZBuffer *zb = c->zb;
@@ -19,7 +19,7 @@
void glopViewport(GLContext *c,GLParam *p)
{
- int xsize,ysize,xmin,ymin,xsize_req,ysize_req;
+ GLint xsize,ysize,xmin,ymin,xsize_req,ysize_req;
xmin=p[1].i;
ymin=p[2].i;
@@ -60,8 +60,8 @@
void glopEnableDisable(GLContext *c,GLParam *p)
{
- int code=p[1].i;
- int v=p[2].i;
+ GLint code=p[1].i;
+ GLint v=p[2].i;
switch(code) {
case GL_CULL_FACE:
@@ -111,26 +111,26 @@
void glopShadeModel(GLContext *c,GLParam *p)
{
- int code=p[1].i;
+ GLint code=p[1].i;
c->current_shade_model=code;
}
void glopCullFace(GLContext *c,GLParam *p)
{
- int code=p[1].i;
+ GLint code=p[1].i;
c->current_cull_face=code;
}
void glopFrontFace(GLContext *c,GLParam *p)
{
- int code=p[1].i;
+ GLint code=p[1].i;
c->current_front_face=code;
}
void glopPolygonMode(GLContext *c,GLParam *p)
{
- int face=p[1].i;
- int mode=p[2].i;
+ GLint face=p[1].i;
+ GLint mode=p[2].i;
switch(face) {
case GL_BACK:
@@ -151,8 +151,8 @@
void glopHint(GLContext *c,GLParam *p)
{
#if 0
- int target=p[1].i;
- int mode=p[2].i;
+ GLint target=p[1].i;
+ GLint mode=p[2].i;
/* do nothing */
#endif
--- a/src/msghandling.c
+++ b/src/msghandling.c
@@ -1,6 +1,6 @@
#include <stdarg.h>
#include <stdio.h>
-
+#include "../include/GL/gl.h"
#define NDEBUG
#ifdef NDEBUG
@@ -9,7 +9,7 @@
/* Use this function to output messages when something unexpected
happens (which might be an indication of an error). *Don't* use it
- when there's internal errors in the code - these should be handled
+ when there's GLinternal errors in the code - these should be handled
by asserts. */
void
tgl_warning(const char *format, ...)
--- a/src/msghandling.h
+++ b/src/msghandling.h
@@ -1,6 +1,6 @@
#ifndef _msghandling_h_
#define _msghandling_h_
-
+#include "../include/GL/gl.h"
extern void tgl_warning(const char *text, ...);
extern void tgl_trace(const char *text, ...);
extern void tgl_fixme(const char *text, ...);
--- a/src/quick.sh
+++ b/src/quick.sh
@@ -3,6 +3,10 @@
#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/unsigned int/GLuint/g' *.c *.h
-sed -i 's/\nint /GLint /g' *.c *.h
+#sed -i 's/unsigned int/GLuint/g' *.c *.h
+#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/ int/ GLint/g' *.c *.h
+
#gcc *.c -o executable.out -lglut -lGL -lm -lGLU
--- a/src/select.c
+++ b/src/select.c
@@ -3,7 +3,7 @@
int glRenderMode(int mode)
{
GLContext *c=gl_get_context();
- int result=0;
+ GLint result=0;
switch(c->render_mode) {
case GL_RENDER:
@@ -88,7 +88,7 @@
void gl_add_select(GLContext *c,GLuint zmin,GLuint zmax)
{
GLuint *ptr;
- int n,i;
+ GLint n,i;
if (!c->select_overflow) {
if (c->select_hit==NULL) {
--- a/src/specbuf.c
+++ b/src/specbuf.c
@@ -3,10 +3,10 @@
#include <math.h>
#include <stdlib.h>
-static void calc_buf(GLSpecBuf *buf, const float shininess)
+static void calc_buf(GLSpecBuf *buf, const GLfloat shininess)
{
- int i;
- float val, inc;
+ GLint i;
+ GLfloat val, inc;
val = 0.0f;
inc = 1.0f/SPECULAR_BUFFER_SIZE;
for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++) {
@@ -16,8 +16,8 @@
}
GLSpecBuf *
-specbuf_get_buffer(GLContext *c, const int shininess_i,
- const float shininess)
+specbuf_get_buffer(GLContext *c, const GLint shininess_i,
+ const GLfloat shininess)
{
GLSpecBuf *found, *oldest;
found = oldest = c->specbuf_first;
--- a/src/specbuf.h
+++ b/src/specbuf.h
@@ -9,14 +9,14 @@
#define SPECULAR_BUFFER_RESOLUTION 1024
typedef struct GLSpecBuf {
- int shininess_i;
- int last_used;
- float buf[SPECULAR_BUFFER_SIZE+1];
+ GLint shininess_i;
+ GLint last_used;
+ GLfloat buf[SPECULAR_BUFFER_SIZE+1];
struct GLSpecBuf *next;
} GLSpecBuf;
-GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i,
- const float shininess);
+GLSpecBuf *specbuf_get_buffer(GLContext *c, const GLint shininess_i,
+ const GLfloat shininess);
void specbuf_cleanup(GLContext *c); /* free all memory used */
#endif /* _tgl_specbuf_h_ */
\ No newline at end of file
--- a/src/texture.c
+++ b/src/texture.c
@@ -16,7 +16,7 @@
return NULL;
}
-void* glGetTexturePixmap(int text, int level, int* xsize, int* ysize){
+void* glGetTexturePixmap(int text, GLint level, GLint* xsize, GLint* ysize){
GLTexture* tex;
GLContext *c=gl_get_context();
assert(text >= 0 && level < MAX_TEXTURE_LEVELS);
@@ -31,7 +31,7 @@
{
GLTexture *t,**ht;
GLImage *im;
- int i;
+ GLint i;
t=find_texture(c,h);
if (t->prev==NULL) {
@@ -81,7 +81,7 @@
void glGenTextures(int n, GLuint *textures)
{
GLContext *c=gl_get_context();
- int max,i;
+ GLint max,i;
GLTexture *t;
max=0;
@@ -102,7 +102,7 @@
void glDeleteTextures(int n, const GLuint *textures)
{
GLContext *c=gl_get_context();
- int i;
+ GLint i;
GLTexture *t;
for(i=0;i<n;i++) {
@@ -119,8 +119,8 @@
void glopBindTexture(GLContext *c,GLParam *p)
{
- int target=p[1].i;
- int texture=p[2].i;
+ GLint target=p[1].i;
+ GLint texture=p[2].i;
GLTexture *t;
assert(target == GL_TEXTURE_2D && texture >= 0);
@@ -134,18 +134,18 @@
void glopTexImage2D(GLContext *c,GLParam *p)
{
- int target=p[1].i;
- int level=p[2].i;
- int components=p[3].i;
- int width=p[4].i;
- int height=p[5].i;
- int border=p[6].i;
- int format=p[7].i;
- int type=p[8].i;
+ GLint target=p[1].i;
+ GLint level=p[2].i;
+ GLint components=p[3].i;
+ GLint width=p[4].i;
+ GLint height=p[5].i;
+ GLint border=p[6].i;
+ GLint format=p[7].i;
+ GLint type=p[8].i;
void *pixels=p[9].p;
GLImage *im;
- unsigned char *pixels1;
- int do_free;
+ GLubyte *pixels1;
+ GLint do_free;
if (!(target == GL_TEXTURE_2D && level == 0 && components == 3 &&
border == 0 && format == GL_RGB &&
@@ -156,7 +156,7 @@
do_free=0;
if (width != 256 || height != 256) {
pixels1 = gl_malloc(256 * 256 * 3);
- /* no interpolation is done here to respect the original image aliasing ! */
+ /* no GLinterpolation is done here to respect the original image aliasing ! */
gl_resizeImageNoInterpolate(pixels1,256,256,pixels,width,height);
do_free=1;
width=256;
@@ -194,9 +194,9 @@
/* TODO: not all tests are done */
void glopTexEnv(GLContext *c,GLParam *p)
{
- int target=p[1].i;
- int pname=p[2].i;
- int param=p[3].i;
+ GLint target=p[1].i;
+ GLint pname=p[2].i;
+ GLint param=p[3].i;
if (target != GL_TEXTURE_ENV) {
error:
@@ -211,9 +211,9 @@
/* TODO: not all tests are done */
void glopTexParameter(GLContext *c,GLParam *p)
{
- int target=p[1].i;
- int pname=p[2].i;
- int param=p[3].i;
+ GLint target=p[1].i;
+ GLint pname=p[2].i;
+ GLint param=p[3].i;
if (target != GL_TEXTURE_2D) {
error:
@@ -230,8 +230,8 @@
void glopPixelStore(GLContext *c,GLParam *p)
{
- int pname=p[1].i;
- int param=p[2].i;
+ GLint pname=p[1].i;
+ GLint param=p[2].i;
if (pname != GL_UNPACK_ALIGNMENT ||
param != 1) {
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -55,7 +55,7 @@
void gl_eval_viewport(GLContext * c)
{
GLViewport *v;
- float zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
+ GLfloat zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
v = &c->viewport;
@@ -70,7 +70,7 @@
void glopBegin(GLContext * c, GLParam * p)
{
- int type;
+ GLint type;
M4 tmp;
assert(c->in_begin == 0);
@@ -88,7 +88,7 @@
gl_M4_Inv(&tmp, c->matrix_stack_ptr[0]);
gl_M4_Transpose(&c->matrix_model_view_inv, &tmp);
} else {
- float *m = &c->matrix_model_projection.m[0][0];
+ GLfloat *m = &c->matrix_model_projection.m[0][0];
/* precompute projection matrix */
gl_M4_Mul(&c->matrix_model_projection,
c->matrix_stack_ptr[1],
@@ -144,7 +144,7 @@
/* TODO : handle all cases */
static inline void gl_vertex_transform(GLContext * c, GLVertex * v)
{
- float *m;
+ GLfloat *m;
V4 *n;
if (c->lighting_enabled) {
@@ -206,7 +206,7 @@
void glopVertex(GLContext * c, GLParam * p)
{
GLVertex *v;
- int n, i, cnt;
+ GLint n, i, cnt;
assert(c->in_begin != 0);
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -10,14 +10,14 @@
//#include "../include/GL/gl.h"
#include "../include/zbuffer.h"
-ZBuffer *ZB_open(int xsize, int ysize, int mode,
- int nb_colors,
- unsigned char *color_indexes,
- int *color_table,
+ZBuffer *ZB_open(int xsize, GLint ysize, GLint mode,
+ GLint nb_colors,
+ GLubyte *color_indexes,
+ GLint *color_table,
void *frame_buffer)
{
ZBuffer *zb;
- int size;
+ GLint size;
zb = gl_malloc(sizeof(ZBuffer));
if (zb == NULL)
@@ -87,9 +87,9 @@
gl_free(zb);
}
-void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize)
+void ZB_resize(ZBuffer * zb, void *frame_buffer, GLint xsize, GLint ysize)
{
- int size;
+ GLint size;
/* xsize must be a multiple of 4 */
xsize = xsize & ~3;
@@ -133,13 +133,13 @@
static void ZB_copyBuffer(ZBuffer * zb,
void *buf,
- int linesize)
+ GLint linesize)
{
- unsigned char *p1;
+ GLubyte *p1;
PIXEL *q;
- int y;
+ GLint y;
#if !TGL_FEATURE_NO_COPY_COLOR
- int n;
+ GLint n;
#endif
q = zb->pbuf;
@@ -158,7 +158,7 @@
memcpy(p1, q, n);
#endif
p1 += linesize; //TODO make this a predictable behavior.
- q = (PIXEL *) ((char *) q + zb->linesize);
+ q = (PIXEL *) ((GLbyte *) q + zb->linesize);
}
}
@@ -182,11 +182,11 @@
//This function is never called.
static void ZB_copyFrameBufferRGB32(ZBuffer * zb,
void *buf,
- int linesize)
+ GLint linesize)
{
unsigned short *q;
GLuint *p, *p1, v, w0, w1;
- int y, n;
+ GLint y, n;
q = zb->pbuf;
p1 = (GLuint *) buf;
@@ -264,11 +264,11 @@
/*
static void ZB_copyFrameBufferRGB24(ZBuffer * zb,
void *buf,
- int linesize)
+ GLint linesize)
{
unsigned short *q;
GLuint *p, *p1, w0, w1, w2, v0, v1;
- int y, n;
+ GLint y, n;
q = zb->pbuf;
p1 = (GLuint *) buf;
@@ -289,7 +289,7 @@
p += 3;
} while (--n > 0);
- *((char *) p1) += linesize;
+ *((GLbyte *) p1) += linesize;
}
}
*/
@@ -344,11 +344,11 @@
// XXX: not optimized
static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
- void *buf, int linesize)
+ void *buf, GLint linesize)
{
PIXEL *q;
unsigned short *p, *p1;
- int y, n;
+ GLint y, n;
q = zb->pbuf;
p1 = (unsigned short *) buf;
@@ -361,10 +361,10 @@
p[1] = RGB24_TO_RGB16(q[3], q[4], q[5]);
p[2] = RGB24_TO_RGB16(q[6], q[7], q[8]);
p[3] = RGB24_TO_RGB16(q[9], q[10], q[11]);
- q = (PIXEL *)((char *)q + 4 * PSZB);
+ q = (PIXEL *)((GLbyte *)q + 4 * PSZB);
p += 4;
} while (--n > 0);
- p1 = (unsigned short *)((char *)p1 + linesize);
+ p1 = (unsigned short *)((GLbyte *)p1 + linesize);
}
}
@@ -400,11 +400,11 @@
/* XXX: not optimized */
/*
static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
- void *buf, int linesize)
+ void *buf, GLint linesize)
{
PIXEL *q;
unsigned short *p, *p1;
- int y, n;
+ GLint y, n;
q = zb->pbuf;
p1 = (unsigned short *) buf;
@@ -420,7 +420,7 @@
q += 4;
p += 4;
} while (--n > 0);
- p1 = (unsigned short *)((char *)p1 + linesize);
+ p1 = (unsigned short *)((GLbyte *)p1 + linesize);
}
}
*/
@@ -455,9 +455,9 @@
* adr must be aligned on an 'int'
*/
//Used in 16 bit mode
-void memset_s(void *adr, int val, int count)
+void memset_s(void *adr, GLint val, GLint count)
{
- int i, n, v;
+ GLint i, n, v;
GLuint *p;
unsigned short *q;
@@ -480,9 +480,9 @@
}
//Used in 32 bit mode
-void memset_l(void *adr, int val, int count)
+void memset_l(void *adr, GLint val, GLint count)
{
- int i, n, v;
+ GLint i, n, v;
GLuint *p;
p = adr;
@@ -503,13 +503,13 @@
/* count must be a multiple of 4 and >= 4 */
//Gek's note: Should never be used.
-void memset_RGB24(void *adr,int r, int v, int b,long count)
+void memset_RGB24(void *adr,int r, GLint v, GLint b,long count)
{
long i, n;
register long v1,v2,v3,*pt=(long *)(adr);
- unsigned char *p,R=(unsigned char)r,V=(unsigned char)v,B=(unsigned char)b;
+ GLubyte *p,R=(GLubyte)r,V=(GLubyte)v,B=(GLubyte)b;
- p=(unsigned char *)adr;
+ p=(GLubyte *)adr;
*p++=R;
*p++=V;
*p++=B;
@@ -533,13 +533,13 @@
}
}
-void ZB_clear(ZBuffer * zb, int clear_z, int z,
- int clear_color, int r, int g, int b)
+void ZB_clear(ZBuffer * zb, GLint clear_z, GLint z,
+ GLint clear_color, GLint r, GLint g, GLint b)
{
#if TGL_FEATURE_RENDER_BITS != 24
- int color;
+ GLint color;
#endif
- int y;
+ GLint y;
PIXEL *pp;
if (clear_z) {
@@ -566,7 +566,7 @@
#else
#error BADJUJU
#endif
- pp = (PIXEL *) ((char *) pp + zb->linesize);
+ pp = (PIXEL *) ((GLbyte *) pp + zb->linesize);
}
}
}
--- a/src/zdither.c
+++ b/src/zdither.c
@@ -23,7 +23,7 @@
#define DITHER_INDEX(r,g,b) ((b) + (g) * _B + (r) * (_B * _G))
#define MAXC 256
-static int kernel8[_DY*_DX] = {
+static GLint kernel8[_DY*_DX] = {
0 * MAXC, 8 * MAXC, 2 * MAXC, 10 * MAXC,
12 * MAXC, 4 * MAXC, 14 * MAXC, 6 * MAXC,
3 * MAXC, 11 * MAXC, 1 * MAXC, 9 * MAXC,
@@ -33,9 +33,9 @@
/* we build the color table and the lookup table */
void ZB_initDither(ZBuffer *zb,int nb_colors,
- unsigned char *color_indexes,int *color_table)
+ GLubyte *color_indexes,int *color_table)
{
- int c,r,g,b,i,index,r1,g1,b1;
+ GLint c,r,g,b,i,index,r1,g1,b1;
if (nb_colors < (_R * _G * _B)) {
fprintf(stderr,"zdither: not enough colors\n");
@@ -81,7 +81,7 @@
#if 0
int ZDither_lookupColor(int r,int g,int b)
{
- unsigned char *ctable=zdither_color_table;
+ GLubyte *ctable=zdither_color_table;
return ctable[_MIX(_DITH0(_R, r), _DITH0(_G, g),_DITH0(_B, b))];
}
#endif
@@ -89,7 +89,7 @@
#define DITHER_PIXEL2(a) \
{ \
- register int v,t,r,g,c; \
+ register GLint v,t,r,g,c; \
v=*(GLuint *)(pp+(a)); \
g=(v & 0x07DF07DF) + g_d; \
r=(((v & 0xF800F800) >> 2) + r_d) & 0x70007000; \
@@ -102,15 +102,15 @@
linesize are not multiple of 2, it cannot work efficiently (or
hang!) */
-void ZB_ditherFrameBuffer(ZBuffer *zb,unsigned char *buf,
- int linesize)
+void ZB_ditherFrameBuffer(ZBuffer *zb,GLubyte *buf,
+ GLint linesize)
{
- int xk,yk,x,y,c1,c2;
- unsigned char *dest1;
+ GLint xk,yk,x,y,c1,c2;
+ GLubyte *dest1;
unsigned short *pp1;
- int r_d,g_d,b_d;
- unsigned char *ctable=zb->dctable;
- register unsigned char *dest;
+ GLint r_d,g_d,b_d;
+ GLubyte *ctable=zb->dctable;
+ register GLubyte *dest;
register unsigned short *pp;
assert( ((long)buf & 1) == 0 && (linesize & 1) == 0);
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -51,9 +51,9 @@
#define TGL_OFFSET_POINT 0x4
typedef struct GLSpecBuf {
- int shininess_i;
- int last_used;
- float buf[SPECULAR_BUFFER_SIZE+1];
+ GLint shininess_i;
+ GLint last_used;
+ GLfloat buf[SPECULAR_BUFFER_SIZE+1];
struct GLSpecBuf *next;
} GLSpecBuf;
@@ -63,15 +63,15 @@
V4 specular;
V4 position;
V3 spot_direction;
- float spot_exponent;
- float spot_cutoff;
- float attenuation[3];
+ GLfloat spot_exponent;
+ GLfloat spot_cutoff;
+ GLfloat attenuation[3];
/* precomputed values */
- float cos_spot_cutoff;
+ GLfloat cos_spot_cutoff;
V3 norm_spot_direction;
V3 norm_position;
/* we use a linked list to know which are the enabled lights */
- int enabled;
+ GLint enabled;
struct GLLight *next,*prev;
} GLLight;
@@ -80,25 +80,25 @@
V4 ambient;
V4 diffuse;
V4 specular;
- float shininess;
+ GLfloat shininess;
/* computed values */
- int shininess_i;
- int do_specular;
+ GLint shininess_i;
+ GLint do_specular;
} GLMaterial;
typedef struct GLViewport {
- int xmin,ymin,xsize,ysize;
+ GLint xmin,ymin,xsize,ysize;
V3 scale;
V3 trans;
- int updated;
+ GLint updated;
} GLViewport;
typedef union {
- int op;
- float f;
- int i;
+ GLint op;
+ GLfloat f;
+ GLint i;
GLuint ui;
void *p;
} GLParam;
@@ -114,7 +114,7 @@
} GLList;
typedef struct GLVertex {
- int edge_flag;
+ GLint edge_flag;
V3 normal;
V4 coord;
V4 tex_coord;
@@ -123,13 +123,13 @@
/* computed values */
V4 ec; /* eye coordinates */
V4 pc; /* coordinates in the normalized volume */
- int clip_code; /* clip code */
- ZBufferPoint zp; /* integer coordinates for the rasterization */
+ GLint clip_code; /* clip code */
+ ZBufferPoint zp; /* GLinteger coordinates for the rasterization */
} GLVertex;
typedef struct GLImage {
void *pixmap;
- int xsize,ysize;
+ GLint xsize,ysize;
} GLImage;
/* textures */
@@ -138,7 +138,7 @@
typedef struct GLTexture {
GLImage images[MAX_TEXTURE_LEVELS];
- int handle;
+ GLint handle;
struct GLTexture *next,*prev;
} GLTexture;
@@ -165,19 +165,19 @@
GLLight lights[MAX_LIGHTS];
GLLight *first_light;
V4 ambient_light_model;
- int local_light_model;
- int lighting_enabled;
- int light_model_two_side;
+ GLint local_light_model;
+ GLint lighting_enabled;
+ GLint light_model_two_side;
/* materials */
GLMaterial materials[2];
- int color_material_enabled;
- int current_color_material_mode;
- int current_color_material_type;
+ GLint color_material_enabled;
+ GLint current_color_material_mode;
+ GLint current_color_material_type;
/* textures */
GLTexture *current_texture;
- int texture_2d_enabled;
+ GLint texture_2d_enabled;
/* shared state */
GLSharedState shared_state;
@@ -184,98 +184,98 @@
/* current list */
GLParamBuffer *current_op_buffer;
- int current_op_buffer_index;
- int exec_flag,compile_flag,print_flag;
+ GLint current_op_buffer_index;
+ GLint exec_flag,compile_flag,print_flag;
/* matrix */
- int matrix_mode;
+ GLint matrix_mode;
M4 *matrix_stack[3];
M4 *matrix_stack_ptr[3];
- int matrix_stack_depth_max[3];
+ GLint matrix_stack_depth_max[3];
M4 matrix_model_view_inv;
M4 matrix_model_projection;
- int matrix_model_projection_updated;
- int matrix_model_projection_no_w_transform;
- int apply_texture_matrix;
+ GLint matrix_model_projection_updated;
+ GLint matrix_model_projection_no_w_transform;
+ GLint apply_texture_matrix;
/* viewport */
GLViewport viewport;
/* current state */
- int polygon_mode_back;
- int polygon_mode_front;
+ GLint polygon_mode_back;
+ GLint polygon_mode_front;
- int current_front_face;
- int current_shade_model;
- int current_cull_face;
- int cull_face_enabled;
- int normalize_enabled;
+ GLint current_front_face;
+ GLint current_shade_model;
+ GLint current_cull_face;
+ GLint cull_face_enabled;
+ GLint normalize_enabled;
gl_draw_triangle_func draw_triangle_front,draw_triangle_back;
/* selection */
- int render_mode;
+ GLint render_mode;
GLuint *select_buffer;
- int select_size;
+ GLint select_size;
GLuint *select_ptr,*select_hit;
- int select_overflow;
- int select_hits;
+ GLint select_overflow;
+ GLint select_hits;
/* names */
GLuint name_stack[MAX_NAME_STACK_DEPTH];
- int name_stack_size;
+ GLint name_stack_size;
/* clear */
- float clear_depth;
+ GLfloat clear_depth;
V4 clear_color;
/* current vertex state */
V4 current_color;
- //GLuint longcurrent_color[3]; /* precomputed integer color */
+ //GLuint longcurrent_color[3]; /* precomputed GLinteger color */
V4 current_normal;
V4 current_tex_coord;
- int current_edge_flag;
+ GLint current_edge_flag;
/* glBegin / glEnd */
- int in_begin;
- int begin_type;
- int vertex_n,vertex_cnt;
- int vertex_max;
+ GLint in_begin;
+ GLint begin_type;
+ GLint vertex_n,vertex_cnt;
+ GLint vertex_max;
GLVertex *vertex;
/* opengl 1.1 arrays */
- float *vertex_array;
- int vertex_array_size;
- int vertex_array_stride;
- float *normal_array;
- int normal_array_stride;
- float *color_array;
- int color_array_size;
- int color_array_stride;
- float *texcoord_array;
- int texcoord_array_size;
- int texcoord_array_stride;
- int client_states;
+ GLfloat *vertex_array;
+ GLint vertex_array_size;
+ GLint vertex_array_stride;
+ GLfloat *normal_array;
+ GLint normal_array_stride;
+ GLfloat *color_array;
+ GLint color_array_size;
+ GLint color_array_stride;
+ GLfloat *texcoord_array;
+ GLint texcoord_array_size;
+ GLint texcoord_array_stride;
+ GLint client_states;
/* opengl 1.1 polygon offset */
- float offset_factor;
- float offset_units;
- int offset_states;
+ GLfloat offset_factor;
+ GLfloat offset_units;
+ GLint offset_states;
/* specular buffer. could probably be shared between contexts,
but that wouldn't be 100% thread safe */
GLSpecBuf *specbuf_first;
- int specbuf_used_counter;
- int specbuf_num_buffers;
+ GLint specbuf_used_counter;
+ GLint specbuf_num_buffers;
/* opaque structure for user's use */
void *opaque;
/* resize viewport function */
- int (*gl_resize_viewport)(struct GLContext *c,int *xsize,int *ysize);
+ GLint (*gl_resize_viewport)(struct GLContext *c,int *xsize,int *ysize);
/* depth test */
- int depth_test;
+ GLint depth_test;
} GLContext;
extern GLContext *gl_ctx;
@@ -298,7 +298,7 @@
GLVertex *p0,GLVertex *p1,GLVertex *p2);
/* matrix.c */
-void gl_print_matrix(const float *m);
+void gl_print_matrix(const GLfloat *m);
/*
void glopLoadIdentity(GLContext *c,GLParam *p);
void glopTranslate(GLContext *c,GLParam *p);*/
@@ -313,14 +313,14 @@
GLTexture *alloc_texture(GLContext *c,int h);
/* image_util.c */
-void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,unsigned char *rgb,
- int xsize,int ysize);
-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);
-void gl_resizeImageNoInterpolate(unsigned char *dest,int xsize_dest,int ysize_dest,
- unsigned char *src,int xsize_src,int ysize_src);
+void gl_convertRGB_to_5R6G5B(unsigned short *pixmap,GLubyte *rgb,
+ GLint xsize,int ysize);
+void gl_convertRGB_to_8A8R8G8B(GLuint *pixmap, GLubyte *rgb,
+ GLint xsize, GLint ysize);
+void gl_resizeImage(GLubyte *dest,int xsize_dest,int ysize_dest,
+ GLubyte *src,int xsize_src,int ysize_src);
+void gl_resizeImageNoInterpolate(GLubyte *dest,int xsize_dest,int ysize_dest,
+ GLubyte *src,int xsize_src,int ysize_src);
GLContext *gl_get_context(void);
@@ -328,8 +328,8 @@
/* specular buffer "api" */
-GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i,
- const float shininess);
+GLSpecBuf *specbuf_get_buffer(GLContext *c, const GLint shininess_i,
+ const GLfloat shininess);
#ifdef __BEOS__
void dprintf(const char *, ...);
@@ -358,9 +358,9 @@
#define CLIP_EPSILON (1E-5)
-static inline int gl_clipcode(float x,float y,float z,float w1)
+static inline GLint gl_clipcode(GLfloat x,GLfloat y,GLfloat z,GLfloat w1)
{
- float w;
+ GLfloat w;
w=w1 * (1.0 + CLIP_EPSILON);
return (x<-w) |
--- a/src/zline.c
+++ b/src/zline.c
@@ -7,10 +7,10 @@
{
unsigned short *pz;
PIXEL *pp;
- int zz;
+ GLint zz;
pz = zb->zbuf + (p->y * zb->xsize + p->x);
- pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB);
+ pp = (PIXEL *) ((GLbyte *) zb->pbuf + zb->linesize * p->y + p->x * PSZB);
zz = p->z >> ZB_POINT_Z_FRAC_BITS;
if (ZCMP(zz, *pz)) {
#if TGL_FEATURE_RENDER_BITS == 24
@@ -26,12 +26,12 @@
#define INTERP_Z
static void ZB_line_flat_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
- int color)
+ GLint color)
{
#include "zline.h"
}
-/* line with color interpolation */
+/* line with color GLinterpolation */
#define INTERP_Z
#define INTERP_RGB
static void ZB_line_interp_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
@@ -39,10 +39,10 @@
#include "zline.h"
}
-/* no Z interpolation */
+/* no Z GLinterpolation */
static void ZB_line_flat(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2,
- int color)
+ GLint color)
{
#include "zline.h"
}
@@ -55,12 +55,12 @@
void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
{
- int color1, color2;
+ GLint color1, color2;
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
- /* choose if the line should have its color interpolated or not */
+ /* choose if the line should have its color GLinterpolated or not */
if (color1 == color2) {
ZB_line_flat_z(zb, p1, p2, color1);
} else {
@@ -70,12 +70,12 @@
void ZB_line(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2)
{
- int color1, color2;
+ GLint color1, color2;
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
- /* choose if the line should have its color interpolated or not */
+ /* choose if the line should have its color GLinterpolated or not */
if (color1 == color2) {
ZB_line_flat(zb, p1, p2, color1);
} else {
--- a/src/zline.h
+++ b/src/zline.h
@@ -1,6 +1,6 @@
{
- int n, dx, dy, sx, pp_inc_1, pp_inc_2;
- register int a;
+ GLint n, dx, dy, sx, pp_inc_1, pp_inc_2;
+ register GLint a;
register PIXEL *pp;
#if defined(INTERP_RGB) || TGL_FEATURE_RENDER_BITS == 24
register GLuint r, g, b;
@@ -10,8 +10,8 @@
#endif
#ifdef INTERP_Z
register unsigned short *pz;
- int zinc;
- register int z, zz;
+ GLint zinc;
+ register GLint z, zz;
#endif
if (p1->y > p2->y || (p1->y == p2->y && p1->x > p2->x)) {
@@ -21,7 +21,7 @@
p2 = tmp;
}
sx = zb->xsize;
- pp = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p1->y + p1->x * PSZB);
+ pp = (PIXEL *) ((GLbyte *) zb->pbuf + zb->linesize * p1->y + p1->x * PSZB);
#ifdef INTERP_Z
pz = zb->zbuf + (p1->y * sx + p1->x);
z = p1->z;
@@ -86,8 +86,8 @@
PUTPIXEL();\
ZZ(z+=zinc);\
RGB(r+=rinc;g+=ginc;b+=binc);\
- if (a>0) { pp=(PIXEL *)((char *)pp + pp_inc_1); ZZ(pz+=(inc_1)); a-=dx; }\
- else { pp=(PIXEL *)((char *)pp + pp_inc_2); ZZ(pz+=(inc_2)); a+=dy; }\
+ if (a>0) { pp=(PIXEL *)((GLbyte *)pp + pp_inc_1); ZZ(pz+=(inc_1)); a-=dx; }\
+ else { pp=(PIXEL *)((GLbyte *)pp + pp_inc_2); ZZ(pz+=(inc_2)); a+=dy; }\
} while (--n >= 0);
/* fin macro */
@@ -113,7 +113,7 @@
#undef INTERP_Z
#undef INTERP_RGB
-/* internal defines */
+/* GLinternal defines */
#undef DRAWLINE
#undef PUTPIXEL
#undef ZZ
--- a/src/zmath.c
+++ b/src/zmath.c
@@ -31,8 +31,8 @@
void gl_M4_Mul(M4 *c,M4 *a,M4 *b)
{
- int i,j,k;
- float s;
+ GLint i,j,k;
+ GLfloat s;
for(i=0;i<4;i++)
for(j=0;j<4;j++) {
s=0.0;
@@ -44,11 +44,11 @@
/* c=c*a */
void gl_M4_MulLeft(M4 *c,M4 *b)
{
- int i,j,k;
- float s;
+ GLint i,j,k;
+ GLfloat s;
M4 a;
- /*memcpy(&a, c, 16*sizeof(float));
+ /*memcpy(&a, c, 16*sizeof(GLfloat));
*/
a=*c;
@@ -121,7 +121,7 @@
void gl_M4_InvOrtho(M4 *a,M4 b)
{
int i,j;
- float s;
+ GLfloat s;
for(i=0;i<3;i++)
for(j=0;j<3;j++) a->m[i][j]=b.m[j][i];
a->m[3][0]=0.0; a->m[3][1]=0.0; a->m[3][2]=0.0; a->m[3][3]=1.0;
@@ -135,10 +135,10 @@
/* Inversion of a general nxn matrix.
Note : m is destroyed */
-int Matrix_Inv(float *r,float *m,int n)
+int Matrix_Inv(GLfloat *r,GLfloat *m,int n)
{
- int i,j,k,l;
- float max,tmp,t;
+ GLint i,j,k,l;
+ GLfloat max,tmp,t;
/* identit�e dans r */
for(i=0;i<n*n;i++) r[i]=0;
@@ -155,7 +155,7 @@
max=m[i*n+j];
}
- /* non intersible matrix */
+ /* non GLintersible matrix */
if (max==0) return 1;
@@ -198,15 +198,15 @@
void gl_M4_Inv(M4 *a,M4 *b)
{
M4 tmp;
- memcpy(&tmp, b, 16*sizeof(float));
+ memcpy(&tmp, b, 16*sizeof(GLfloat));
/*tmp=*b;*/
Matrix_Inv(&a->m[0][0],&tmp.m[0][0],4);
}
-void gl_M4_Rotate(M4 *a,float t,int u)
+void gl_M4_Rotate(M4 *a,GLfloat t,int u)
{
- float s,c;
- int v,w;
+ GLfloat s,c;
+ GLint v,w;
if ((v=u+1)>2) v=0;
if ((w=v+1)>2) w=0;
s=sin(t);
@@ -220,7 +220,7 @@
/* inverse of a 3x3 matrix */
void gl_M3_Inv(M3 *a,M3 *m)
{
- float det;
+ GLfloat det;
det = m->m[0][0]*m->m[1][1]*m->m[2][2]-m->m[0][0]*m->m[1][2]*m->m[2][1]-
m->m[1][0]*m->m[0][1]*m->m[2][2]+m->m[1][0]*m->m[0][2]*m->m[2][1]+
@@ -244,7 +244,7 @@
int gl_V3_Norm(V3 *a)
{
- float n;
+ GLfloat n;
n=sqrt(a->X*a->X+a->Y*a->Y+a->Z*a->Z);
if (n==0) return 1;
a->X/=n;
@@ -253,7 +253,7 @@
return 0;
}
-V3 gl_V3_New(float x,float y,float z)
+V3 gl_V3_New(GLfloat x,GLfloat y,GLfloat z)
{
V3 a;
a.X=x;
@@ -262,7 +262,7 @@
return a;
}
-V4 gl_V4_New(float x,float y,float z,float w)
+V4 gl_V4_New(GLfloat x,GLfloat y,GLfloat z,GLfloat w)
{
V4 a;
a.X=x;
--- a/src/zmath.h
+++ b/src/zmath.h
@@ -1,18 +1,18 @@
#ifndef __ZMATH__
#define __ZMATH__
-
+#include "../include/GL/gl.h"
/* Matrix & Vertex */
typedef struct {
- float m[4][4];
+ GLfloat m[4][4];
} M4;
typedef struct {
- float m[3][3];
+ GLfloat m[3][3];
} M3;
typedef struct {
- float m[3][4];
+ GLfloat m[3][4];
} M34;
@@ -22,11 +22,11 @@
#define W v[3]
typedef struct {
- float v[3];
+ GLfloat v[3];
} V3;
typedef struct {
- float v[4];
+ GLfloat v[4];
} V4;
void gl_M4_Id(M4 *a);
@@ -42,13 +42,13 @@
void gl_M4_Mul(M4 *c,M4 *a,M4 *b);
void gl_M4_MulLeft(M4 *c,M4 *a);
void gl_M4_Transpose(M4 *a,M4 *b);
-void gl_M4_Rotate(M4 *c,float t,int u);
+void gl_M4_Rotate(M4 *c,GLfloat t,int u);
int gl_V3_Norm(V3 *a);
-V3 gl_V3_New(float x,float y,float z);
-V4 gl_V4_New(float x,float y,float z,float w);
+V3 gl_V3_New(GLfloat x,GLfloat y,GLfloat z);
+V4 gl_V4_New(GLfloat x,GLfloat y,GLfloat z,GLfloat w);
-int gl_Matrix_Inv(float *r,float *m,int n);
+int gl_Matrix_Inv(GLfloat *r,GLfloat *m,int n);
#endif
// __ZMATH__
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -9,11 +9,11 @@
GLTEXTSIZE textsize = 1;
void glTextSize(GLTEXTSIZE mode){textsize = mode;}//Set text size
-void renderchar(char *bitmap, int _x, int _y, GLuint p) {
- int x,y;
- int set;
+void renderGLbyte(GLbyte *bitmap, GLint _x, GLint _y, GLuint p) {
+ GLint x,y;
+ GLint set;
//int mask;
- int mult = textsize;
+ GLint mult = textsize;
for (x=0; x < 8; x++) {
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
@@ -26,7 +26,7 @@
}
-void glPlotPixel(int x, int y, GLuint p){
+void glPlotPixel(int x, GLint y, GLuint p){
// int x = p[1].i;
// int y = p[2].i;
// GLuint p = p[3].ui;
@@ -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, GLuint p){
+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;
@@ -51,7 +51,7 @@
for(int i = 0; text[i] != '\0' && y+7 < h; i++){
if(text[i] != '\n' && text[i] < 127 && xoff+x < w)
{
- renderchar(font8x8_basic[text[i]],x+xoff,y+yoff, p);
+ renderGLbyte(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
@@ -156,7 +156,7 @@
register unsigned short *pz; \
register PIXEL *pp; \
register GLuint tmp,z,zz,rgb,drgbdx; \
- register int n; \
+ register GLint n; \
n=(x2 >> 16) - x1; \
pp=pp1+x1; \
pz=pz1+x1; \
@@ -236,7 +236,7 @@
ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
{
PIXEL *texture;
- float fdzdx,fndzdx,ndszdx,ndtzdx;
+ GLfloat fdzdx,fndzdx,ndszdx,ndtzdx;
#define INTERP_Z
#define INTERP_STZ
@@ -246,7 +246,7 @@
#define DRAW_INIT() \
{ \
texture=zb->current_texture;\
- fdzdx=(float)dzdx;\
+ fdzdx=(GLfloat)dzdx;\
fndzdx=NB_INTERP * fdzdx;\
ndszdx=NB_INTERP * dszdx;\
ndtzdx=NB_INTERP * dtzdx;\
@@ -257,7 +257,7 @@
{ \
zz=z >> ZB_POINT_Z_FRAC_BITS; \
if (ZCMP(zz,pz[_a],_a)) { \
- pp[_a]=*(PIXEL *)((char *)texture+ \
+ pp[_a]=*(PIXEL *)((GLbyte *)texture+ \
(((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH)));\
pz[_a]=zz; \
} \
@@ -273,12 +273,12 @@
register unsigned short *pz; \
register PIXEL *pp; \
register GLuint s,t,z,zz; \
- register int n,dsdx,dtdx; \
- float sz,tz,fz,zinv; \
+ register GLint n,dsdx,dtdx; \
+ GLfloat sz,tz,fz,zinv; \
n=(x2>>16)-x1; \
- fz=(float)z1;\
+ fz=(GLfloat)z1;\
zinv=1.0 / fz;\
- pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
+ pp=(PIXEL *)((GLbyte *)pp1 + x1 * PSZB); \
pz=pz1+x1; \
z=z1; \
sz=sz1;\
@@ -285,7 +285,7 @@
tz=tz1;\
while (n>=(NB_INTERP-1)) { \
{\
- float ss,tt;\
+ GLfloat ss,tt;\
ss=(sz * zinv);\
tt=(tz * zinv);\
s=(int) ss;\
@@ -304,13 +304,13 @@
PUT_PIXEL(6);/*the_x++;*/ \
PUT_PIXEL(7);/*the_x-=7;*/ \
pz+=NB_INTERP; \
- pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);/*the_x+=NB_INTERP * PSZB;*/\
+ pp=(PIXEL *)((GLbyte *)pp + NB_INTERP * PSZB);/*the_x+=NB_INTERP * PSZB;*/\
n-=NB_INTERP; \
sz+=ndszdx;\
tz+=ndtzdx;\
} \
{\
- float ss,tt;\
+ GLfloat ss,tt;\
ss=(sz * zinv);\
tt=(tz * zinv);\
s=(int) ss;\
@@ -321,7 +321,7 @@
while (n>=0) { \
PUT_PIXEL(0);/*the_x += PSZB;*/ \
pz+=1; \
- pp=(PIXEL *)((char *)pp + PSZB);\
+ pp=(PIXEL *)((GLbyte *)pp + PSZB);\
n-=1; \
} \
}
@@ -365,11 +365,11 @@
#define PUT_PIXEL(_a) \
{ \
- float zinv; \
- int s,t; \
+ GLfloat zinv; \
+ GLint s,t; \
zz=z >> ZB_POINT_Z_FRAC_BITS; \
if (ZCMP(zz,pz[_a],_a)) { \
- zinv= 1.0 / (float) z; \
+ zinv= 1.0 / (GLfloat) z; \
s= (int) (sz * zinv); \
t= (int) (tz * zinv); \
pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; \
--- a/src/ztriangle.h
+++ b/src/ztriangle.h
@@ -1,38 +1,38 @@
/*
- * We draw a triangle with various interpolations
+ * We draw a triangle with various GLinterpolations
*/
{
ZBufferPoint *t,*pr1,*pr2,*l1,*l2;
- float fdx1, fdx2, fdy1, fdy2, fz, d1, d2;
+ GLfloat fdx1, fdx2, fdy1, fdy2, fz, d1, d2;
unsigned short *pz1;
PIXEL *pp1;
- int part,update_left,update_right;
+ GLint part,update_left,update_right;
- int nb_lines,dx1,dy1,tmp,dx2,dy2;
+ GLint nb_lines,dx1,dy1,tmp,dx2,dy2;
#if TGL_FEATURE_POLYGON_STIPPLE
unsigned short the_y;
#endif
- int error,derror;
- int x1,dxdy_min,dxdy_max;
+ GLint error,derror;
+ GLint x1,dxdy_min,dxdy_max;
/* warning: x2 is multiplied by 2^16 */
- int x2,dx2dy2;
+ GLint x2,dx2dy2;
#ifdef INTERP_Z
- int z1,dzdx,dzdy,dzdl_min,dzdl_max;
+ GLint z1,dzdx,dzdy,dzdl_min,dzdl_max;
#endif
#ifdef INTERP_RGB
- int r1,drdx,drdy,drdl_min,drdl_max;
- int g1,dgdx,dgdy,dgdl_min,dgdl_max;
- int b1,dbdx,dbdy,dbdl_min,dbdl_max;
+ GLint r1,drdx,drdy,drdl_min,drdl_max;
+ GLint g1,dgdx,dgdy,dgdl_min,dgdl_max;
+ GLint b1,dbdx,dbdy,dbdl_min,dbdl_max;
#endif
#ifdef INTERP_ST
- int s1,dsdx,dsdy,dsdl_min,dsdl_max;
- int t1,dtdx,dtdy,dtdl_min,dtdl_max;
+ GLint s1,dsdx,dsdy,dsdl_min,dsdl_max;
+ GLint t1,dtdx,dtdy,dtdl_min,dtdl_max;
#endif
#ifdef INTERP_STZ
- float sz1,dszdx,dszdy,dszdl_min,dszdl_max;
- float tz1,dtzdx,dtzdy,dtzdl_min,dtzdl_max;
+ GLfloat sz1,dszdx,dszdy,dszdl_min,dszdl_max;
+ GLfloat tz1,dtzdx,dtzdy,dtzdl_min,dtzdl_max;
#endif
/* we sort the vertex with increasing y */
@@ -52,7 +52,7 @@
p2 = t;
}
- /* we compute dXdx and dXdy for all interpolated values */
+ /* we compute dXdx and dXdy for all GLinterpolated values */
fdx1 = p1->x - p0->x;
fdy1 = p1->y - p0->y;
@@ -109,16 +109,16 @@
#ifdef INTERP_STZ
{
- float zz;
- zz=(float) p0->z;
- p0->sz= (float) p0->s * zz;
- p0->tz= (float) p0->t * zz;
- zz=(float) p1->z;
- p1->sz= (float) p1->s * zz;
- p1->tz= (float) p1->t * zz;
- zz=(float) p2->z;
- p2->sz= (float) p2->s * zz;
- p2->tz= (float) p2->t * zz;
+ GLfloat zz;
+ zz=(GLfloat) p0->z;
+ p0->sz= (GLfloat) p0->s * zz;
+ p0->tz= (GLfloat) p0->t * zz;
+ zz=(GLfloat) p1->z;
+ p1->sz= (GLfloat) p1->s * zz;
+ p1->tz= (GLfloat) p1->t * zz;
+ zz=(GLfloat) p2->z;
+ p2->sz= (GLfloat) p2->s * zz;
+ p2->tz= (GLfloat) p2->t * zz;
d1 = p1->sz - p0->sz;
d2 = p2->sz - p0->sz;
@@ -134,7 +134,7 @@
/* screen coordinates */
- pp1 = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p0->y);
+ pp1 = (PIXEL *) ((GLbyte *) zb->pbuf + zb->linesize * p0->y);
#if TGL_FEATURE_POLYGON_STIPPLE
the_y = p0->y;
#endif
@@ -249,7 +249,7 @@
/* generic draw line */
{
register PIXEL *pp;
- register int n;
+ register GLint n;
#ifdef INTERP_Z
register unsigned short *pz;
register GLuint z,zz;
@@ -261,12 +261,12 @@
register GLuint s,t;
#endif
#ifdef INTERP_STZ
- float sz,tz;
+ GLfloat sz,tz;
#endif
n=(x2 >> 16) - x1;
/*the_x = x1; //Gek added this to make determining the X coordinate easier!*/
- pp=(PIXEL *)((char *)pp1 + x1 * PSZB);
+ pp=(PIXEL *)((GLbyte *)pp1 + x1 * PSZB);
#ifdef INTERP_Z
pz=pz1+x1;
z=z1;
@@ -292,7 +292,7 @@
#ifdef INTERP_Z
pz+=4;
#endif
- pp=(PIXEL *)((char *)pp + 4 * PSZB);
+ pp=(PIXEL *)((GLbyte *)pp + 4 * PSZB);
n-=4;
}
while (n>=0) {
@@ -300,7 +300,7 @@
#ifdef INTERP_Z
pz+=1;
#endif
- pp=(PIXEL *)((char *)pp + PSZB);
+ pp=(PIXEL *)((GLbyte *)pp + PSZB);
n-=1;
}
}
@@ -354,7 +354,7 @@
x2+=dx2dy2;
/* screen coordinates */
- pp1=(PIXEL *)((char *)pp1 + zb->linesize);
+ pp1=(PIXEL *)((GLbyte *)pp1 + zb->linesize);
#if TGL_FEATURE_POLYGON_STIPPLE
the_y++;
#endif