From ae1696bbf36ec59e352474ddb07290f7bb022159 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Tue, 29 Jul 2008 19:28:19 +0000 Subject: [PATCH] formating code --- engine/tinygl/api.cpp | 5 +- engine/tinygl/arrays.cpp | 12 +- engine/tinygl/clear.cpp | 3 +- engine/tinygl/clip.cpp | 8 +- engine/tinygl/get.cpp | 121 ++++++----- engine/tinygl/gl.h | 26 +-- engine/tinygl/light.cpp | 2 +- engine/tinygl/list.cpp | 6 +- engine/tinygl/misc.cpp | 13 +- engine/tinygl/msghandling.cpp | 23 +- engine/tinygl/specbuf.cpp | 5 +- engine/tinygl/texture.cpp | 227 ++++++++++---------- engine/tinygl/vertex.cpp | 24 +-- engine/tinygl/zbuffer.cpp | 5 +- engine/tinygl/zbuffer.h | 1 - engine/tinygl/zgl.h | 389 ++++++++++++++++------------------ engine/tinygl/zline.cpp | 3 +- engine/tinygl/zmath.h | 2 +- engine/tinygl/ztriangle.cpp | 12 +- 19 files changed, 413 insertions(+), 474 deletions(-) diff --git a/engine/tinygl/api.cpp b/engine/tinygl/api.cpp index d73166c8155..1c0a2c27139 100644 --- a/engine/tinygl/api.cpp +++ b/engine/tinygl/api.cpp @@ -1,8 +1,6 @@ #include "engine/tinygl/zgl.h" -#include - // glVertex void tglVertex4f(float x, float y, float z, float w) { @@ -312,8 +310,7 @@ void tglViewport(int x, int y, int width, int height) { gl_add_op(p); } -void tglFrustum(double left, double right, double bottom, double top, - double nearv, double farv) { +void tglFrustum(double left, double right, double bottom, double top, double nearv, double farv) { TGLParam p[7]; p[0].op = OP_Frustum; diff --git a/engine/tinygl/arrays.cpp b/engine/tinygl/arrays.cpp index 2aef7675e27..401bc0413bd 100644 --- a/engine/tinygl/arrays.cpp +++ b/engine/tinygl/arrays.cpp @@ -1,9 +1,6 @@ #include "engine/tinygl/zgl.h" -#include -#include - #define VERTEX_ARRAY 0x0001 #define COLOR_ARRAY 0x0002 #define NORMAL_ARRAY 0x0004 @@ -120,8 +117,7 @@ void glopVertexPointer(GLContext *c, TGLParam *p) { c->vertex_array = (float *)p[3].p; } -void glVertexPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer) { +void glVertexPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) { TGLParam p[4]; assert(type == TGL_FLOAT); p[0].op = OP_VertexPointer; @@ -137,8 +133,7 @@ void glopColorPointer(GLContext *c, TGLParam *p) { c->color_array = (float *)p[3].p; } -void glColorPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer) { +void glColorPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) { TGLParam p[4]; assert(type == TGL_FLOAT); p[0].op = OP_ColorPointer; @@ -167,8 +162,7 @@ void glopTexCoordPointer(GLContext *c, TGLParam *p) { c->texcoord_array = (float *)p[3].p; } -void glTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer) { +void glTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer) { TGLParam p[4]; assert(type == TGL_FLOAT); p[0].op = OP_TexCoordPointer; diff --git a/engine/tinygl/clear.cpp b/engine/tinygl/clear.cpp index 5c085e040ae..3f151b318f4 100644 --- a/engine/tinygl/clear.cpp +++ b/engine/tinygl/clear.cpp @@ -20,6 +20,5 @@ void glopClear(GLContext *c,TGLParam *p) { int b = (int)(c->clear_color.v[2] * 65535); // TODO : correct value of Z - ZB_clear(c->zb,mask & TGL_DEPTH_BUFFER_BIT, z, - mask & TGL_COLOR_BUFFER_BIT, r, g, b); + ZB_clear(c->zb,mask & TGL_DEPTH_BUFFER_BIT, z, mask & TGL_COLOR_BUFFER_BIT, r, g, b); } diff --git a/engine/tinygl/clip.cpp b/engine/tinygl/clip.cpp index 6c9bbae8cc9..be7a754d88d 100644 --- a/engine/tinygl/clip.cpp +++ b/engine/tinygl/clip.cpp @@ -2,7 +2,7 @@ #include "engine/tinygl/zgl.h" // fill triangle profile -// #define PROFILE +// #define TINYGL_PROFILE #define CLIP_XMIN (1 << 0) #define CLIP_XMAX (1 << 1) @@ -366,12 +366,12 @@ void gl_draw_triangle_select(GLContext *c, GLVertex *p0, GLVertex *p1,GLVertex * gl_add_select1(c, p0->zp.z, p1->zp.z, p2->zp.z); } -#ifdef PROFILE +#ifdef TINYGL_PROFILE int count_triangles, count_triangles_textured, count_pixels; #endif void gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2) { -#ifdef PROFILE +#ifdef TINYGL_PROFILE { int norm; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize); @@ -395,7 +395,7 @@ void gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p assert(c->zb->shadow_mask_buf); ZB_fillTriangleFlatShadow(c->zb, &p0->zp, &p1->zp, &p2->zp); } else if (c->texture_2d_enabled) { -#ifdef PROFILE +#ifdef TINYGL_PROFILE count_triangles_textured++; #endif ZB_setTexture(c->zb, (PIXEL *)c->current_texture->images[0].pixmap); diff --git a/engine/tinygl/get.cpp b/engine/tinygl/get.cpp index 6e9a2dedfc4..3e468bf9698 100644 --- a/engine/tinygl/get.cpp +++ b/engine/tinygl/get.cpp @@ -4,69 +4,68 @@ void glGetIntegerv(int pname,int *params) { GLContext *c=gl_get_context(); - switch(pname) { + switch (pname) { case TGL_VIEWPORT: - params[0]=c->viewport.xmin; - params[1]=c->viewport.ymin; - params[2]=c->viewport.xsize; - params[3]=c->viewport.ysize; + params[0] = c->viewport.xmin; + params[1] = c->viewport.ymin; + params[2] = c->viewport.xsize; + params[3] = c->viewport.ysize; break; - case TGL_MAX_MODELVIEW_STACK_DEPTH: - *params = MAX_MODELVIEW_STACK_DEPTH; - break; - case TGL_MAX_PROJECTION_STACK_DEPTH: - *params = MAX_PROJECTION_STACK_DEPTH; - break; - case TGL_MAX_LIGHTS: - *params = T_MAX_LIGHTS; - break; - case TGL_MAX_TEXTURE_SIZE: - *params = 256; /* not completely true, but... */ - break; - case TGL_MAX_TEXTURE_STACK_DEPTH: - *params = MAX_TEXTURE_STACK_DEPTH; - break; - default: - gl_fatal_error("glGet: option not implemented"); - break; - } + case TGL_MAX_MODELVIEW_STACK_DEPTH: + *params = MAX_MODELVIEW_STACK_DEPTH; + break; + case TGL_MAX_PROJECTION_STACK_DEPTH: + *params = MAX_PROJECTION_STACK_DEPTH; + break; + case TGL_MAX_LIGHTS: + *params = T_MAX_LIGHTS; + break; + case TGL_MAX_TEXTURE_SIZE: + *params = 256; // not completely true, but... + break; + case TGL_MAX_TEXTURE_STACK_DEPTH: + *params = MAX_TEXTURE_STACK_DEPTH; + break; + default: + gl_fatal_error("glGet: option not implemented"); + break; + } } -void glGetFloatv(int pname, float *v) -{ - int i; - int mnr = 0; /* just a trick to return the correct matrix */ - GLContext *c = gl_get_context(); - switch (pname) { - case TGL_TEXTURE_MATRIX: - mnr++; - case TGL_PROJECTION_MATRIX: - mnr++; - case TGL_MODELVIEW_MATRIX: - { - float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; - for (i = 0; i < 4; i++) { - *v++ = p[0]; - *v++ = p[4]; - *v++ = p[8]; - *v++ = p[12]; - p++; - } - } - break; - case TGL_LINE_WIDTH: - *v = 1.0f; - break; - case TGL_LINE_WIDTH_RANGE: - v[0] = v[1] = 1.0f; - break; - case TGL_POINT_SIZE: - *v = 1.0f; - break; - case TGL_POINT_SIZE_RANGE: - v[0] = v[1] = 1.0f; - default: - fprintf(stderr,"warning: unknown pname in glGetFloatv()\n"); - break; - } +void glGetFloatv(int pname, float *v) { + int i; + int mnr = 0; // just a trick to return the correct matrix + GLContext *c = gl_get_context(); + switch (pname) { + case TGL_TEXTURE_MATRIX: + mnr++; + case TGL_PROJECTION_MATRIX: + mnr++; + case TGL_MODELVIEW_MATRIX: + { + float *p = &c->matrix_stack_ptr[mnr]->m[0][0];; + for (i = 0; i < 4; i++) { + *v++ = p[0]; + *v++ = p[4]; + *v++ = p[8]; + *v++ = p[12]; + p++; + } + } + break; + case TGL_LINE_WIDTH: + *v = 1.0f; + break; + case TGL_LINE_WIDTH_RANGE: + v[0] = v[1] = 1.0f; + break; + case TGL_POINT_SIZE: + *v = 1.0f; + break; + case TGL_POINT_SIZE_RANGE: + v[0] = v[1] = 1.0f; + default: + fprintf(stderr, "warning: unknown pname in glGetFloatv()\n"); + break; + } } diff --git a/engine/tinygl/gl.h b/engine/tinygl/gl.h index 8dedddd79da..bcf2a5d5250 100644 --- a/engine/tinygl/gl.h +++ b/engine/tinygl/gl.h @@ -677,7 +677,7 @@ void tglCullFace(int mode); void tglPolygonMode(int face,int mode); void tglBegin(int type); -void tglEnd(void); +void tglEnd(); #define PROTO_GL1(name) \ void tgl ## name ## 1f(float); \ @@ -722,10 +722,10 @@ void tglEdgeFlag(int flag); // matrix void tglMatrixMode(int mode); void tglLoadMatrixf(const float *m); -void tglLoadIdentity(void); +void tglLoadIdentity(); void tglMultMatrixf(const float *m); -void tglPushMatrix(void); -void tglPopMatrix(void); +void tglPushMatrix(); +void tglPopMatrix(); void tglRotatef(float angle, float x, float y, float z); void tglTranslatef(float x, float y, float z); void tglScalef(float x, float y, float z); @@ -750,7 +750,7 @@ void tglClearDepth(double depth); int tglRenderMode(int mode); void tglSelectBuffer(int size, unsigned int *buf); -void tglInitNames(void); +void tglInitNames(); void tglPushName(unsigned int name); void tglPopName(void); void tglLoadName(unsigned int name); @@ -779,7 +779,7 @@ void tglLightModelfv(int pname, float *param); // misc -void tglFlush(void); +void tglFlush(); void tglHint(int target, int mode); void tglGetIntegerv(int pname, int *params); void tglGetFloatv(int pname, float *v); @@ -792,14 +792,10 @@ void tglSetShadowColor(unsigned char r, unsigned char g, unsigned char b); void tglEnableClientState(TGLenum array); void tglDisableClientState(TGLenum array); void tglArrayElement(TGLint i); -void tglVertexPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer); -void tglColorPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer); -void tglNormalPointer(TGLenum type, TGLsizei stride, - const TGLvoid *pointer); -void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, - const TGLvoid *pointer); +void tglVertexPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer); +void tglColorPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer); +void tglNormalPointer(TGLenum type, TGLsizei stride, const TGLvoid *pointer); +void tglTexCoordPointer(TGLint size, TGLenum type, TGLsizei stride, const TGLvoid *pointer); // opengl 1.2 polygon offset void tglPolygonOffset(TGLfloat factor, TGLfloat units); @@ -807,6 +803,6 @@ void tglPolygonOffset(TGLfloat factor, TGLfloat units); void tglDebug(int mode); void tglInit(void *zbuffer); -void tglClose(void); +void tglClose(); #endif diff --git a/engine/tinygl/light.cpp b/engine/tinygl/light.cpp index 169e048db86..ce1a8488b28 100644 --- a/engine/tinygl/light.cpp +++ b/engine/tinygl/light.cpp @@ -239,7 +239,7 @@ void gl_shade_vertex(GLContext *c, GLVertex *v) { // diffuse light lR += dot * l->diffuse.v[0] * m->diffuse.v[0]; lG += dot * l->diffuse.v[1] * m->diffuse.v[1]; - lB+= dot * l->diffuse.v[2] * m->diffuse.v[2]; + lB += dot * l->diffuse.v[2] * m->diffuse.v[2]; // spot light if (l->spot_cutoff != 180) { diff --git a/engine/tinygl/list.cpp b/engine/tinygl/list.cpp index 0dd5125366b..45743add448 100644 --- a/engine/tinygl/list.cpp +++ b/engine/tinygl/list.cpp @@ -154,7 +154,7 @@ void glopCallList(GLContext *c, TGLParam *p) { list = p[1].ui; l = find_list(c, list); - if (l == NULL) + if (!l) gl_fatal_error("list %d not defined", list); p = l->first_op_buffer->ops; @@ -179,7 +179,7 @@ void glNewList(unsigned int list, int mode) { assert(c->compile_flag == 0); l = find_list(c, list); - if (l != NULL) + if (l) delete_list(c, list); l = alloc_list(c, list); @@ -219,7 +219,7 @@ unsigned int glGenLists(int range) { lists = c->shared_state.lists; count = 0; for (i = 0; i < MAX_DISPLAY_LISTS; i++) { - if (lists[i] == NULL) { + if (!lists[i]) { count++; if (count == range) { list = i - range + 1; diff --git a/engine/tinygl/misc.cpp b/engine/tinygl/misc.cpp index 695518cf6d6..5c3bb2790b6 100644 --- a/engine/tinygl/misc.cpp +++ b/engine/tinygl/misc.cpp @@ -12,16 +12,13 @@ void glopViewport(GLContext *c, TGLParam *p) { // we may need to resize the zbuffer - if (c->viewport.xmin != xmin || - c->viewport.ymin != ymin || - c->viewport.xsize != xsize || - c->viewport.ysize != ysize) { + if (c->viewport.xmin != xmin || c->viewport.ymin != ymin || + c->viewport.xsize != xsize || c->viewport.ysize != ysize) { xsize_req = xmin + xsize; ysize_req = ymin + ysize; - if (c->gl_resize_viewport && - c->gl_resize_viewport(c, &xsize_req, &ysize_req) != 0) { + if (c->gl_resize_viewport && c->gl_resize_viewport(c, &xsize_req, &ysize_req) != 0) { gl_fatal_error("glViewport: error while resizing display"); } @@ -95,8 +92,8 @@ void glopEnableDisable(GLContext *c, TGLParam *p) { c->shadow_mode &= ~2; break; default: - if (code>=TGL_LIGHT0 && code= TGL_LIGHT0 && code < TGL_LIGHT0 + T_MAX_LIGHTS) { + gl_enable_disable_light(c, code - TGL_LIGHT0, v); } else { //fprintf(stderr, "glEnableDisable: 0x%X not supported.\n", code); } diff --git a/engine/tinygl/msghandling.cpp b/engine/tinygl/msghandling.cpp index 955d0820758..20fce2640c9 100644 --- a/engine/tinygl/msghandling.cpp +++ b/engine/tinygl/msghandling.cpp @@ -1,19 +1,15 @@ -#include -#include -#ifndef NDEBUG -#define NDEBUG -#endif +#include "engine/tinygl/zgl.h" -#ifdef NDEBUG -#define NO_DEBUG_OUTPUT +#ifndef TINYGL_DEBUG +//#define TINYGL_DEBUG #endif // 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 // by asserts. -#ifndef NO_DEBUG_OUTPUT +#ifndef TINYGL_DEBUG void tgl_warning(const char *, ...) { } #else void tgl_warning(const char *format, ...) { @@ -23,10 +19,10 @@ void tgl_warning(const char *format, ...) { vfprintf(stderr, format, args); va_end(args); } -#endif // !NO_DEBUG_OUTPUT +#endif // This function should be used for debug output only. -#ifndef NO_DEBUG_OUTPUT +#ifndef TINYGL_DEBUG void tgl_trace(const char *, ...) { } #else void tgl_trace(const char *format, ...) { @@ -36,12 +32,12 @@ void tgl_trace(const char *format, ...) { vfprintf(stderr, format, args); va_end(args); } -#endif // !NO_DEBUG_OUTPUT +#endif // Use this function to output info about things in the code which // should be fixed (missing handling of special cases, important // features not implemented, known bugs/buglets, ...). -#ifndef NO_DEBUG_OUTPUT +#ifndef TINYGL_DEBUG void tgl_fixme(const char *, ...) { } #else void tgl_fixme(const char *format, ...) { @@ -51,4 +47,5 @@ void tgl_fixme(const char *format, ...) { vfprintf(stderr, format, args); va_end(args); } -#endif // !NO_DEBUG_OUTPUT +#endif + diff --git a/engine/tinygl/specbuf.cpp b/engine/tinygl/specbuf.cpp index 5bf0dbda187..92d4b45feb9 100644 --- a/engine/tinygl/specbuf.cpp +++ b/engine/tinygl/specbuf.cpp @@ -2,9 +2,6 @@ #include "engine/tinygl/zgl.h" #include "engine/tinygl/msghandling.h" -#include -#include - static void calc_buf(GLSpecBuf *buf, const float shininess) { int i; float val, inc; @@ -29,7 +26,7 @@ GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float s found->last_used = c->specbuf_used_counter++; return found; } - if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { + if (!oldest || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { // create new buffer GLSpecBuf *buf = (GLSpecBuf *)gl_malloc(sizeof(GLSpecBuf)); if (!buf) diff --git a/engine/tinygl/texture.cpp b/engine/tinygl/texture.cpp index c1386cf7729..1b589048aca 100644 --- a/engine/tinygl/texture.cpp +++ b/engine/tinygl/texture.cpp @@ -21,13 +21,13 @@ static void free_texture(GLContext *c, int h) { int i; t = find_texture(c, h); - if (t->prev == NULL) { + if (!t->prev) { ht = &c->shared_state.texture_hash_table[t->handle % TEXTURE_HASH_TABLE_SIZE]; *ht = t->next; } else { t->prev->next = t->next; } - if (t->next != NULL) + if (t->next) t->next->prev = t->prev; for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { @@ -39,85 +39,77 @@ static void free_texture(GLContext *c, int h) { gl_free(t); } -GLTexture *alloc_texture(GLContext *c,int h) -{ - GLTexture *t,**ht; - - t=(GLTexture *)gl_zalloc(sizeof(GLTexture)); +GLTexture *alloc_texture(GLContext *c, int h) { + GLTexture *t, **ht; - ht=&c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE]; + t = (GLTexture *)gl_zalloc(sizeof(GLTexture)); - t->next=*ht; - t->prev=NULL; - if (t->next != NULL) t->next->prev=t; - *ht=t; + ht = &c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE]; - t->handle=h; - - return t; + t->next = *ht; + t->prev = NULL; + if (t->next) + t->next->prev = t; + *ht = t; + + t->handle = h; + + return t; } - -void glInitTextures(GLContext *c) -{ - /* textures */ - - c->texture_2d_enabled=0; - c->current_texture=find_texture(c,0); +void glInitTextures(GLContext *c) { + // textures + c->texture_2d_enabled = 0; + c->current_texture = find_texture(c, 0); } -void tglGenTextures(int n, unsigned int *textures) -{ - GLContext *c=gl_get_context(); - int max,i; - GLTexture *t; +void tglGenTextures(int n, unsigned int *textures) { + GLContext *c = gl_get_context(); + int max, i; + GLTexture *t; - max=0; - for(i=0;ishared_state.texture_hash_table[i]; - while (t!=NULL) { - if (t->handle>max) max=t->handle; - t=t->next; - } - - } - for(i=0;ishared_state.texture_hash_table[i]; + while (t) { + if (t->handle > max) + max = t->handle; + t = t->next; + } + } + for(i = 0; i < n; i++) { + textures[i] = max + i + 1; + } } +void tglDeleteTextures(int n, const unsigned int *textures) { + GLContext *c = gl_get_context(); + int i; + GLTexture *t; -void tglDeleteTextures(int n, const unsigned int *textures) -{ - GLContext *c=gl_get_context(); - int i; - GLTexture *t; - - for(i=0;icurrent_texture) { - tglBindTexture(TGL_TEXTURE_2D,0); - } - free_texture(c,textures[i]); - } - } + for (i = 0; i < n; i++) { + t = find_texture(c, textures[i]); + if (t) { + if (t == c->current_texture) { + tglBindTexture(TGL_TEXTURE_2D, 0); + } + free_texture(c, textures[i]); + } + } } +void glopBindTexture(GLContext *c, TGLParam *p) { + int target = p[1].i; + int texture = p[2].i; + GLTexture *t; -void glopBindTexture(GLContext *c,TGLParam *p) -{ - int target=p[1].i; - int texture=p[2].i; - GLTexture *t; + assert(target == TGL_TEXTURE_2D && texture >= 0); - assert(target == TGL_TEXTURE_2D && texture >= 0); - - t=find_texture(c,texture); - if (t==NULL) { - t=alloc_texture(c,texture); - } - c->current_texture=t; + t = find_texture(c, texture); + if (!t) { + t = alloc_texture(c, texture); + } + c->current_texture = t; } void glopTexImage2D(GLContext *c, TGLParam *p) { @@ -134,12 +126,11 @@ void glopTexImage2D(GLContext *c, TGLParam *p) { unsigned char *pixels1; int do_free; - if (!(target == TGL_TEXTURE_2D && level == 0 && components == 3 && - border == 0 && format == TGL_RGBA && - type == TGL_UNSIGNED_BYTE)) { + if (!(target == TGL_TEXTURE_2D && level == 0 && components == 3 && border == 0 + && format == TGL_RGBA && type == TGL_UNSIGNED_BYTE)) { gl_fatal_error("glTexImage2D: combination of parameters not handled"); } - + do_free = 0; if (width != 256 || height != 256) { pixels1 = (unsigned char *)gl_malloc(256 * 256 * 4); @@ -150,67 +141,67 @@ void glopTexImage2D(GLContext *c, TGLParam *p) { do_free = 1; width = 256; height = 256; - } else { + } else { pixels1 = (unsigned char *)pixels; - } + } - im = &c->current_texture->images[level]; - im->xsize = width; - im->ysize = height; - if (im->pixmap) - gl_free(im->pixmap); - im->pixmap = gl_malloc(width * height * 3); - if (im->pixmap) + im = &c->current_texture->images[level]; + im->xsize = width; + im->ysize = height; + if (im->pixmap) + gl_free(im->pixmap); + im->pixmap = gl_malloc(width * height * 3); + if (im->pixmap) gl_convertRGB_to_5R6G5B8A((unsigned short *)im->pixmap, pixels1, width, height); - if (do_free) + if (do_free) gl_free(pixels1); } +// TODO: not all tests are done +void glopTexEnv(GLContext *, TGLParam *p) { + int target = p[1].i; + int pname = p[2].i; + int param = p[3].i; -/* TODO: not all tests are done */ -void glopTexEnv(GLContext *,TGLParam *p) -{ - int target=p[1].i; - int pname=p[2].i; - int param=p[3].i; + if (target != TGL_TEXTURE_ENV) { +error: + gl_fatal_error("glTexParameter: unsupported option"); + } - if (target != TGL_TEXTURE_ENV) { - error: - gl_fatal_error("glTexParameter: unsupported option"); - } + if (pname != TGL_TEXTURE_ENV_MODE) + goto error; - if (pname != TGL_TEXTURE_ENV_MODE) goto error; - - if (param != TGL_DECAL) goto error; + if (param != TGL_DECAL) + goto error; } -/* TODO: not all tests are done */ -void glopTexParameter(GLContext *,TGLParam *p) -{ - int target=p[1].i; - int pname=p[2].i; - int param=p[3].i; - - if (target != TGL_TEXTURE_2D) { - error: - gl_fatal_error("glTexParameter: unsupported option"); - } +// TODO: not all tests are done +void glopTexParameter(GLContext *, TGLParam *p) { + int target = p[1].i; + int pname = p[2].i; + int param = p[3].i; - switch(pname) { - case TGL_TEXTURE_WRAP_S: - case TGL_TEXTURE_WRAP_T: - if (param != TGL_REPEAT) goto error; - break; - } + if (target != TGL_TEXTURE_2D) { +error: + gl_fatal_error("glTexParameter: unsupported option"); + } + + switch (pname) { + case TGL_TEXTURE_WRAP_S: + case TGL_TEXTURE_WRAP_T: + if (param != TGL_REPEAT) + goto error; + break; + default: + ; + } } -void glopPixelStore(GLContext *,TGLParam *p) -{ - int pname=p[1].i; - int param=p[2].i; +void glopPixelStore(GLContext *, TGLParam *p) { + int pname = p[1].i; + int param = p[2].i; - if (pname != TGL_UNPACK_ALIGNMENT || - param != 1) { - gl_fatal_error("glPixelStore: unsupported option"); - } + if (pname != TGL_UNPACK_ALIGNMENT || param != 1) { + gl_fatal_error("glPixelStore: unsupported option"); + } } diff --git a/engine/tinygl/vertex.cpp b/engine/tinygl/vertex.cpp index 7b9018fa6de..98eb5d72709 100644 --- a/engine/tinygl/vertex.cpp +++ b/engine/tinygl/vertex.cpp @@ -155,14 +155,10 @@ static inline void gl_vertex_transform(GLContext *c, GLVertex *v) { // projection coordinates m = &c->matrix_stack_ptr[1]->m[0][0]; - v->pc.X = (v->ec.X * m[0] + v->ec.Y * m[1] + - v->ec.Z * m[2] + v->ec.W * m[3]); - v->pc.Y = (v->ec.X * m[4] + v->ec.Y * m[5] + - v->ec.Z * m[6] + v->ec.W * m[7]); - v->pc.Z = (v->ec.X * m[8] + v->ec.Y * m[9] + - v->ec.Z * m[10] + v->ec.W * m[11]); - v->pc.W = (v->ec.X * m[12] + v->ec.Y * m[13] + - v->ec.Z * m[14] + v->ec.W * m[15]); + v->pc.X = (v->ec.X * m[0] + v->ec.Y * m[1] + v->ec.Z * m[2] + v->ec.W * m[3]); + v->pc.Y = (v->ec.X * m[4] + v->ec.Y * m[5] + v->ec.Z * m[6] + v->ec.W * m[7]); + v->pc.Z = (v->ec.X * m[8] + v->ec.Y * m[9] + v->ec.Z * m[10] + v->ec.W * m[11]); + v->pc.W = (v->ec.X * m[12] + v->ec.Y * m[13] + v->ec.Z * m[14] + v->ec.W * m[15]); m = &c->matrix_model_view_inv.m[0][0]; n = &c->current_normal; @@ -179,17 +175,13 @@ static inline void gl_vertex_transform(GLContext *c, GLVertex *v) { // NOTE: W = 1 is assumed m = &c->matrix_model_projection.m[0][0]; - v->pc.X = (v->coord.X * m[0] + v->coord.Y * m[1] + - v->coord.Z * m[2] + m[3]); - v->pc.Y = (v->coord.X * m[4] + v->coord.Y * m[5] + - v->coord.Z * m[6] + m[7]); - v->pc.Z = (v->coord.X * m[8] + v->coord.Y * m[9] + - v->coord.Z * m[10] + m[11]); + v->pc.X = (v->coord.X * m[0] + v->coord.Y * m[1] + v->coord.Z * m[2] + m[3]); + v->pc.Y = (v->coord.X * m[4] + v->coord.Y * m[5] + v->coord.Z * m[6] + m[7]); + v->pc.Z = (v->coord.X * m[8] + v->coord.Y * m[9] + v->coord.Z * m[10] + m[11]); if (c->matrix_model_projection_no_w_transform) { v->pc.W = m[15]; } else { - v->pc.W = (v->coord.X * m[12] + v->coord.Y * m[13] + - v->coord.Z * m[14] + m[15]); + v->pc.W = (v->coord.X * m[12] + v->coord.Y * m[13] + v->coord.Z * m[14] + m[15]); } } diff --git a/engine/tinygl/zbuffer.cpp b/engine/tinygl/zbuffer.cpp index 9f5f8bb8c5a..acd780412b6 100644 --- a/engine/tinygl/zbuffer.cpp +++ b/engine/tinygl/zbuffer.cpp @@ -13,7 +13,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, void *frame_buffer) { int size; zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer)); - if (zb == NULL) + if (!zb) return NULL; zb->xsize = xsize; @@ -173,8 +173,7 @@ void memset_l(void *adr, int val, int count) { *p++ = val; } -void ZB_clear(ZBuffer *zb, int clear_z, int z, - int clear_color, int r, int g, int b) { +void ZB_clear(ZBuffer *zb, int clear_z, int z, int clear_color, int r, int g, int b) { int color; int y; PIXEL *pp; diff --git a/engine/tinygl/zbuffer.h b/engine/tinygl/zbuffer.h index 8b1ad9750e0..c02edd2b762 100644 --- a/engine/tinygl/zbuffer.h +++ b/engine/tinygl/zbuffer.h @@ -63,7 +63,6 @@ void ZB_resize(ZBuffer *zb, void *frame_buffer, int xsize, int ysize); void ZB_clear(ZBuffer *zb, int clear_z, int z, int clear_color, int r, int g, int b); // linesize is in BYTES void ZB_copyFrameBuffer(ZBuffer *zb, void *buf, int linesize); -//void ZB_setShadowMaskBuf( // zline.c diff --git a/engine/tinygl/zgl.h b/engine/tinygl/zgl.h index b92b81a4b0b..4aea74810aa 100644 --- a/engine/tinygl/zgl.h +++ b/engine/tinygl/zgl.h @@ -10,9 +10,6 @@ #include "engine/tinygl/zbuffer.h" #include "engine/tinygl/zmath.h" -#define DEBUG -/* #define NDEBUG */ - enum { #define ADD_OP(a,b,c) OP_ ## a , @@ -21,23 +18,23 @@ enum { }; -/* initially # of allocated GLVertexes (will grow when necessary) */ +// initially # of allocated GLVertexes (will grow when necessary) #define POLYGON_MAX_VERTEX 16 -/* Max # of specular light pow buffers */ +// Max # of specular light pow buffers #define MAX_SPECULAR_BUFFERS 8 -/* # of entries in specular buffer */ +// # of entries in specular buffer #define SPECULAR_BUFFER_SIZE 1024 -/* specular buffer granularity */ +// specular buffer granularity #define SPECULAR_BUFFER_RESOLUTION 1024 -#define MAX_MODELVIEW_STACK_DEPTH 35 -#define MAX_PROJECTION_STACK_DEPTH 8 -#define MAX_TEXTURE_STACK_DEPTH 8 -#define MAX_NAME_STACK_DEPTH 64 -#define MAX_TEXTURE_LEVELS 11 -#define T_MAX_LIGHTS 16 +#define MAX_MODELVIEW_STACK_DEPTH 35 +#define MAX_PROJECTION_STACK_DEPTH 8 +#define MAX_TEXTURE_STACK_DEPTH 8 +#define MAX_NAME_STACK_DEPTH 64 +#define MAX_TEXTURE_LEVELS 11 +#define T_MAX_LIGHTS 16 #define VERTEX_HASH_SIZE 1031 @@ -49,275 +46,266 @@ enum { #define TGL_OFFSET_POINT 0x4 typedef struct GLSpecBuf { - int shininess_i; - int last_used; - float buf[SPECULAR_BUFFER_SIZE+1]; - struct GLSpecBuf *next; + int shininess_i; + int last_used; + float buf[SPECULAR_BUFFER_SIZE+1]; + struct GLSpecBuf *next; } GLSpecBuf; typedef struct GLLight { - V4 ambient; - V4 diffuse; - V4 specular; - V4 position; - V3 spot_direction; - float spot_exponent; - float spot_cutoff; - float attenuation[3]; - /* precomputed values */ - float cos_spot_cutoff; - V3 norm_spot_direction; - V3 norm_position; - /* we use a linked list to know which are the enabled lights */ - int enabled; - struct GLLight *next,*prev; + V4 ambient; + V4 diffuse; + V4 specular; + V4 position; + V3 spot_direction; + float spot_exponent; + float spot_cutoff; + float attenuation[3]; + // precomputed values + float cos_spot_cutoff; + V3 norm_spot_direction; + V3 norm_position; + // we use a linked list to know which are the enabled lights + int enabled; + struct GLLight *next, *prev; } GLLight; typedef struct GLMaterial { - V4 emission; - V4 ambient; - V4 diffuse; - V4 specular; - float shininess; + V4 emission; + V4 ambient; + V4 diffuse; + V4 specular; + float shininess; - /* computed values */ - int shininess_i; - int do_specular; + // computed values + int shininess_i; + int do_specular; } GLMaterial; typedef struct GLViewport { - int xmin,ymin,xsize,ysize; - V3 scale; - V3 trans; - int updated; + int xmin, ymin, xsize, ysize; + V3 scale; + V3 trans; + int updated; } GLViewport; typedef union { - int op; - float f; - int i; - unsigned int ui; - void *p; + int op; + float f; + int i; + unsigned int ui; + void *p; } TGLParam; typedef struct TGLParamBuffer { - TGLParam ops[OP_BUFFER_MAX_SIZE]; - struct TGLParamBuffer *next; + TGLParam ops[OP_BUFFER_MAX_SIZE]; + struct TGLParamBuffer *next; } TGLParamBuffer; typedef struct GLList { - TGLParamBuffer *first_op_buffer; - /* TODO: extensions for an hash table or a better allocating scheme */ + TGLParamBuffer *first_op_buffer; + // TODO: extensions for an hash table or a better allocating scheme } GLList; typedef struct GLVertex { - int edge_flag; - V3 normal; - V4 coord; - V4 tex_coord; - V4 color; - - /* 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 */ + int edge_flag; + V3 normal; + V4 coord; + V4 tex_coord; + V4 color; + + // 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 } GLVertex; typedef struct GLImage { - void *pixmap; - int xsize,ysize; + void *pixmap; + int xsize, ysize; } GLImage; -/* textures */ +// textures #define TEXTURE_HASH_TABLE_SIZE 256 typedef struct GLTexture { - GLImage images[MAX_TEXTURE_LEVELS]; - int handle; - struct GLTexture *next,*prev; + GLImage images[MAX_TEXTURE_LEVELS]; + int handle; + struct GLTexture *next, *prev; } GLTexture; -/* shared state */ +// shared state typedef struct GLSharedState { - GLList **lists; - GLTexture **texture_hash_table; + GLList **lists; + GLTexture **texture_hash_table; } GLSharedState; struct GLContext; -typedef void (*gl_draw_triangle_func)(struct GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); +typedef void (*gl_draw_triangle_func)(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); -/* display context */ +// display context typedef struct GLContext { - /* Z buffer */ - ZBuffer *zb; + // Z buffer + ZBuffer *zb; - /* lights */ - GLLight lights[T_MAX_LIGHTS]; - GLLight *first_light; - V4 ambient_light_model; - int local_light_model; - int lighting_enabled; - int light_model_two_side; + // lights + GLLight lights[T_MAX_LIGHTS]; + GLLight *first_light; + V4 ambient_light_model; + int local_light_model; + int lighting_enabled; + int light_model_two_side; - /* materials */ - GLMaterial materials[2]; - int color_material_enabled; - int current_color_material_mode; - int current_color_material_type; + // materials + GLMaterial materials[2]; + int color_material_enabled; + int current_color_material_mode; + int current_color_material_type; - /* textures */ - GLTexture *current_texture; - int texture_2d_enabled; + // textures + GLTexture *current_texture; + int texture_2d_enabled; - /* shared state */ - GLSharedState shared_state; + // shared state + GLSharedState shared_state; - /* current list */ - TGLParamBuffer *current_op_buffer; - int current_op_buffer_index; - int exec_flag,compile_flag,print_flag; + // current list + TGLParamBuffer *current_op_buffer; + int current_op_buffer_index; + int exec_flag, compile_flag, print_flag; - /* matrix */ + // matrix + int matrix_mode; + M4 *matrix_stack[3]; + M4 *matrix_stack_ptr[3]; + int matrix_stack_depth_max[3]; - int matrix_mode; - M4 *matrix_stack[3]; - M4 *matrix_stack_ptr[3]; - int 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; - 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; + // viewport + GLViewport viewport; - /* viewport */ - GLViewport viewport; + // current state + int polygon_mode_back; + int polygon_mode_front; - /* current state */ - int polygon_mode_back; - int polygon_mode_front; + int current_front_face; + int current_shade_model; + int current_cull_face; + int cull_face_enabled; + int normalize_enabled; + gl_draw_triangle_func draw_triangle_front, draw_triangle_back; - int current_front_face; - int current_shade_model; - int current_cull_face; - int cull_face_enabled; - int normalize_enabled; - gl_draw_triangle_func draw_triangle_front,draw_triangle_back; + // selection + int render_mode; + unsigned int *select_buffer; + int select_size; + unsigned int *select_ptr, *select_hit; + int select_overflow; + int select_hits; - /* selection */ - int render_mode; - unsigned int *select_buffer; - int select_size; - unsigned int *select_ptr,*select_hit; - int select_overflow; - int select_hits; + // names + unsigned int name_stack[MAX_NAME_STACK_DEPTH]; + int name_stack_size; - /* names */ - unsigned int name_stack[MAX_NAME_STACK_DEPTH]; - int name_stack_size; + // clear + float clear_depth; + V4 clear_color; - /* clear */ - float clear_depth; - V4 clear_color; + // current vertex state + V4 current_color; + unsigned int longcurrent_color[3]; // precomputed integer color + V4 current_normal; + V4 current_tex_coord; + int current_edge_flag; - /* current vertex state */ - V4 current_color; - unsigned int longcurrent_color[3]; /* precomputed integer color */ - V4 current_normal; - V4 current_tex_coord; - int current_edge_flag; + // glBegin / glEnd + int in_begin; + int begin_type; + int vertex_n, vertex_cnt; + int vertex_max; + GLVertex *vertex; - /* glBegin / glEnd */ - int in_begin; - int begin_type; - int vertex_n,vertex_cnt; - int 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; - /* 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; - - /* opengl 1.1 polygon offset */ - float offset_factor; - float offset_units; - int offset_states; + // opengl 1.1 polygon offset + float offset_factor; + float offset_units; + int offset_states; - int shadow_mode; + int shadow_mode; - /* 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; + // 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; - /* opaque structure for user's use */ - void *opaque; - /* resize viewport function */ - int (*gl_resize_viewport)(struct GLContext *c,int *xsize,int *ysize); + // opaque structure for user's use + void *opaque; + // resize viewport function + int (*gl_resize_viewport)(GLContext *c, int *xsize, int *ysize); - /* depth test */ - int depth_test; + // depth test + int depth_test; } GLContext; extern GLContext *gl_ctx; void gl_add_op(TGLParam *p); -/* clip.c */ -void gl_transform_to_viewport(GLContext *c,GLVertex *v); -void gl_draw_triangle(GLContext *c,GLVertex *p0,GLVertex *p1,GLVertex *p2); -void gl_draw_line(GLContext *c,GLVertex *p0,GLVertex *p1); -void gl_draw_point(GLContext *c,GLVertex *p0); +// clip.c +void gl_transform_to_viewport(GLContext *c, GLVertex *v); +void gl_draw_triangle(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); +void gl_draw_line(GLContext *c, GLVertex *p0, GLVertex *p1); +void gl_draw_point(GLContext *c, GLVertex *p0); -void gl_draw_triangle_point(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); -void gl_draw_triangle_line(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); -void gl_draw_triangle_fill(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); -void gl_draw_triangle_select(GLContext *c, - GLVertex *p0,GLVertex *p1,GLVertex *p2); +void gl_draw_triangle_point(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); +void gl_draw_triangle_line(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); +void gl_draw_triangle_fill(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); +void gl_draw_triangle_select(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2); -/* matrix.c */ +// matrix.c void gl_print_matrix(const float *m); -/* -void glopLoadIdentity(GLContext *c,TGLParam *p); -void glopTranslate(GLContext *c,TGLParam *p);*/ -/* light.c */ -void gl_add_select(GLContext *c,unsigned int zmin,unsigned int zmax); -void gl_enable_disable_light(GLContext *c,int light,int v); -void gl_shade_vertex(GLContext *c,GLVertex *v); +// light.c +void gl_add_select(GLContext *c, unsigned int zmin, unsigned int zmax); +void gl_enable_disable_light(GLContext *c, int light, int v); +void gl_shade_vertex(GLContext *c, GLVertex *v); void glInitTextures(GLContext *c); void glEndTextures(GLContext *c); -GLTexture *alloc_texture(GLContext *c,int h); +GLTexture *alloc_texture(GLContext *c, int h); // image_util.c void gl_convertRGB_to_5R6G5B8A(unsigned short *pixmap, unsigned char *rgba, 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); + 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); + unsigned char *src, int xsize_src, int ysize_src); GLContext *gl_get_context(void); @@ -350,8 +338,7 @@ static inline int gl_clipcode(float x, float y, float z, float w1) { float w; w = (float)(w1 * (1.0 + CLIP_EPSILON)); - return (x < -w) | ((x > w) << 1) | ((y < -w) << 2) | - ((y > w) << 3) | ((z < -w) << 4) | ((z > w) << 5); + return (x < -w) | ((x > w) << 1) | ((y < -w) << 2) | ((y > w) << 3) | ((z < -w) << 4) | ((z > w) << 5); } #endif // _tgl_zgl_h_ diff --git a/engine/tinygl/zline.cpp b/engine/tinygl/zline.cpp index a475e2268a3..0ac87a22a8c 100644 --- a/engine/tinygl/zline.cpp +++ b/engine/tinygl/zline.cpp @@ -1,4 +1,3 @@ -#include #include "engine/tinygl/zbuffer.h" @@ -14,7 +13,7 @@ void ZB_plot(ZBuffer * zb, ZBufferPoint * p) { pz_2 = zb->zbuf2 + (p->y * zb->xsize + p->x); pp = (PIXEL *)((char *) zb->pbuf + zb->linesize * p->y + p->x * PSZB); zz = p->z >> ZB_POINT_Z_FRAC_BITS; - if ((ZCMP(zz, *pz)) && (ZCMP((unsigned int)p->z, *pz_2)) ) { + if ((ZCMP(zz, *pz)) && (ZCMP((unsigned int)p->z, *pz_2))) { *pp = RGB_TO_PIXEL(p->r, p->g, p->b); *pz_2 = p->z; } diff --git a/engine/tinygl/zmath.h b/engine/tinygl/zmath.h index 69dc29d26d2..52980290bd5 100644 --- a/engine/tinygl/zmath.h +++ b/engine/tinygl/zmath.h @@ -43,7 +43,7 @@ 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); -int gl_V3_Norm(V3 *a); +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); diff --git a/engine/tinygl/ztriangle.cpp b/engine/tinygl/ztriangle.cpp index 0a9e108f85b..a945fd6bd6d 100644 --- a/engine/tinygl/ztriangle.cpp +++ b/engine/tinygl/ztriangle.cpp @@ -5,8 +5,7 @@ #define ZCMP(z, zpix) ((z) >= (zpix)) -void ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p0, - ZBufferPoint *p1, ZBufferPoint *p2) { +void ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { int color; #define INTERP_Z @@ -30,8 +29,7 @@ void ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p0, // Smooth filled triangle. // The code below is very tricky :) -void ZB_fillTriangleSmooth(ZBuffer *zb, ZBufferPoint *p0, - ZBufferPoint *p1, ZBufferPoint *p2) { +void ZB_fillTriangleSmooth(ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { int _drgbdx; #define INTERP_Z @@ -97,8 +95,7 @@ void ZB_setTexture(ZBuffer *zb, PIXEL *texture) { zb->current_texture=texture; } -void ZB_fillTriangleMapping(ZBuffer *zb, ZBufferPoint *p0, - ZBufferPoint *p1, ZBufferPoint *p2) { +void ZB_fillTriangleMapping(ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { PIXEL *texture; #define INTERP_Z @@ -122,8 +119,7 @@ void ZB_fillTriangleMapping(ZBuffer *zb, ZBufferPoint *p0, #include "engine/tinygl/ztriangle.h" } -void ZB_fillTriangleMappingPerspective(ZBuffer *zb, ZBufferPoint *p0, - ZBufferPoint *p1, ZBufferPoint *p2) { +void ZB_fillTriangleMappingPerspective(ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) { PIXEL *texture; float fdzdx, fndzdx, ndszdx, ndtzdx; int _drgbdx;