ref: de0622960ecb4ac77edb7633744e18b33835c226
parent: e4b851f42a42b7eaf2c1fb61c53fd309e417c6f8
author: David <gek@katherine>
date: Thu Mar 4 10:00:35 EST 2021
Update documentation and deps
--- a/src/arrays.c
+++ b/src/arrays.c
@@ -1,5 +1,4 @@
#include "zgl.h"
-#include <assert.h>
//#include <stdio.h>
#include "msghandling.h"
@@ -375,7 +374,6 @@
p[1].i = TEXCOORD_ARRAY;
break;
default:
- assert(0);
break;
}
gl_add_op(p);
@@ -402,7 +400,6 @@
p[1].i = ~TEXCOORD_ARRAY;
break;
default:
- assert(0);
break;
}
gl_add_op(p);
@@ -470,7 +467,7 @@
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(type == GL_FLOAT);
+
#endif
p[0].op = OP_NormalPointer;
p[1].i = stride;
@@ -493,7 +490,7 @@
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(type == GL_FLOAT);
+
#endif
p[0].op = OP_TexCoordPointer;
p[1].i = size;
--- a/src/list.c
+++ b/src/list.c
@@ -172,10 +172,10 @@
c->current_op_buffer_index = index;
}
/* this opcode is never called directly */
-void glopEndList(GLContext* c, GLParam* p) { assert(0); }
+void glopEndList(GLContext* c, GLParam* p) { exit(1); }
/* this opcode is never called directly */
-void glopNextBuffer(GLContext* c, GLParam* p) { assert(0); }
+void glopNextBuffer(GLContext* c, GLParam* p) { exit(1); }
void glopCallList(GLContext* c, GLParam* p) {
GLList* l;
--- a/src/matrix.c
+++ b/src/matrix.c
@@ -22,8 +22,8 @@
case GL_TEXTURE:
c->matrix_mode = 2;
break;
- default:
- assert(0);
+ default:break;
+ //assert(0);
}
}
@@ -78,7 +78,8 @@
GLint n = c->matrix_mode;
M4* m;
- assert((c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1) < c->matrix_stack_depth_max[n]);
+ //TODO add error check.
+ //assert((c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1) < c->matrix_stack_depth_max[n]);
m = ++c->matrix_stack_ptr[n];
@@ -90,7 +91,7 @@
void glopPopMatrix(GLContext* c, GLParam* p) {
GLint n = c->matrix_mode;
- assert(c->matrix_stack_ptr[n] > c->matrix_stack[n]);
+ //assert(c->matrix_stack_ptr[n] > c->matrix_stack[n]);
c->matrix_stack_ptr[n]--;
gl_matrix_update(c);
}
--- a/src/misc.c
+++ b/src/misc.c
@@ -170,8 +170,7 @@
c->polygon_mode_front = mode;
c->polygon_mode_back = mode;
break;
- default:
- assert(0);
+ default:break;
}
}
--- a/src/select.c
+++ b/src/select.c
@@ -250,7 +250,7 @@
void glopPushName(GLContext* c, GLParam* p) {
if (c->render_mode == GL_SELECT) {
- assert(c->name_stack_size < MAX_NAME_STACK_DEPTH);
+ //assert(c->name_stack_size < MAX_NAME_STACK_DEPTH);
c->name_stack[c->name_stack_size++] = p[1].i;
c->select_hit = NULL;
}
@@ -263,7 +263,7 @@
void glopPopName(GLContext* c, GLParam* p) {
if (c->render_mode == GL_SELECT) {
- assert(c->name_stack_size > 0);
+ //assert(c->name_stack_size > 0);
c->name_stack_size--;
c->select_hit = NULL;
}
@@ -271,7 +271,7 @@
void glopLoadName(GLContext* c, GLParam* p) {
if (c->render_mode == GL_SELECT) {
- assert(c->name_stack_size > 0);
+ //assert(c->name_stack_size > 0);
c->name_stack[c->name_stack_size - 1] = p[1].i;
c->select_hit = NULL;
}
--- a/src/texture.c
+++ b/src/texture.c
@@ -47,7 +47,7 @@
#define RETVAL NULL
#include "error_check.h"
#else
- assert(text >= 0 && level < MAX_TEXTURE_LEVELS);
+ //assert(text >= 0 && level < MAX_TEXTURE_LEVELS);
#endif
tex = find_texture(c, text);
if (!tex)
@@ -166,7 +166,7 @@
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- assert(target == GL_TEXTURE_2D && target > 0);
+ //assert(target == GL_TEXTURE_2D && target > 0);
#endif
t = find_texture(c, texture);
if (t == NULL) {
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -3,7 +3,6 @@
* Z buffer: 16 bits Z / 16 bits color
*
*/
-#include <assert.h>
//#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--- a/src/zdither.c.unused
+++ /dev/null
@@ -1,154 +1,0 @@
-/*
- * Highly optimised dithering 16 bits -> 8 bits.
- * The formulas were taken in Mesa (Bob Mercier mercier@hollywood.cinenet.net).
- */
-
-#include "../include/zbuffer.h"
-#include <assert.h>
-//#include <stdio.h>
-#include <stdlib.h>
-
-#if defined(TGL_FEATURE_8_BITS)
-
-#define _R 5
-#define _G 9
-#define _B 5
-#define _DX 4
-#define _DY 4
-#define _D (_DX * _DY)
-#define _MIX(r, g, b) (((g) << 6) | ((b) << 3) | (r))
-
-#define DITHER_TABLE_SIZE (1 << 15)
-
-#define DITHER_INDEX(r, g, b) ((b) + (g)*_B + (r) * (_B * _G))
-
-#define MAXC 256
-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, 15 * MAXC, 7 * MAXC, 13 * MAXC, 5 * MAXC,
-};
-
-/* we build the color table and the lookup table */
-
-void ZB_initDither(ZBuffer* zb, GLint nb_colors, GLubyte* color_indexes, GLint* color_table) {
- GLint c, r, g, b, i, index, r1, g1, b1;
-
- if (nb_colors < (_R * _G * _B)) {
- // tgl_fixme("zdither: not enough colors\n");
- exit(1);
- }
-
- for (i = 0; i < nb_colors; i++)
- color_table[i] = 0;
-
- zb->nb_colors = nb_colors;
- zb->ctable = gl_malloc(nb_colors * sizeof(GLint));
-
- for (r = 0; r < _R; r++) {
- for (g = 0; g < _G; g++) {
- for (b = 0; b < _B; b++) {
- r1 = (r * 255) / (_R - 1);
- g1 = (g * 255) / (_G - 1);
- b1 = (b * 255) / (_B - 1);
- index = DITHER_INDEX(r, g, b);
- c = (r1 << 16) | (g1 << 8) | b1;
- zb->ctable[index] = c;
- color_table[index] = c;
- }
- }
- }
-
- zb->dctable = gl_malloc(DITHER_TABLE_SIZE);
-
- for (i = 0; i < DITHER_TABLE_SIZE; i++) {
- r = (i >> 12) & 0x7;
- g = (i >> 8) & 0xF;
- b = (i >> 3) & 0x7;
- index = DITHER_INDEX(r, g, b);
- zb->dctable[i] = color_indexes[index];
- }
-}
-
-void ZB_closeDither(ZBuffer* zb) {
- gl_free(zb->ctable);
- gl_free(zb->dctable);
-}
-
-#if 0
-int ZDither_lookupColor(GLint r,GLint g,GLint b)
-{
- GLubyte *ctable=zdither_color_table;
- return ctable[_MIX(_DITH0(_R, r), _DITH0(_G, g),_DITH0(_B, b))];
-}
-#endif
-
-#define DITHER_PIXEL2(a) \
- { \
- register GLint v, t, r, g, c; \
- v = *(GLuint*)(pp + (a)); \
- g = (v & 0x07DF07DF) + g_d; \
- r = (((v & 0xF800F800) >> 2) + r_d) & 0x70007000; \
- t = r | g; \
- c = ctable[t & 0xFFFF] | (ctable[t >> 16] << 8); \
- *(GLushort*)(dest + (a)) = c; \
- }
-
-/* NOTE: all the memory access are 16 bit aligned, so if buf or
- linesize are not multiple of 2, it cannot work efficiently (or
- hang!) */
-
-void ZB_ditherFrameBuffer(ZBuffer* zb, GLubyte* buf, GLint linesize) {
- GLint xk, yk, x, y, c1, c2;
- GLubyte* dest1;
- GLushort* pp1;
- GLint r_d, g_d, b_d;
- GLubyte* ctable = zb->dctable;
- register GLubyte* dest;
- register GLushort* pp;
-
- assert(((long)buf & 1) == 0 && (linesize & 1) == 0);
-
- for (yk = 0; yk < 4; yk++) {
- for (xk = 0; xk < 4; xk += 2) {
-#if BYTE_ORDER == BIG_ENDIAN
- c1 = kernel8[yk * 4 + xk + 1];
- c2 = kernel8[yk * 4 + xk];
-#else
- c1 = kernel8[yk * 4 + xk];
- c2 = kernel8[yk * 4 + xk + 1];
-#endif
- r_d = ((c1 << 2) & 0xF800) >> 2;
- g_d = (c1 >> 4) & 0x07C0;
- b_d = (c1 >> 9) & 0x001F;
-
- r_d |= (((c2 << 2) & 0xF800) >> 2) << 16;
- g_d |= ((c2 >> 4) & 0x07C0) << 16;
- b_d |= ((c2 >> 9) & 0x001F) << 16;
- g_d = b_d | g_d;
-
- dest1 = buf + (yk * linesize) + xk;
- // NOTE BY GEK: The following line was modified to fix a compiler warning,
- // casting zb->pbuf to GLushort*
- pp1 = (GLushort*)(zb->pbuf) + (yk * zb->xsize) + xk;
-
- for (y = yk; y < zb->ysize; y += 4) {
- dest = dest1;
- pp = pp1;
- for (x = xk; x < zb->xsize; x += 16) {
-
- DITHER_PIXEL2(0);
- DITHER_PIXEL2(1 * 4);
- DITHER_PIXEL2(2 * 4);
- DITHER_PIXEL2(3 * 4);
-
- pp += 16;
- dest += 16;
- }
- dest1 += linesize * 4;
- pp1 += zb->xsize * 4;
- }
- }
- }
-}
-
-#endif
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -4,7 +4,6 @@
#include "../include/zfeatures.h"
#include "../include/zbuffer.h"
#include "zmath.h"
-#include <assert.h>
#include <math.h>
#include <stdlib.h>
//Needed for memcpy
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -2,7 +2,7 @@
#include "../include/zbuffer.h"
#include "font8x8_basic.h"
#include "zgl.h"
-#include <assert.h>
+
//#include <stdio.h>
#include <stdlib.h>
//#include <string.h>