ref: c4285492260419bcb6cebf8c211743b3bc60523a
parent: b7e50c61fac413c2e9c4d2dec9df7a8f2e0858b3
author: MHS <gek@katherine>
date: Mon Apr 12 16:50:50 EDT 2021
Automatic commit.
--- a/README.md
+++ b/README.md
@@ -2,8 +2,10 @@
![tgl logo](tgl_minimal.png)
+(Maintainer's note: tinygl is now C89 compliant. Demo code and bonus libraries remain only c99 compliant.)
-A major overhaul of Fabrice Bellard's TinyGL (still compiling with -std=c99) to be
+
+A major overhaul of Fabrice Bellard's TinyGL (Now compiling with -std=c89!) to be
more useful as a software rasterizer.
Now with limited multithreading support
@@ -451,11 +453,9 @@
This changes too often to maintain documentation here.
-To disable or enable the compiletime tests, see include/GL/gl.h
+The compiletime test is now disabled by default since it may not be "liked" by some obscure compilers...
+you can enable it in GL/gl.h
-You may need to disable it if you want to compile the library
-even though you failed the compatibility test.
-
```c
//at the top of include/GL/gl.h
//Enable TinyGL's Compiletime Compatibility Test (Scroll down)
@@ -507,93 +507,8 @@
## ALSO COMPATIBLE WITH 16 BIT
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-## BENCHMARK RESULTS (Old- the library is faster now)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-### CPU: i7-6700 (Gek)
-### OS: Linux Mint Debian Edition
+Todo: add updated benchmarks
-at the default settings, 32 bit,
-```c
-#define TGL_FEATURE_ARRAYS 1
-#define TGL_FEATURE_DISPLAYLISTS 1
-#define TGL_FEATURE_LIT_TEXTURES 1
-//NOTE: Polygon Offset does nothing at the moment.
-#define TGL_FEATURE_POLYGON_OFFSET 0
-#define TGL_FEATURE_POLYGON_STIPPLE 0
-//A stipple pattern is 128 bytes in size.
-#define TGL_POLYGON_STIPPLE_BYTES 128
-//A stipple pattern is 2^5 (32) bits wide.
-#define TGL_POLYGON_STIPPLE_POW2_WIDTH 5
-//The stipple pattern mask (the last bits of the screen coordinates used for indexing)
-//The default pattern is 32 bits wide and 32 bits tall, or 4 bytes per row and 32 tall, 4 * 32 = 128 bytes.
-#define TGL_POLYGON_STIPPLE_MASK_X 31
-#define TGL_POLYGON_STIPPLE_MASK_Y 31
-
-//These are features useful for integrating TinyGL with other renderers.
-#define TGL_FEATURE_NO_COPY_COLOR 0
-#define TGL_FEATURE_NO_DRAW_COLOR 0
-#define TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR 0
-#define TGL_NO_COPY_COLOR 0xff00ff
-#define TGL_NO_DRAW_COLOR 0xff00ff
-//^ solid debug pink.
-#define TGL_COLOR_MASK 0x00ffffff
-
-//..
-
-#define TGL_FEATURE_16_BITS 0
-#define TGL_FEATURE_32_BITS 1
-```
-
-```
-./model -m monkey3.obj -count 27
-```
-
-Hovers around 55-62 fps at count 27.
-(I get the exact same performance figures with textures disabled)
-
-```
-./gears
-Low: 731 FPS
-High: 885 FPS
-Average: around 835
-```
-
-```
-./helloworld
-Low: 1178 FPS
-High: 1530 FPS
-Average: around 1380 FPS
-```
-
-```
-./texture
-Low: 476 FPS
-High: 547 FPS
-Average: around 510 FPS
-```
-#### With NO_DRAW_COLOR enabled, otherwise the same
-
-```
-./model -m monkey3.obj -count 24
-```
-
-Raising the count above 25 causes the count to unreliably stay above 50 FPS and never reach 60.
-
-```
-./texture
-Low: 467 FPS
-High: 592 FPS
-Average: around 570 FPS
-```
-Surprising that it actually runs faster
-
-```
-./gears
-Low: 804 FPS
-High: 917 FPS
-Average: around 842 FPS
-```
### OpenIMGUI Standard
--- a/config.mk
+++ b/config.mk
@@ -11,7 +11,8 @@
#CFLAGS= -Wall -w -O3 -g -std=c99 -march=native -DNDEBUG
#extract the maximum possible performance from gcc.
-CFLAGS= -Wall -Ofast -std=gnu99 -DNDEBUG -fopenmp -mtune=native
+CFLAGS= -Wall -Ofast -std=c99 -DNDEBUG -fopenmp -mtune=native -Wno-unused-function
+CFLAGS_LIB= -Wall -Ofast -std=c89 -DNDEBUG -fopenmp -mtune=native -Wno-unused-function
#CFLAGS= -Wall -Ofast -std=gnu99 -DNDEBUG -mtune=native
#uncomment the following line for compiling the lib with tinyc
#keep these flags for compiling with gcc if you are linking with tinygl compiled with tcc.
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -4,9 +4,9 @@
#ifndef GL_H
#define GL_H
-//Enable TinyGL's Compiletime Compatibility Test (Scroll down)
-#define COMPILETIME_TINYGL_COMPAT_TEST 1
+#define COMPILETIME_TINYGL_COMPAT_TEST 0
+
#define GL_VERSION_1_1 1
#ifdef __cplusplus
@@ -730,18 +730,13 @@
#if COMPILETIME_TINYGL_COMPAT_TEST == 1
-
-//Test to ensure that these types are the correct size
-//If you get an "array is negative" error, simply change
-//the typedefs above to types which match the sizes tested for here.
-//Note that this library NEEDS a 4-byte float type (IEEE 754) so
-//if you don't have one, TinyGL is incompatible.
-
-//Sizeof cannot be tested directly in #if directives.
-//This won't work:
-//#if (sizeof(GLbyte) != 1)
-//#error "GLbyte is wrong size!"
-//#endif
+/*
+Test to ensure that these types are the correct size
+If you get an "array is negative" error, simply change
+the typedefs above to types which match the sizes tested for here.
+Note that this library NEEDS a 4-byte float type (IEEE 754) so
+if you don't have one, TinyGL is incompatible.
+*/
extern char TGL_BUILDT_GLbyte[ 1-2*(sizeof(GLbyte) != 1)];
#ifdef __STDC_IEC_559__
#if __STDC_IEC_559__ == 0
@@ -748,9 +743,8 @@
#error C99 Compiler Using Non-Compliant Float Type! Compatibility not guaranteed.
#endif
#else
-//#warning "Cannot test __STDC_IEC_559__, it is not defined."
+#warning "Cannot test __STDC_IEC_559__, it is not defined."
#endif
-//extern char __BUILDT_error[ 1-2*(sizeof(GLbyte) != 4)];
extern char TGL_BUILDT_GLshort[ 1-2*(sizeof(GLshort) != 2)];
extern char TGL_BUILDT_GLint[ 1-2*(sizeof(GLint) != 4)];
extern char TGL_BUILDT_GLuint[ 1-2*(sizeof(GLuint) != 4)];
@@ -757,7 +751,7 @@
extern char TGL_BUILDT_GLfloat[ 1-2*(sizeof(GLfloat) != 4)];
extern char TGL_BUILDT_GLubyte[ 1-2*(sizeof(GLubyte) != 1)];
extern char TGL_BUILDT_GLushort[ 1-2*(sizeof(GLushort) != 2)];
-//Testing bit shifting on the processor.
+
extern char TGL_BUILDT_LshiftGLint[ 1-2*(((GLint)255<<8) != 65280)];
extern char TGL_BUILDT_RshiftGLint[ 1-2*((GLint)65280>>8 != 255)];
extern char TGL_BUILDT_RshiftGLint2[ 1-2*( ((GLint)-1)>>14 != -1 )];
@@ -769,10 +763,10 @@
extern char TGL_BUILDT_LshiftGLshort[ 1-2*(((GLshort)255<<8) != 65280)];
extern char TGL_BUILDT_RshiftGLshort[ 1-2*((GLshort)65280>>8 != -1)];
-//Testing floating point
-//extern char TGL_BUILDT_FLOATT1[ 1-2*((TGL_BUILDT_UNION_CAST(TGL_BUILDT_T1_HEX)).f == TGL_BUILDT_T1_FLOAT)];
-//extern char TGL_BUILDT_FLOATT2[ 1-2*((TGL_BUILDT_UNION_CAST(TGL_BUILDT_T2_FLOAT)).l == TGL_BUILDT_T2_HEX)];
+
+
+
#undef T
#endif
/* functions */
@@ -800,13 +794,13 @@
void glDrawArrays( GLenum mode,
GLint first,
GLsizei count);
-//NEW functions added by GEK!!!
-void glSetEnableSpecular(GLint s); //Toggle specular rendering (Speedup!!!)
-void* glGetTexturePixmap(GLint text, GLint level, GLint* xsize, GLint* ysize); //Get the raw data of a texture!
-void glDrawText(const GLubyte* text, GLint x, GLint y, GLuint pixel); //Blit 8x8 text to he screen
-void glTextSize(GLTEXTSIZE mode); //Set text size
-void glPlotPixel(GLint x, GLint y, GLuint pixel); //plot a pixel to the screen.
+void glSetEnableSpecular(GLint s);
+void* glGetTexturePixmap(GLint text, GLint level, GLint* xsize, GLint* ysize);
+void glDrawText(const GLubyte* text, GLint x, GLint y, GLuint pixel);
+void glTextSize(GLTEXTSIZE mode);
+void glPlotPixel(GLint x, GLint y, GLuint pixel);
+
#define PROTO_GL1(name) \
void gl ## name ## 1f(GLfloat); \
void gl ## name ## 1d(GLdouble); \
@@ -967,7 +961,7 @@
GLsizei size,
const void * data,
GLenum usage);
-//Bonus ducks! OpenGL Buffer objects.
+
void glBindBufferAsArray(GLenum target, GLuint buffer, GLenum type, GLint size, GLint stride);
/* opengl 1.2 polygon offset */
--- a/include/zbuffer.h
+++ b/include/zbuffer.h
@@ -7,16 +7,16 @@
#include "zfeatures.h"
#include "GL/gl.h"
-//#warning stdio is left in!!! remove it!!!
-//#include <stdio.h>
+
+
#define ZB_Z_BITS 16
#define ZB_POINT_Z_FRAC_BITS 14
-//a "1" in bit FRAC_BITS+1 (starting at zero) = 1.
-//This is a complicated as hell fixed point math standard.
-//go to zfeatures.h to find out how this stuff is decided
+
+
+
#define ZB_POINT_S_MIN ( (1<<ZB_POINT_S_FRAC_BITS) )
#define ZB_POINT_S_MAX ( (1<<(1+TGL_FEATURE_TEXTURE_POW2+ZB_POINT_S_FRAC_BITS))-ZB_POINT_S_MIN )
#define ZB_POINT_T_MIN ( (1<<ZB_POINT_T_FRAC_BITS) )
@@ -25,7 +25,7 @@
#define ZB_POINT_T_VALUE (ZB_POINT_T_FRAC_BITS - 4)
#define ZB_S_MASK ((TGL_FEATURE_TEXTURE_DIM-1)<<(ZB_POINT_S_FRAC_BITS+1))
#define ZB_T_MASK ((TGL_FEATURE_TEXTURE_DIM-1)<<(ZB_POINT_T_FRAC_BITS+1))
-//PSZSH is 5 at 32 bit, or 4 at 16 bit.
+
#if ZB_POINT_T_FRAC_BITS == (ZB_POINT_S_FRAC_BITS + TGL_FEATURE_TEXTURE_POW2)
#define ST_TO_TEXTURE_BYTE_OFFSET(s,t) ( ((s & ZB_S_MASK) | (t & ZB_T_MASK)) >> (ZB_POINT_S_VALUE-PSZSH))
#else
@@ -32,7 +32,7 @@
#define ST_TO_TEXTURE_BYTE_OFFSET(s,t) ( ((s & ZB_S_MASK)>>(ZB_POINT_S_VALUE-PSZSH)) | ((t & ZB_T_MASK)>>(ZB_POINT_T_VALUE-PSZSH)) )
#endif
-//The corrected mult mask prevents a bug relating to color interp. it's also why the color bit depth is so damn high.
+/*The corrected mult mask prevents a bug relating to color interp. it's also why the color bit depth is so damn high.*/
#define COLOR_MULT_MASK (0xff0000)
#define COLOR_CORRECTED_MULT_MASK (0xfe0000)
#define COLOR_MASK (0xffffff)
@@ -54,8 +54,8 @@
#define RGB_TO_PIXEL(r,g,b) \
( COLOR_R_GET16(r) | COLOR_G_GET16(g) | COLOR_B_GET16(b) )
#endif
-//This is how textures are sampled. if you want to do some sort of fancy texture filtering,
-//you do it here.
+/*This is how textures are sampled. if you want to do some sort of fancy texture filtering,*/
+/*you do it here.*/
#define TEXTURE_SAMPLE(texture, s, t) \
(*(PIXEL*)( (GLbyte*)texture + \
ST_TO_TEXTURE_BYTE_OFFSET(s,t) \
@@ -68,7 +68,7 @@
#define ZB_NB_COLORS 225 /* number of colors for 8 bit display */
-//#define TGL_CLAMPI(imp) ( (imp>0) * (COLOR_MASK * (imp>COLOR_MASK) + imp * (!(imp>COLOR_MASK)) ) )
+
#define TGL_CLAMPI(imp) ( (imp>0)?((imp>COLOR_MASK)?COLOR_MASK:imp):0 )
@@ -81,7 +81,7 @@
#define GET_REDDER(p) ((p & 0xff0000))
#define GET_GREENER(p) ((p & 0xff00)<<8)
#define GET_BLUEER(p) ((p & 0xff)<<16)
-//These never change, DO NOT CHANGE THESE BASED ON COLOR INTERP BIT DEPTH
+/*These never change, DO NOT CHANGE THESE BASED ON COLOR INTERP BIT DEPTH*/
#define GET_RED(p) ((p>>16)&0xff)
#define GET_GREEN(p) ((p>>8)&0xff)
#define GET_BLUE(p) (p&0xff)
@@ -95,7 +95,7 @@
#define GET_REDDER(p) ((p & 0xF800)<<8)
#define GET_GREENER(p) ((p & 0x07E0)<<13)
#define GET_BLUEER(p) ((p & 31)<<19)
-//DO NOT CHANGE THESE BASED ON COLOR INTERP BITDEPTH
+/*DO NOT CHANGE THESE BASED ON COLOR INTERP BITDEPTH*/
#define GET_RED(p) ((p & 0xF800)>>8)
#define GET_GREEN(p) ((p & 0x07E0)>>3)
#define GET_BLUE(p) ((p & 31)<<3)
@@ -129,7 +129,7 @@
#if TGL_FEATURE_BLEND == 1
#define TGL_BLEND_VARS GLuint zbblendeq = zb->blendeq; GLuint sfactor = zb->sfactor; GLuint dfactor = zb->dfactor;
-//SORCERY to achieve 32 bit signed integer clamping
+/*SORCERY to achieve 32 bit signed integer clamping*/
#define TGL_BLEND_SWITCH_CASE(sr,sg,sb,dr,dg,db,dest) \
@@ -198,7 +198,7 @@
} \
TGL_BLEND_SWITCH_CASE(sr,sg,sb,dr,dg,db,dest) \
} \
-} ///////////////////////////////////////////////////////////////////////////////////////
+}
#define TGL_BLEND_FUNC_RGB(rr, gg, bb, dest){ \
{ \
@@ -234,7 +234,7 @@
} \
TGL_BLEND_SWITCH_CASE(sr,sg,sb,dr,dg,db,dest) \
} \
-} ///////////////////////////////////////////////////////////////////////////////////////
+}
#else
#define TGL_BLEND_VARS /* a comment */
@@ -245,8 +245,8 @@
typedef struct {
- //GLint mode;
+
GLushort *zbuf;
PIXEL *pbuf;
PIXEL *current_texture;
@@ -255,10 +255,10 @@
/* point size*/
GLfloat pointsize;
-// GLint nb_colors;
-// unsigned char *dctable;
-// GLint *ctable;
+
+
+
/* opengl polygon stipple*/
#if TGL_FEATURE_POLYGON_STIPPLE == 1
@@ -286,9 +286,9 @@
/* zbuffer.c */
ZBuffer *ZB_open(int xsize,int ysize,int mode,
-// GLint nb_colors,
-// unsigned char *color_indexes,
-// GLint *color_table,
+
+
+
void *frame_buffer);
@@ -354,9 +354,9 @@
#else
#include<string.h>
#include<stdlib.h>
-static inline void gl_free(void* p) { free(p); }
-static inline void* gl_malloc(GLint size) { return malloc(size); }
-static inline void* gl_zalloc(GLint size) { return calloc(1, size); }
+static void gl_free(void* p) { free(p); }
+static void* gl_malloc(GLint size) { return malloc(size); }
+static void* gl_zalloc(GLint size) { return calloc(1, size); }
#endif
#endif /* _tgl_zbuffer_h_ */
--- a/include/zfeatures.h
+++ b/include/zfeatures.h
@@ -2,86 +2,95 @@
#define _tgl_features_h_
/* It is possible to enable/disable (compile time) features in this
header file. */
-
-//Enables setting the error flags when there's an error, so you can check it with glGetError
-//Disabling this has slight performance gains.
+/*
+Enables setting the error flags when there's an error, so you can check it with glGetError
+Disabling this has slight performance gains.
+*/
#define TGL_FEATURE_ERROR_CHECK 0
-//Strict out-of-memory checking. All OpenGL function calls are invalidated (ALL OF THEM) if a GL_OUT_OF_MEMORY error occurs.
-//This means that TinyGL has to constantly check all gl_malloc() attempts for errors and the state of the error state variable.
-//The checks slow down the renderer so it is not recommended , but
-//it's in the GL spec that this should occur.
+/*
+Strict out-of-memory checking. All OpenGL function calls are invalidated (ALL OF THEM) if a GL_OUT_OF_MEMORY error occurs.
+This means that TinyGL has to constantly check all gl_malloc() attempts for errors and the state of the error state variable.
+The checks slow down the renderer so it is not recommended , but
+it's in the GL spec that this should occur.
+*/
#define TGL_FEATURE_STRICT_OOM_CHECKS 0
-//Swap between using the inline'd malloc(), calloc(), and free() in zbuffer.h, or
-//a replacement gl_malloc(), gl_zalloc(), and gl_free() in memory.c
+/*
+Swap between using the inline'd malloc(), calloc(), and free() in zbuffer.h, or
+a replacement gl_malloc(), gl_zalloc(), and gl_free() in memory.c
+*/
#define TGL_FEATURE_CUSTOM_MALLOC 0
-//Use Fast Inverse Square Root. Toggleable because it's actually slower,
-//And because some systems may have float types which are incompatible with it.
+/*
+Use Fast Inverse Square Root. Toggleable because it's actually slower,
+And because some systems may have float types which are incompatible with it.
+*/
#define TGL_FEATURE_FISR 1
-//Clientside Arrays
+
#define TGL_FEATURE_ARRAYS 1
-//This library has a super cool opcode system based on function pointers, it's pretty fast too.
+
#define TGL_FEATURE_DISPLAYLISTS 1
-//Lighting is expensive on texture-mapped polygons.
+
#define TGL_FEATURE_LIT_TEXTURES 1
-//Enable the patternized "discard"-ing of pixels.
+/*Enable the patternized "discard"-ing of pixels.*/
#define TGL_FEATURE_POLYGON_STIPPLE 0
-//Enable the use of GL_SELECT and GL_FEEDBACK
+/*Enable the use of GL_SELECT and GL_FEEDBACK*/
#define TGL_FEATURE_ALT_RENDERMODES 0
-//Enable the rendering of large polygons (in terms of vertex count)
-//Also enabled the rendering of line loops.
-//the maximum number of vertices in a polygon is defined in zgl.h
+/*
+Enable the rendering of large polygons (in terms of vertex count)
+Also enabled the rendering of line loops.
+the maximum number of vertices in a polygon is defined in zgl.h
+*/
#define TGL_FEATURE_GL_POLYGON 0
-//Enable GL_BLEND functionality
+
#define TGL_FEATURE_BLEND 1
-//Enable blending in glDrawPixels, which slows it down a lot and makes it unsuitable for a lot of things.
+
#define TGL_FEATURE_BLEND_DRAW_PIXELS 0
-//The width of textures as a power of 2. The default is 8, or 256x256 textures.
+/*The width of textures as a power of 2. The default is 8, or 256x256 textures.*/
#define TGL_FEATURE_TEXTURE_POW2 8
#define TGL_FEATURE_TEXTURE_DIM (1<<TGL_FEATURE_TEXTURE_POW2)
-//A stipple pattern is 128 bytes in size.
+/*A stipple pattern is 128 bytes in size.*/
#define TGL_POLYGON_STIPPLE_BYTES 128
-//A stipple pattern is 2^5 (32) bits wide.
+/*A stipple pattern is 2^5 (32) bits wide.*/
#define TGL_POLYGON_STIPPLE_POW2_WIDTH 5
-//The stipple pattern mask (the last bits of the screen coordinates used for indexing)
-//The default pattern is 32 bits wide and 32 bits tall, or 4 bytes per row and 32 tall, 4 * 32 = 128 bytes.
#define TGL_POLYGON_STIPPLE_MASK_X 31
#define TGL_POLYGON_STIPPLE_MASK_Y 31
-//Use lookup tables for calculating specular light.
+/*Use lookup tables for calculating specular light.*/
#define TGL_FEATURE_SPECULAR_BUFFERS 0
-//Prevent ZB_copyFrameBuffer from copying certain colors.
+/*Prevent ZB_copyFrameBuffer from copying certain colors.*/
#define TGL_FEATURE_NO_COPY_COLOR 0
-//Don't draw (texture mapped) pixels whose color is the NO_DRAW_COLOR
+/*Don't draw (texture mapped) pixels whose color is the NO_DRAW_COLOR*/
#define TGL_FEATURE_NO_DRAW_COLOR 0
-//Regardless of the current clear color, always clear using the NO_COPY_COLOR
+/*Regardless of the current clear color, always clear using the NO_COPY_COLOR*/
#define TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR 0
#define TGL_NO_COPY_COLOR 0xff00ff
#define TGL_NO_DRAW_COLOR 0xff00ff
-//^ solid debug pink.
+/* solid debug pink.*/
#define TGL_COLOR_MASK 0x00ffffff
-//^ mask to check for while drawing/copying.
+/* mask to check for while drawing/copying.*/
-//MULTITHREADING OPTIONS, only applicable if compiled with -fopenmp
-//Enable DrawPixels to offload the rendering of individual scanlines to separate threads.
+
+
#define TGL_FEATURE_MULTITHREADED_DRAWPIXELS 1
-//Enable multithreading glCopyTexImage2D
+
#define TGL_FEATURE_MULTITHREADED_COPY_TEXIMAGE_2D 1
-//Enable multithreading the ZB_CopyBuffer operation.
+
#define TGL_FEATURE_MULTITHREADED_ZB_COPYBUFFER 0
-//Enable stdalign
+
#define TGL_FEATURE_ALIGNAS 1
-//Optimization hint- cost of branching.
-//0- branching has zero cost, avoid extraneous code.
-//1- Branching has some cost, allow some extraneous code
-//2- Branching has extreme cost, allow a lot of extraneous code. Modern processors work best on this setting.
+/*
+Optimization hint- cost of branching.
+0- branching has zero cost, avoid extraneous code.
+1- Branching has some cost, allow some extraneous code
+2- Branching has extreme cost, allow a lot of extraneous code. Modern processors work best on this setting.
+*/
#define TGL_OPTIMIZATION_HINT_BRANCH_COST 2
-//Disable it for TinyC
+
#ifdef __TINYC__
#undef TGL_FEATURE_ALIGNAS
#define TGL_FEATURE_ALIGNAS 0
@@ -95,17 +104,10 @@
#define TGL_ALIGN /*a comment*/
#endif
-//DO NOT TURN THESE ON, I don't maintain them and I actively #error them out.
-#define TGL_FEATURE_8_BITS 0
-#define TGL_FEATURE_24_BITS 0
-//These are the only maintained modes.
#define TGL_FEATURE_16_BITS 0
#define TGL_FEATURE_32_BITS 1
-//#define TGL_FEATURE_RENDER_BITS 15
-//#define TGL_FEATURE_RENDER_BITS 16
-
#if TGL_FEATURE_32_BITS == 1
#define TGL_FEATURE_RENDER_BITS 32
@@ -117,11 +119,11 @@
#endif
-//The fraction bits in the fixed point values used for S and T in interpolatiion.
+/*The fraction bits in the fixed point values used for S and T in interpolatiion.*/
#define ZB_POINT_S_FRAC_BITS 10
#define ZB_POINT_T_FRAC_BITS (ZB_POINT_S_FRAC_BITS + TGL_FEATURE_TEXTURE_POW2)
-//Test the compatibility of the target platform at glInit() time.
+/*Test the compatibility of the target platform at glInit() time.*/
#define TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST 1
#define TINYGL_VERSION 0.8
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,4 +18,4 @@
clean:
rm -f *~ *.o *.a
.c.o:
- $(CC) $(CFLAGS) -Wno-uninitialized -c $*.c
+ $(CC) $(CFLAGS_LIB) -c $*.c
--- a/src/accum.c
+++ b/src/accum.c
@@ -1,2 +1,2 @@
#include "zgl.h"
-//TODO: Write the accumulation buffer
+
--- a/src/api.c
+++ b/src/api.c
@@ -1,5 +1,4 @@
#include "zgl.h"
-//#include <stdio.h>
/* glVertex */
void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
@@ -26,8 +25,8 @@
GLParam p[4];
#include "error_check_no_context.h"
p[0].op = OP_Normal;
-//NODO: Normalize vector here if it's enabled, so that the display list contains only normalized normals.
-//Redacted because: It would fuck up the matrix math. Dang it!
+
+
p[1].f = x;
p[2].f = y;
p[3].f = z;
@@ -35,13 +34,12 @@
gl_add_op(p);
}
-
-void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2){
+void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) {
glBegin(GL_QUADS);
- glVertex2f( x1, y1 );
- glVertex2f( x2, y1 );
- glVertex2f( x2, y2 );
- glVertex2f( x1, y2 );
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y1);
+ glVertex2f(x2, y2);
+ glVertex2f(x1, y2);
glEnd();
}
@@ -114,11 +112,11 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
-if(flag != GL_TRUE && flag != GL_FALSE)
+ if (flag != GL_TRUE && flag != GL_FALSE)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#endif
- p[0].op = OP_EdgeFlag;
+ p[0].op = OP_EdgeFlag;
p[1].i = flag;
gl_add_op(p);
@@ -131,14 +129,14 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(mode != GL_FLAT && mode != GL_SMOOTH)
+ if (mode != GL_FLAT && mode != GL_SMOOTH)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- if(mode != GL_FLAT && mode != GL_SMOOTH) return;
-//Assume that they know what they're doing.
+ if (mode != GL_FLAT && mode != GL_SMOOTH)
+ return;
#endif
- p[0].op = OP_ShadeModel;
+ p[0].op = OP_ShadeModel;
p[1].i = mode;
gl_add_op(p);
@@ -149,14 +147,14 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK))
+ if (!(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK);
- //Assume it's alrgiht.
+ /* assert(mode == GL_BACK || mode == GL_FRONT || mode == GL_FRONT_AND_BACK);*/
+ /* Assume it's alrgiht.*/
#endif
- p[0].op = OP_CullFace;
+ p[0].op = OP_CullFace;
p[1].i = mode;
gl_add_op(p);
@@ -167,13 +165,13 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(mode == GL_CCW || mode == GL_CW))
+ if (!(mode == GL_CCW || mode == GL_CW))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //if(!(mode == GL_CCW || mode == GL_CW)) return;
+ /* if(!(mode == GL_CCW || mode == GL_CW)) return;*/
#endif
- mode = (mode != GL_CCW);
+ mode = (mode != GL_CCW);
p[0].op = OP_FrontFace;
p[1].i = mode;
@@ -186,16 +184,14 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
-if(!( (face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK)&&
- (mode == GL_POINT || mode == GL_LINE || mode == GL_FILL) )
- )
+ if (!((face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK) && (mode == GL_POINT || mode == GL_LINE || mode == GL_FILL)))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK);
- //assert(mode == GL_POINT || mode == GL_LINE || mode == GL_FILL);
+ /* assert(face == GL_BACK || face == GL_FRONT || face == GL_FRONT_AND_BACK);*/
+ /* assert(mode == GL_POINT || mode == GL_LINE || mode == GL_FILL);*/
#endif
- p[0].op = OP_PolygonMode;
+ p[0].op = OP_PolygonMode;
p[1].i = face;
p[2].i = mode;
@@ -202,12 +198,12 @@
gl_add_op(p);
}
-void glDepthMask(GLint i){
+void glDepthMask(GLint i) {
#include "error_check_no_context.h"
- gl_get_context()->zb->depth_write = (i==GL_TRUE);
+ gl_get_context()->zb->depth_write = (i == GL_TRUE);
}
/* glEnable / glDisable */
-//TODO go to glopEnableDisable and add error checking there on values there.
+/* TODO go to glopEnableDisable and add error checking there on values there.*/
void glEnable(GLint cap) {
GLParam p[3];
#include "error_check_no_context.h"
@@ -236,25 +232,17 @@
#include "error_check_no_context.h"
p[0].op = OP_Begin;
p[1].i = mode;
-#if TGL_FEATURE_ERROR_CHECK ==1
-//Check for compatibility of selection
-if(mode != GL_POINTS &&
-mode != GL_LINES &&
-mode != GL_LINE_LOOP &&
-mode != GL_LINE_STRIP &&
+#if TGL_FEATURE_ERROR_CHECK == 1
+
+ if (mode != GL_POINTS && mode != GL_LINES && mode != GL_LINE_LOOP && mode != GL_LINE_STRIP &&
#if TGL_FEATURE_GL_POLYGON == 1
-mode != GL_POLYGON &&
+ mode != GL_POLYGON &&
#endif
-mode != GL_TRIANGLES &&
-mode != GL_TRIANGLE_FAN &&
-mode != GL_TRIANGLE_STRIP &&
-mode != GL_QUADS &&
-mode != GL_QUAD_STRIP
-)
+ mode != GL_TRIANGLES && mode != GL_TRIANGLE_FAN && mode != GL_TRIANGLE_STRIP && mode != GL_QUADS && mode != GL_QUAD_STRIP)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#endif
- gl_add_op(p);
+ gl_add_op(p);
}
void glEnd(void) {
@@ -390,16 +378,16 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK))
+ if (!(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK);
-#endif
- p[0].op = OP_Material;
+ /* assert(mode == GL_FRONT || mode == GL_BACK || mode == GL_FRONT_AND_BACK);*/
+#endif
+ p[0].op = OP_Material;
p[1].i = mode;
p[2].i = type;
- n = 4;//This appears to be a hack... to avoid a jump instruction? What the hell?
+ n = 4; /* This appears to be a hack... to avoid a jump instruction? What the hell?*/
if (type == GL_SHININESS)
n = 1;
for (i = 0; i < 4; i++)
@@ -468,8 +456,6 @@
p[0].op = OP_LightModel;
p[1].i = pname;
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;
p[4].f = 0;
p[5].f = 0;
@@ -521,7 +507,6 @@
}
/* textures */
-//TODO Check inputs into glopTexImage2D
void glTexImage2D(GLint target, GLint level, GLint components, GLint width, GLint height, GLint border, GLint format, GLint type, void* pixels) {
GLParam p[10];
#include "error_check_no_context.h"
@@ -565,33 +550,32 @@
}
void glTexEnvi(GLint target, GLint pname, GLint param) {
-// GLParam p[8];
+
#include "error_check_no_context.h"
-// p[0].op = OP_TexEnv;
-// p[1].i = target;
-// p[2].i = pname;
-// p[3].i = param;
-// p[4].f = 0;
-// p[5].f = 0;
-// p[6].f = 0;
-// p[7].f = 0;
-// gl_add_op(p);
+
+
+
+
+
+
+
+
}
void glTexParameteri(GLint target, GLint pname, GLint param) {
-// GLParam p[8];
+
#include "error_check_no_context.h"
-// p[0].op = OP_TexParameter;
-// p[1].i = target;
-// p[2].i = pname;
-// p[3].i = param;
-// p[4].f = 0;
-// p[5].f = 0;
-// p[6].f = 0;
-// p[7].f = 0;
-// gl_add_op(p);
+
+
+
+
+
+
+
+
+
}
/*
@@ -660,14 +644,11 @@
gl_add_op(p);
}
-
-//TODO: Implement a barrier for worker threads if we ever add multithreading support.
void glFlush(void) { /* nothing to do */
}
void glHint(GLint target, GLint mode) {
#include "error_check_no_context.h"
-
}
/* Non standard functions */
--- a/src/arrays.c
+++ b/src/arrays.c
@@ -1,67 +1,86 @@
#include "zgl.h"
-//#include <stdio.h>
+
#include "msghandling.h"
-//Code for buffers is here too!
-
-static GLint free_buffer(GLint handle){
+static GLint free_buffer(GLint handle) {
GLContext* c = gl_get_context();
GLSharedState* s = &(c->shared_state);
- if(handle == 0 || handle > MAX_BUFFERS) return 1; //error flag
-//HANDLE IS HENCEFORTH AN INDEX, AND NOT A HANDLE!!!
+ if (handle == 0 || handle > MAX_BUFFERS)
+ return 1;
+
handle--;
- if(s->buffers[handle]){ //if this handle exists...
- if(c->boundarraybuffer == (handle+1)) c->boundarraybuffer = 0;
- if(s->buffers[handle]->data) //if this handle has data...
+ if (s->buffers[handle]) {
+ if (c->boundarraybuffer == (handle + 1))
+ c->boundarraybuffer = 0;
+ if (s->buffers[handle]->data)
{
void* d = s->buffers[handle]->data;
- gl_free(s->buffers[handle]->data); //free the data...
- //deal with the possible bindings...
- if(c->vertex_array == d) {c->vertex_array = NULL;c->client_states &= ~VERTEX_ARRAY;}
- if(c->color_array == d) {c->color_array = NULL;c->client_states &= ~COLOR_ARRAY;}
- if(c->normal_array == d) {c->normal_array = NULL;c->client_states &= ~NORMAL_ARRAY;}
- if(c->texcoord_array == d) {c->texcoord_array = NULL;c->client_states &= ~TEXCOORD_ARRAY;}
+ gl_free(s->buffers[handle]->data);
+
+ if (c->vertex_array == d) {
+ c->vertex_array = NULL;
+ c->client_states &= ~VERTEX_ARRAY;
+ }
+ if (c->color_array == d) {
+ c->color_array = NULL;
+ c->client_states &= ~COLOR_ARRAY;
+ }
+ if (c->normal_array == d) {
+ c->normal_array = NULL;
+ c->client_states &= ~NORMAL_ARRAY;
+ }
+ if (c->texcoord_array == d) {
+ c->texcoord_array = NULL;
+ c->client_states &= ~TEXCOORD_ARRAY;
+ }
}
- gl_free(s->buffers[handle]); //free the buffer...
- s->buffers[handle] = NULL; //Set it to null...
+ gl_free(s->buffers[handle]);
+ s->buffers[handle] = NULL;
return 0;
} else {
return 0;
}
}
-static GLint check_buffer(GLint handle){ //1 means used, 0 means free, 2 means invalid
+static GLint check_buffer(GLint handle) {
GLContext* c = gl_get_context();
GLSharedState* s = &(c->shared_state);
- if(handle == 0 || handle > MAX_BUFFERS) return 2; //error flag
+ if (handle == 0 || handle > MAX_BUFFERS)
+ return 2;
handle--;
- if(s->buffers[handle]) return 1;
+ if (s->buffers[handle])
+ return 1;
return 0;
}
-GLboolean glIsBuffer( GLuint buffer){
- if(check_buffer(buffer) == 1) return GL_TRUE;
+GLboolean glIsBuffer(GLuint buffer) {
+ if (check_buffer(buffer) == 1)
+ return GL_TRUE;
return GL_FALSE;
}
-
-static inline GLBuffer* get_buffer(GLint handle){
- GLContext* c = gl_get_context();
- GLSharedState* s = &(c->shared_state);
- if(handle == 0 || handle > MAX_BUFFERS) return NULL;
+static GLBuffer* get_buffer(GLint handle) {
+ GLContext* c;
+ GLSharedState* s;
+ c = gl_get_context();
+ s = &(c->shared_state);
+ if (handle == 0 || handle > MAX_BUFFERS)
+ return NULL;
handle--;
return s->buffers[handle];
}
-static inline GLint create_buffer(GLint handle){
+static GLint create_buffer(GLint handle) {
GLContext* c = gl_get_context();
GLSharedState* s = &(c->shared_state);
- if(handle == 0 || handle > MAX_BUFFERS) return 1; //error flag
- handle--;//convert from handle to index
- if(s->buffers[handle]) free_buffer(handle+1); //this is no longer the handle so we have to add 1.
- //This buffer is now free for usage!
- s->buffers[handle] = gl_zalloc(sizeof(GLBuffer));
+ if (handle == 0 || handle > MAX_BUFFERS)
+ return 1;
+ handle--;
+ if (s->buffers[handle])
+ free_buffer(handle + 1);
- if(!(s->buffers[handle])){
+ s->buffers[handle] = gl_zalloc(sizeof(GLBuffer));
+
+ if (!(s->buffers[handle])) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#define RETVAL 1
@@ -75,103 +94,99 @@
return 0;
}
-void glGenBuffers( GLsizei n,
- GLuint * buffers)
-{GLContext* c = gl_get_context();
- #include "error_check.h"
- if(n > MAX_BUFFERS) goto error;
+void glGenBuffers(GLsizei n, GLuint* buffers) {
+ GLint i;
+ GLContext* c = gl_get_context();
+#include "error_check.h"
+ if (n > MAX_BUFFERS)
+ goto error;
- {
+ {
GLint n_left = n;
GLuint names[MAX_BUFFERS];
- for(int i = 1; i <= MAX_BUFFERS && n_left > 0; i++)
- if(!check_buffer(i)) names[(n_left--)-1] = i;
+ for (i = 1; i <= MAX_BUFFERS && n_left > 0; i++)
+ if (!check_buffer(i))
+ names[(n_left--) - 1] = i;
- if(n_left) goto error; //We were unable to find enough free names.
- for(int i = 0; i < n; i++){
+ if (n_left)
+ goto error;
+ for (i = 0; i < n; i++) {
create_buffer(names[i]);
-
-//we have this error check here to quit out early in case of GL_OUT_OF_MEMORY
+
+
#include "error_check.h"
buffers[i] = names[i];
}
}
return;
- error:
- for(int i = 0; i < n; i++)
- buffers[i] = 0;
- return;
+error:
+ for (i = 0; i < n; i++)
+ buffers[i] = 0;
+ return;
}
-void glDeleteBuffers( GLsizei n,
- const GLuint * buffers)
-{GLContext* c = gl_get_context();
- #include "error_check.h"
- for(GLint i = 0; i < n; i++) free_buffer(buffers[i]);
+void glDeleteBuffers(GLsizei n, const GLuint* buffers) {
+ GLint i;
+ GLContext* c = gl_get_context();
+#include "error_check.h"
+ for (i = 0; i < n; i++)
+ free_buffer(buffers[i]);
}
-//TODO GL_ARRAY_BUFFER, at a minimum.
-void glBindBuffer( GLenum target,
- GLuint buffer)
-{
+void glBindBuffer(GLenum target, GLuint buffer) {
GLContext* c = gl_get_context();
- #include "error_check.h"
- if(buffer == 0 ||
- check_buffer(buffer) == 1){
- if(target == GL_ARRAY_BUFFER) c->boundarraybuffer = buffer;
+#include "error_check.h"
+ if (buffer == 0 || check_buffer(buffer) == 1) {
+ if (target == GL_ARRAY_BUFFER)
+ c->boundarraybuffer = buffer;
}
return;
}
-void glBindBufferAsArray(GLenum target,
- GLuint buffer,
- GLenum type, //GL_FLOAT
- GLint size, //number of floats
- GLint stride){ //floats between items
+void glBindBufferAsArray(GLenum target, GLuint buffer,
+ GLenum type,
+ GLint size,
+ GLint stride) {
GLContext* c = gl_get_context();
- #include "error_check.h"
- if(target != GL_VERTEX_BUFFER &&
- target != GL_NORMAL_BUFFER &&
- target != GL_COLOR_BUFFER &&
- target != GL_TEXTURE_COORD_BUFFER){
+#include "error_check.h"
+ if (target != GL_VERTEX_BUFFER && target != GL_NORMAL_BUFFER && target != GL_COLOR_BUFFER && target != GL_TEXTURE_COORD_BUFFER) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
return;
-#endif
-
+#endif
}
- if(buffer == 0)
- switch(target){
- case GL_VERTEX_BUFFER:
- glDisableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(size, type, stride, NULL);
- c->boundvertexbuffer = buffer;
- return;
+ if (buffer == 0)
+ switch (target) {
+ case GL_VERTEX_BUFFER:
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(size, type, stride, NULL);
+ c->boundvertexbuffer = buffer;
+ return;
break;
- case GL_NORMAL_BUFFER:
- glDisableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(type, stride, NULL);
- c->boundnormalbuffer = buffer;
- return;
+ case GL_NORMAL_BUFFER:
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(type, stride, NULL);
+ c->boundnormalbuffer = buffer;
+ return;
break;
- case GL_COLOR_BUFFER:
- glDisableClientState(GL_COLOR_ARRAY);
- glColorPointer(size, type, stride, NULL);
- c->boundcolorbuffer = buffer;
- return;
+ case GL_COLOR_BUFFER:
+ glDisableClientState(GL_COLOR_ARRAY);
+ glColorPointer(size, type, stride, NULL);
+ c->boundcolorbuffer = buffer;
+ return;
break;
- case GL_TEXTURE_COORD_BUFFER:
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(size, type, stride, NULL);
- c->boundtexcoordbuffer = buffer;
- return;
+ case GL_TEXTURE_COORD_BUFFER:
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(size, type, stride, NULL);
+ c->boundtexcoordbuffer = buffer;
+ return;
break;
- default:return;
+ default:
+ return;
}
- if(check_buffer(buffer) != 1 ||
- type != GL_FLOAT){
+ if (check_buffer(buffer) != 1 || type != GL_FLOAT) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
@@ -180,8 +195,8 @@
return;
#endif
}
- GLBuffer* buf = c->shared_state.buffers[buffer-1];
- if(!buf || (buf->data == NULL) || (buf->size == 0)){
+ GLBuffer* buf = c->shared_state.buffers[buffer - 1];
+ if (!buf || (buf->data == NULL) || (buf->size == 0)) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
@@ -190,48 +205,52 @@
return;
#endif
}
- switch(target){
- case GL_VERTEX_BUFFER:
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(size, type, stride, buf->data);
- c->boundvertexbuffer = buffer;
+ switch (target) {
+ case GL_VERTEX_BUFFER:
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(size, type, stride, buf->data);
+ c->boundvertexbuffer = buffer;
break;
- case GL_NORMAL_BUFFER:
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(type, stride, buf->data);
- c->boundnormalbuffer = buffer;
+ case GL_NORMAL_BUFFER:
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(type, stride, buf->data);
+ c->boundnormalbuffer = buffer;
break;
- case GL_COLOR_BUFFER:
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(size, type, stride, buf->data);
- c->boundcolorbuffer = buffer;
+ case GL_COLOR_BUFFER:
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(size, type, stride, buf->data);
+ c->boundcolorbuffer = buffer;
break;
- case GL_TEXTURE_COORD_BUFFER:
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(size, type, stride, buf->data);
- c->boundtexcoordbuffer = buffer;
+ case GL_TEXTURE_COORD_BUFFER:
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(size, type, stride, buf->data);
+ c->boundtexcoordbuffer = buffer;
break;
- default:return;
+ default:
+ return;
}
return;
}
-void *glMapBuffer( GLenum target,
- GLenum access)
-{
+void* glMapBuffer(GLenum target, GLenum access) {
GLContext* c = gl_get_context();
#define RETVAL NULL
#include "error_check.h"
GLint handle = 0;
- if(target == GL_ARRAY_BUFFER) handle = c->boundarraybuffer;
- if(target == GL_VERTEX_BUFFER) handle = c->boundvertexbuffer;
- if(target == GL_TEXTURE_COORD_BUFFER) handle = c->boundtexcoordbuffer;
- if(target == GL_NORMAL_BUFFER) handle = c->boundnormalbuffer;
- if(target == GL_COLOR_BUFFER) handle = c->boundcolorbuffer;
+ if (target == GL_ARRAY_BUFFER)
+ handle = c->boundarraybuffer;
+ if (target == GL_VERTEX_BUFFER)
+ handle = c->boundvertexbuffer;
+ if (target == GL_TEXTURE_COORD_BUFFER)
+ handle = c->boundtexcoordbuffer;
+ if (target == GL_NORMAL_BUFFER)
+ handle = c->boundnormalbuffer;
+ if (target == GL_COLOR_BUFFER)
+ handle = c->boundcolorbuffer;
{
- if(check_buffer(handle) == 1)
- return c->shared_state.buffers[handle-1]->data;
+ if (check_buffer(handle) == 1)
+ return c->shared_state.buffers[handle - 1]->data;
}
#if TGL_FEATURE_ERROR_CHECK == 1
#define RETVAL NULL
@@ -241,22 +260,25 @@
return NULL;
#endif
}
-void glBufferData( GLenum target,
- GLsizei size,
- const void * data,
- GLenum usage) //Usage parameter is ignored.
+void glBufferData(GLenum target, GLsizei size, const void* data,
+ GLenum usage)
{
GLContext* c = gl_get_context();
#include "error_check.h"
GLint handle = 0;
GLBuffer* buf = NULL;
- if(target == GL_ARRAY_BUFFER) handle = c->boundarraybuffer;
- if(target == GL_VERTEX_BUFFER) handle = c->boundvertexbuffer;
- if(target == GL_TEXTURE_COORD_BUFFER) handle = c->boundtexcoordbuffer;
- if(target == GL_NORMAL_BUFFER) handle = c->boundnormalbuffer;
- if(target == GL_COLOR_BUFFER) handle = c->boundcolorbuffer;
- if(check_buffer(handle) == 1)
- buf = c->shared_state.buffers[handle-1];
+ if (target == GL_ARRAY_BUFFER)
+ handle = c->boundarraybuffer;
+ if (target == GL_VERTEX_BUFFER)
+ handle = c->boundvertexbuffer;
+ if (target == GL_TEXTURE_COORD_BUFFER)
+ handle = c->boundtexcoordbuffer;
+ if (target == GL_NORMAL_BUFFER)
+ handle = c->boundnormalbuffer;
+ if (target == GL_COLOR_BUFFER)
+ handle = c->boundcolorbuffer;
+ if (check_buffer(handle) == 1)
+ buf = c->shared_state.buffers[handle - 1];
else {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_ENUM
@@ -265,12 +287,15 @@
return;
#endif
}
- if(buf->data) gl_free(buf->data);
- buf->data = NULL; buf->size = 0;
- if(size == 0) return; //Allow the user to delete buffer data with glBufferData.
+ if (buf->data)
+ gl_free(buf->data);
+ buf->data = NULL;
+ buf->size = 0;
+ if (size == 0)
+ return;
buf->data = gl_malloc(size);
buf->size = size;
- if(!(buf->data)){
+ if (!(buf->data)) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
@@ -278,22 +303,13 @@
gl_fatal_error("GL_OUT_OF_MEMORY");
#endif
}
- if(data != NULL)
+ if (data != NULL)
memcpy(buf->data, data, size);
}
-
-
-
-
-
-
-
-
-
void glopArrayElement(GLParam* param) {
- GLContext* c = gl_get_context();
GLint i;
+ GLContext* c = gl_get_context();
GLint states = c->client_states;
GLint idx = param[1].i;
@@ -312,7 +328,7 @@
c->current_normal.X = c->normal_array[i];
c->current_normal.Y = c->normal_array[i + 1];
c->current_normal.Z = c->normal_array[i + 2];
- //c->current_normal.Z = 0.0f;
+
}
if (states & TEXCOORD_ARRAY) {
GLint size = c->texcoord_array_size;
@@ -342,14 +358,14 @@
gl_add_op(p);
}
-void glDrawArrays( GLenum mode,
- GLint first,
- GLsizei count){
- //Temporary implementation until I figure out MR's "batch geometry processing" idea
+void glDrawArrays(GLenum mode, GLint first, GLsizei count) {
+ GLint i;
+ GLint end;
+
#include "error_check_no_context.h"
- GLint end = first+count;
+ end = first + count;
glBegin(mode);
- for(GLint i = first;i<end;i++)
+ for (i = first; i < end; i++)
glArrayElement(i);
glEnd();
}
@@ -380,7 +396,10 @@
gl_add_op(p);
}
-void glopDisableClientState( GLParam* p) {GLContext* c = gl_get_context(); c->client_states &= p[1].i; }
+void glopDisableClientState(GLParam* p) {
+ GLContext* c = gl_get_context();
+ c->client_states &= p[1].i;
+}
void glDisableClientState(GLenum array) {
GLParam p[2];
@@ -418,13 +437,14 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(type != GL_FLOAT)
+ if (type != GL_FLOAT)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- if(type != GL_FLOAT) return;
+ if (type != GL_FLOAT)
+ return;
#endif
- p[0].op = OP_VertexPointer;
+ p[0].op = OP_VertexPointer;
p[1].i = size;
p[2].i = stride;
p[3].p = (void*)pointer;
@@ -443,13 +463,13 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(type != GL_FLOAT)
+ if (type != GL_FLOAT)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(type == GL_FLOAT);
+ /* assert(type == GL_FLOAT);*/
#endif
- p[0].op = OP_ColorPointer;
+ p[0].op = OP_ColorPointer;
p[1].i = size;
p[2].i = stride;
p[3].p = (void*)pointer;
@@ -467,13 +487,13 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(type != GL_FLOAT)
+ if (type != GL_FLOAT)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
-
+
#endif
- p[0].op = OP_NormalPointer;
+ p[0].op = OP_NormalPointer;
p[1].i = stride;
p[2].p = (void*)pointer;
gl_add_op(p);
@@ -491,13 +511,13 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(type != GL_FLOAT)
+ if (type != GL_FLOAT)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
-
+
#endif
- p[0].op = OP_TexCoordPointer;
+ p[0].op = OP_TexCoordPointer;
p[1].i = size;
p[2].i = stride;
p[3].p = (void*)pointer;
--- a/src/clear.c
+++ b/src/clear.c
@@ -7,9 +7,13 @@
c->clear_color.v[2] = p[3].f;
c->clear_color.v[3] = p[4].f;
}
-void glopClearDepth(GLParam* p) { GLContext* c = gl_get_context(); c->clear_depth = p[1].f; }
+void glopClearDepth(GLParam* p) {
+ GLContext* c = gl_get_context();
+ c->clear_depth = p[1].f;
+}
-void glopClear(GLParam* p) {GLContext* c = gl_get_context();
+void glopClear(GLParam* p) {
+ GLContext* c = gl_get_context();
GLint mask = p[1].i;
GLint z = 0;
GLint r = (GLint)(c->clear_color.v[0] * COLOR_MULT_MASK);
--- a/src/clip.c
+++ b/src/clip.c
@@ -10,7 +10,7 @@
#define CLIP_ZMIN (1 << 4)
#define CLIP_ZMAX (1 << 5)
-static inline void gl_transform_to_viewport_clip_c(GLVertex* v) { //MARK: NOT_INLINED_IN_OG
+static void gl_transform_to_viewport_clip_c(GLVertex* v) { /* MARK: NOT_INLINED_IN_OG*/
GLContext* c = gl_get_context();
/* coordinates */
{
@@ -26,34 +26,15 @@
/* texture */
- if (c->texture_2d_enabled)
- {
- v->zp.s = (GLint)(v->tex_coord.X * (ZB_POINT_S_MAX - ZB_POINT_S_MIN) + ZB_POINT_S_MIN); //MARKED
- v->zp.t = (GLint)(v->tex_coord.Y * (ZB_POINT_T_MAX - ZB_POINT_T_MIN) + ZB_POINT_T_MIN); //MARKED
+ if (c->texture_2d_enabled) {
+ v->zp.s = (GLint)(v->tex_coord.X * (ZB_POINT_S_MAX - ZB_POINT_S_MIN) + ZB_POINT_S_MIN);
+ v->zp.t = (GLint)(v->tex_coord.Y * (ZB_POINT_T_MAX - ZB_POINT_T_MIN) + ZB_POINT_T_MIN);
}
}
-/*
-//MARK <POSSIBLE_PERF_BONUS>
-#define clip_func(name, sign, dir, dir1, dir2) GLfloat name(V4* c, V4* a, V4* b);
-//MARK <POSSIBLE_PERF_BONUS>
-clip_func(clip_xmin, -, X, Y, Z)
- clip_func(clip_xmax, +, X, Y, Z)
- clip_func(clip_ymin, -, Y, X, Z)
-
- clip_func(clip_ymax, +, Y, X, Z)
-//MARK <POSSIBLE_PERF_BONUS>
- clip_func(clip_zmin, -, Z, X, Y)
-
- clip_func(clip_zmax, +, Z, X, Y)
-
-extern GLfloat (*clip_proc[6])(V4*, V4*, V4*);// = {clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax};
-
-*/
-
-#define clip_funcdef(name, sign, dir, dir1, dir2) \
+#define clip_funcdef(name, sign, dir, dir1, dir2) \
static GLfloat name(V4* c, V4* a, V4* b) { \
GLfloat t, dX, dY, dZ, dW, den; \
dX = (b->X - a->X); \
@@ -71,7 +52,6 @@
c->dir = sign c->W; \
return t; \
}
-//MARK <POSSIBLE_PERF_BONUS>
clip_funcdef(clip_xmin, -, X, Y, Z)
clip_funcdef(clip_xmax, +, X, Y, Z)
@@ -79,7 +59,7 @@
clip_funcdef(clip_ymin, -, Y, X, Z)
clip_funcdef(clip_ymax, +, Y, X, Z)
-//MARK <POSSIBLE_PERF_BONUS>
+
clip_funcdef(clip_zmin, -, Z, X, Y)
clip_funcdef(clip_zmax, +, Z, X, Y)
@@ -111,9 +91,9 @@
if (c->render_mode == GL_SELECT) {
gl_add_select(p0->zp.z, p0->zp.z);
- }else if (c->render_mode == GL_FEEDBACK){
- gl_add_feedback(GL_POINT_TOKEN,p0,NULL,NULL,0);
- } else
+ } else if (c->render_mode == GL_FEEDBACK) {
+ gl_add_feedback(GL_POINT_TOKEN, p0, NULL, NULL, 0);
+ } else
#endif
{
ZB_plot(c->zb, &p0->zp);
@@ -122,31 +102,25 @@
}
/* line */
-//Used only for lines.
-
/*
* Line Clipping
*/
-
-
-
-
-
-static inline void GLinterpolate(GLVertex* q, GLVertex* p0, GLVertex* p1, GLfloat t) { //MARK: INLINED_IN_OG
+static void GLinterpolate(GLVertex* q, GLVertex* p0, GLVertex* p1, GLfloat t) {
+ GLint i;
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;
q->pc.Z = p0->pc.Z + (p1->pc.Z - p0->pc.Z) * t;
q->pc.W = p0->pc.W + (p1->pc.W - p0->pc.W) * t;
#pragma omp simd
- for(int i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
q->color.v[i] = p0->color.v[i] + (p1->color.v[i] - p0->color.v[i]) * t;
}
/* Line Clipping algorithm from 'Computer Graphics', Principles and
Practice */
-static inline GLint ClipLine1(GLfloat denom, GLfloat num, GLfloat* tmin, GLfloat* tmax) {
+static GLint ClipLine1(GLfloat denom, GLfloat num, GLfloat* tmin, GLfloat* tmax) {
GLfloat t;
if (denom > 0) {
@@ -165,9 +139,10 @@
return 0;
return 1;
}
-void gl_draw_line(GLVertex* p1, GLVertex* p2) {GLContext* c = gl_get_context();
+void gl_draw_line(GLVertex* p1, GLVertex* p2) {
+ GLContext* c = gl_get_context();
GLfloat dx, dy, dz, dw, x1, y1, z1, w1;
-
+
GLVertex q1, q2;
GLint cc1, cc2;
@@ -178,15 +153,9 @@
#if TGL_FEATURE_ALT_RENDERMODES == 1
if (c->render_mode == GL_SELECT) {
gl_add_select1(p1->zp.z, p2->zp.z, p2->zp.z);
- }else if (c->render_mode == GL_FEEDBACK){
- gl_add_feedback(
- GL_LINE_TOKEN,
- p1,
- p2,
- NULL,
- 0
- );
- } else
+ } else if (c->render_mode == GL_FEEDBACK) {
+ gl_add_feedback(GL_LINE_TOKEN, p1, p2, NULL, 0);
+ } else
#endif
{
if (c->zb->depth_test)
@@ -218,15 +187,9 @@
#if TGL_FEATURE_ALT_RENDERMODES == 1
if (c->render_mode == GL_SELECT) {
gl_add_select1(q1.zp.z, q2.zp.z, q2.zp.z);
- }else if (c->render_mode == GL_FEEDBACK){
- gl_add_feedback(
- GL_LINE_TOKEN,
- &q1,
- &q2,
- NULL,
- 0
- );
- } else
+ } else if (c->render_mode == GL_FEEDBACK) {
+ gl_add_feedback(GL_LINE_TOKEN, &q1, &q2, NULL, 0);
+ } else
#endif
{
if (c->zb->depth_test)
@@ -238,23 +201,21 @@
}
}
-//inline void gl_draw_point(GLContext* c, GLVertex* p0);
/*Triangles*/
-static inline void updateTmp(GLVertex* q, GLVertex* p0, GLVertex* p1, GLfloat t) { //MARK: INLINED_IN_OG
+static void updateTmp(GLVertex* q, GLVertex* p0, GLVertex* p1, GLfloat t) {
GLContext* c = gl_get_context();
{
-
q->color.v[0] = p0->color.v[0] + (p1->color.v[0] - p0->color.v[0]) * t;
q->color.v[1] = p0->color.v[1] + (p1->color.v[1] - p0->color.v[1]) * t;
q->color.v[2] = p0->color.v[2] + (p1->color.v[2] - p0->color.v[2]) * t;
}
-
+
#if TGL_OPTIMIZATION_HINT_BRANCH_COST < 1
- if (c->texture_2d_enabled)
+ if (c->texture_2d_enabled)
#endif
{
q->tex_coord.X = p0->tex_coord.X + (p1->tex_coord.X - p0->tex_coord.X) * t;
@@ -265,12 +226,12 @@
if (q->clip_code == 0)
gl_transform_to_viewport_clip_c(q);
}
-//DO NOT INLINE!!! DO NOT INLINE!!! DO NOT INLINE!!!
-static void gl_draw_triangle_clip(GLVertex* p0, GLVertex* p1, GLVertex* p2, GLint clip_bit);//MARK: NOT_INLINED_IN_OG
-void gl_draw_triangle(GLVertex* p0, GLVertex* p1, GLVertex* p2) {GLContext* c = gl_get_context();
+static void gl_draw_triangle_clip(GLVertex* p0, GLVertex* p1, GLVertex* p2, GLint clip_bit);
+
+void gl_draw_triangle(GLVertex* p0, GLVertex* p1, GLVertex* p2) {
+ GLContext* c = gl_get_context();
GLint co, cc[3], front;
-
cc[0] = p0->clip_code;
cc[1] = p1->clip_code;
@@ -283,11 +244,11 @@
GLfloat norm;
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) //MARK <POSSIBLE_PERF_BONUS>
+ if (norm == 0)
return;
front = norm < 0.0;
- front = front ^ c->current_front_face; //I don't know how this works, but it does, GL_CCW is 0x901 and CW is 900.
+ front = front ^ c->current_front_face;
/* back face culling */
if (c->cull_face_enabled) {
@@ -312,21 +273,19 @@
}
}
} else {
- //GLint c_and = cc[0] & cc[1] & cc[2];
- if ((cc[0] & cc[1] & cc[2]) == 0) { // Don't draw a triangle with no points
+ /* GLint c_and = cc[0] & cc[1] & cc[2];*/
+ if ((cc[0] & cc[1] & cc[2]) == 0) { /* Don't draw a triangle with no points*/
gl_draw_triangle_clip(p0, p1, p2, 0);
}
}
}
-
static void gl_draw_triangle_clip(GLVertex* p0, GLVertex* p1, GLVertex* p2, GLint clip_bit) {
- //GLContext* c = gl_get_context();
+
GLint co, c_and, co1, cc[3], edge_flag_tmp, clip_mask;
- //GLVertex tmp1, tmp2, *q[3];
- GLVertex *q[3];
+
+ GLVertex* q[3];
-
cc[0] = p0->clip_code;
cc[1] = p1->clip_code;
cc[2] = p2->clip_code;
@@ -335,7 +294,7 @@
if (co == 0) {
gl_draw_triangle(p0, p1, p2);
} else {
-
+
c_and = cc[0] & cc[1] & cc[2];
/* the triangle is completely outside */
if (c_and != 0)
@@ -347,7 +306,7 @@
}
/* this test can be true only in case of rounding errors */
- if (clip_bit == 6) { //The 2 bit and the 4 bit.
+ if (clip_bit == 6) { /* The 2 bit and the 4 bit.*/
#if 0
tgl_warning("Error:\n");tgl_warning("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);tgl_warning("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);tgl_warning("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
#endif
@@ -359,7 +318,7 @@
if (co1) {
/* one point outside */
-
+
if (cc[0] & clip_mask) {
q[0] = p0;
q[1] = p1;
@@ -373,7 +332,9 @@
q[1] = p0;
q[2] = p1;
}
- {GLVertex tmp1, tmp2;GLfloat tt;
+ {
+ GLVertex tmp1, tmp2;
+ GLfloat tt;
tt = clip_proc[clip_bit](&tmp1.pc, &q[0]->pc, &q[1]->pc);
updateTmp(&tmp1, q[0], q[1], tt);
@@ -392,7 +353,7 @@
}
} else {
/* two points outside */
-
+
if ((cc[0] & clip_mask) == 0) {
q[0] = p0;
q[1] = p1;
@@ -406,7 +367,9 @@
q[1] = p0;
q[2] = p1;
}
- {GLVertex tmp1, tmp2;GLfloat tt;
+ {
+ GLVertex tmp1, tmp2;
+ GLfloat tt;
tt = clip_proc[clip_bit](&tmp1.pc, &q[0]->pc, &q[1]->pc);
updateTmp(&tmp1, q[0], q[1], tt);
@@ -421,38 +384,22 @@
}
}
+/* see vertex.c to see how the draw functions are assigned.*/
+void gl_draw_triangle_select(GLVertex* p0, GLVertex* p1, GLVertex* p2) { gl_add_select1(p0->zp.z, p1->zp.z, p2->zp.z); }
+void gl_draw_triangle_feedback(GLVertex* p0, GLVertex* p1, GLVertex* p2) { gl_add_feedback(GL_POLYGON_TOKEN, p0, p1, p2, 0); }
-
-
-
-
-
-//see vertex.c to see how the draw functions are assigned.
-void gl_draw_triangle_select(GLVertex* p0, GLVertex* p1, GLVertex* p2) {
- gl_add_select1(p0->zp.z, p1->zp.z, p2->zp.z);
-}
-void gl_draw_triangle_feedback(GLVertex* p0, GLVertex* p1, GLVertex* p2){
- gl_add_feedback(
- GL_POLYGON_TOKEN,
- p0,
- p1,
- p2,
- 0
- );
-}
-
#ifdef PROFILE
int count_triangles, count_triangles_textured, count_pixels;
#warning "Compile with PROFILE slows down everything"
#endif
-//see vertex.c to see how the draw functions are assigned.
-void gl_draw_triangle_fill( GLVertex* p0, GLVertex* p1, GLVertex* p2) { //Must be function pointer!
+/* see vertex.c to see how the draw functions are assigned.*/
+void gl_draw_triangle_fill(GLVertex* p0, GLVertex* p1, GLVertex* p2) {
GLContext* c = gl_get_context();
if (c->texture_2d_enabled) {
- //if(c->current_texture)
+ /* if(c->current_texture)*/
#if TGL_FEATURE_LIT_TEXTURES == 1
- if(c->current_shade_model != GL_SMOOTH){
+ if (c->current_shade_model != GL_SMOOTH) {
p1->zp.r = p2->zp.r;
p1->zp.g = p2->zp.g;
p1->zp.b = p2->zp.b;
@@ -463,34 +410,29 @@
}
#endif
-//#ifdef PROFILE
-// count_triangles_textured++;
-//#endif
- ZB_setTexture(c->zb, c->current_texture->images[0].pixmap);
+ ZB_setTexture(c->zb, c->current_texture->images[0].pixmap);
#if TGL_FEATURE_BLEND == 1
- if(c->zb->enable_blend)
- ZB_fillTriangleMappingPerspective(c->zb, &p0->zp, &p1->zp, &p2->zp);
- else
- ZB_fillTriangleMappingPerspectiveNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
-#else
+ if (c->zb->enable_blend)
+ ZB_fillTriangleMappingPerspective(c->zb, &p0->zp, &p1->zp, &p2->zp);
+ else
ZB_fillTriangleMappingPerspectiveNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
+#else
+ ZB_fillTriangleMappingPerspectiveNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
#endif
} else if (c->current_shade_model == GL_SMOOTH) {
- //ZB_fillTriangleSmooth(c->zb, &p0->zp, &p1->zp, &p2->zp);
#if TGL_FEATURE_BLEND == 1
- if(c->zb->enable_blend)
+ if (c->zb->enable_blend)
ZB_fillTriangleSmooth(c->zb, &p0->zp, &p1->zp, &p2->zp);
- else
+ else
ZB_fillTriangleSmoothNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
#else
ZB_fillTriangleSmoothNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
#endif
} else {
- //ZB_fillTriangleFlat(c->zb, &p0->zp, &p1->zp, &p2->zp);
#if TGL_FEATURE_BLEND == 1
- if(c->zb->enable_blend)
+ if (c->zb->enable_blend)
ZB_fillTriangleFlat(c->zb, &p0->zp, &p1->zp, &p2->zp);
- else
+ else
ZB_fillTriangleFlatNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
#else
ZB_fillTriangleFlatNOBLEND(c->zb, &p0->zp, &p1->zp, &p2->zp);
--- a/src/error_check.h
+++ b/src/error_check.h
@@ -1,42 +1,40 @@
-//Error check #included into every command which references the current context as "c"
+
#ifndef RETVAL
#define RETVAL /* a comment*/
#endif
-
#if TGL_FEATURE_ERROR_CHECK == 1
-//LEVEL 1 ERROR_CHECK
-//#error should never execute.
+#ifndef ERROR_FLAG
-#ifndef ERROR_FLAG
-//LEVEL 2 ERROR_FLAG
-//BEGIN LEVEL 3
#if TGL_FEATURE_STRICT_OOM_CHECKS == 1
- if(c->error_flag == GL_OUT_OF_MEMORY) return RETVAL;
+if (c->error_flag == GL_OUT_OF_MEMORY)
+ return RETVAL;
#endif
-//EOF LEVEL 3
+
#elif ERROR_FLAG != GL_OUT_OF_MEMORY
- {c->error_flag = ERROR_FLAG; return RETVAL;}
-//OUT OF MEMORY ELSE
+{
+ c->error_flag = ERROR_FLAG;
+ return RETVAL;
+}
+
#else
- {c->error_flag = GL_OUT_OF_MEMORY; return RETVAL;}
+{
+ c->error_flag = GL_OUT_OF_MEMORY;
+ return RETVAL;
+}
#endif
-//
+#endif
-//LEVEL 1 ERROR_CHECK
-#endif
-//^End of TGL_FEATURE_ERROR_CHECK, level 0
-//Cleanup
#undef RETVAL
#undef ERROR_FLAG
--- a/src/error_check_no_context.h
+++ b/src/error_check_no_context.h
@@ -3,20 +3,17 @@
#endif
#if TGL_FEATURE_ERROR_CHECK == 1
-
-//#error should never execute
+
+
#if TGL_FEATURE_STRICT_OOM_CHECKS == 1
- GLContext* c = gl_get_context();
- if(c->error_flag == GL_OUT_OF_MEMORY)
- return RETVAL;
+GLContext* c = gl_get_context();
+if (c->error_flag == GL_OUT_OF_MEMORY)
+ return RETVAL;
#elif defined(NEED_CONTEXT)
- GLContext* c = gl_get_context();
+GLContext* c = gl_get_context();
#endif
-
-
-
-#endif
+#endif
#undef RETVAL
#undef NEED_CONTEXT
--- a/src/font8x8_basic.h
+++ b/src/font8x8_basic.h
@@ -5,159 +5,153 @@
* License: Public Domain
*
* Based on:
- * // Summary: font8x8.h
- * // 8x8 monochrome bitmap fonts for rendering
- * //
- * // Author:
- * // Marcel Sondaar
- * // International Business Machines (public domain VGA fonts)
- * //
- * // License:
- * // Public Domain
+ * Summary: font8x8.h
+ * 8x8 monochrome bitmap fonts for rendering
+ *
+ * Author:
+ * Marcel Sondaar
+ * International Business Machines (public domain VGA fonts)
+ *
+ * License:
+ * Public Domain
*
* Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm
**/
-// Constant: font8x8_basic
-// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
-static GLbyte font8x8_basic[256][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
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
- {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
- {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
- {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
- {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
- {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
- {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
- {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
- {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
- {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
- {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
- {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
- {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
- {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
- {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
- {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
- {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
- {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
- {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
- {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
- {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
- {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
- {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
- {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
- {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
- {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;)
- {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
- {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
- {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
- {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
- {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
- {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
- {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
- {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
- {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
- {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
- {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
- {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
- {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
- {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
- {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
- {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
- {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
- {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
- {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
- {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
- {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
- {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
- {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
- {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
- {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
- {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
- {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
- {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
- {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
- {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
- {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
- {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
- {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
- {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
- {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
- {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
- {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
- {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
- {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
- {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
- {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
- {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
- {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
- {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
- {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
- {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
- {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
- {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
- {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
- {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
- {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
- {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
- {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
- {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
- {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
- {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
- {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
- {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
- {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
- {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
- {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
- {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
- {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007F
-//32 blank characters.
+static GLbyte font8x8_basic[256][8] = {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00},
+ {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00},
+ {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00},
+ {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00},
+ {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00},
+ {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00},
+ {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00},
+ {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00},
+ {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06},
+ {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00},
+ {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00},
+ {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00},
+ {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00},
+ {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00},
+ {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00},
+ {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00},
+ {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00},
+ {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00},
+ {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00},
+ {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00},
+ {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00},
+ {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06},
+ {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00},
+ {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00},
+ {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00},
+ {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00},
+ {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00},
+ {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00},
+ {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00},
+ {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00},
+ {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00},
+ {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00},
+ {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00},
+ {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00},
+ {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00},
+ {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00},
+ {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00},
+ {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00},
+ {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00},
+ {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00},
+ {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00},
+ {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00},
+ {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00},
+ {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00},
+ {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00},
+ {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00},
+ {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00},
+ {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00},
+ {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00},
+ {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00},
+ {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00},
+ {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00},
+ {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00},
+ {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
+ {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00},
+ {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00},
+ {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00},
+ {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00},
+ {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00},
+ {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00},
+ {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F},
+ {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00},
+ {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E},
+ {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00},
+ {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00},
+ {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00},
+ {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00},
+ {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F},
+ {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78},
+ {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00},
+ {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00},
+ {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00},
+ {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00},
+ {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00},
+ {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00},
+ {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00},
+ {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F},
+ {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00},
+ {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00},
+ {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},
+ {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00},
+ {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+
-
-
-
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0080
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
@@ -189,101 +183,102 @@
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A0 (no break space)
- { 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, // U+00A1 (inverted !)
- { 0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18}, // U+00A2 (dollarcents)
- { 0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00}, // U+00A3 (pound sterling)
- { 0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00}, // U+00A4 (currency mark)
- { 0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C}, // U+00A5 (yen)
- { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+00A6 (broken pipe)
- { 0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E}, // U+00A7 (paragraph)
- { 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A8 (diaeresis)
- { 0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C}, // U+00A9 (copyright symbol)
- { 0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00}, // U+00AA (superscript a)
- { 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00}, // U+00AB (<<)
- { 0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00}, // U+00AC (gun pointing left)
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AD (soft hyphen)
- { 0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C}, // U+00AE (registered symbol)
- { 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AF (macron)
- { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B0 (degree)
- { 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00}, // U+00B1 (plusminus)
- { 0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 2)
- { 0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 3)
- { 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00B2 (aigu)
- { 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03}, // U+00B5 (mu)
- { 0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00}, // U+00B6 (pilcrow)
- { 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, // U+00B7 (central dot)
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E}, // U+00B8 (cedille)
- { 0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B9 (superscript 1)
- { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00BA (superscript 0)
- { 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00}, // U+00BB (>>)
- { 0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03}, // U+00BC (1/4)
- { 0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0}, // U+00BD (1/2)
- { 0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80}, // U+00BE (3/4)
- { 0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00}, // U+00BF (inverted ?)
- { 0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C0 (A grave)
- { 0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C1 (A aigu)
- { 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C2 (A circumflex)
- { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C3 (A ~)
- { 0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00}, // U+00C4 (A umlaut)
- { 0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00}, // U+00C5 (A ring)
- { 0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00}, // U+00C6 (AE)
- { 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E}, // U+00C7 (C cedille)
- { 0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C8 (E grave)
- { 0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C9 (E aigu)
- { 0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CA (E circumflex)
- { 0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CB (E umlaut)
- { 0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CC (I grave)
- { 0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CD (I aigu)
- { 0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CE (I circumflex)
- { 0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CF (I umlaut)
- { 0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00}, // U+00D0 (Eth)
- { 0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00}, // U+00D1 (N ~)
- { 0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D2 (O grave)
- { 0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D3 (O aigu)
- { 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D4 (O circumflex)
- { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00}, // U+00D5 (O ~)
- { 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00}, // U+00D6 (O umlaut)
- { 0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00}, // U+00D7 (multiplicative x)
- { 0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00}, // U+00D8 (O stroke)
- { 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00D9 (U grave)
- { 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DA (U aigu)
- { 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DB (U circumflex)
- { 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+00DC (U umlaut)
- { 0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00}, // U+00DD (Y aigu)
- { 0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+00DE (Thorn)
- { 0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03}, // U+00DF (beta)
- { 0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E0 (a grave)
- { 0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E1 (a aigu)
- { 0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00}, // U+00E2 (a circumflex)
- { 0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E3 (a ~)
- { 0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E4 (a umlaut)
- { 0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E5 (a ring)
- { 0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00}, // U+00E6 (ae)
- { 0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C}, // U+00E7 (c cedille)
- { 0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E8 (e grave)
- { 0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E9 (e aigu)
- { 0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00}, // U+00EA (e circumflex)
- { 0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00EB (e umlaut)
- { 0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EC (i grave)
- { 0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00ED (i augu)
- { 0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00}, // U+00EE (i circumflex)
- { 0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EF (i umlaut)
- { 0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00}, // U+00F0 (eth)
- { 0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00}, // U+00F1 (n ~)
- { 0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F2 (o grave)
- { 0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F3 (o aigu)
- { 0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F4 (o circumflex)
- { 0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F5 (o ~)
- { 0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F6 (o umlaut)
- { 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00}, // U+00F7 (division)
- { 0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06}, // U+00F8 (o stroke)
- { 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00F9 (u grave)
- { 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FA (u aigu)
- { 0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FB (u circumflex)
- { 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FC (u umlaut)
- { 0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+00FD (y aigu)
- { 0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00}, // U+00FE (thorn)
- { 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F} // U+00FF (y umlaut)
-
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00},
+ {0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18},
+ {0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00},
+ {0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00},
+ {0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C},
+ {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},
+ {0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E},
+ {0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C},
+ {0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C},
+ {0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00},
+ {0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00},
+ {0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00},
+ {0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00},
+ {0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03},
+ {0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00},
+ {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E},
+ {0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00},
+ {0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00},
+ {0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03},
+ {0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0},
+ {0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80},
+ {0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00},
+ {0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00},
+ {0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00},
+ {0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00},
+ {0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00},
+ {0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00},
+ {0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00},
+ {0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00},
+ {0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E},
+ {0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00},
+ {0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00},
+ {0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00},
+ {0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00},
+ {0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00},
+ {0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00},
+ {0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00},
+ {0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00},
+ {0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00},
+ {0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00},
+ {0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00},
+ {0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00},
+ {0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00},
+ {0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00},
+ {0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00},
+ {0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00},
+ {0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00},
+ {0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00},
+ {0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F},
+ {0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03},
+ {0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00},
+ {0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00},
+ {0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00},
+ {0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00},
+ {0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00},
+ {0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00},
+ {0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00},
+ {0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C},
+ {0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00},
+ {0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00},
+ {0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00},
+ {0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00},
+ {0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00},
+ {0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00},
+ {0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00},
+ {0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00},
+ {0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00},
+ {0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00},
+ {0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06},
+ {0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00},
+ {0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00},
+ {0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00},
+ {0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00},
+ {0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F},
+ {0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00},
+ {0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F}
+
};
--- a/src/get.c
+++ b/src/get.c
@@ -1,179 +1,178 @@
#include "msghandling.h"
#include "zgl.h"
-
#define xstr(s) str(s)
#define str(s) #s
-//Including this
+
const GLubyte* license_string = (const GLubyte*)""
-"Copyright notice:\n"
-"\n"
-" (C) 1997-2021 Fabrice Bellard, Gek (DMHSW), C-Chads\n"
-"\n"
-" This software is provided 'as-is', without any express or implied\n"
-" warranty. In no event will the authors be held liable for any damages\n"
-" arising from the use of this software.\n"
-"\n"
-" Permission is granted to anyone to use this software for any purpose,\n"
-" including commercial applications, and to alter it and redistribute it\n"
-" freely, subject to the following restrictions:\n"
-"\n"
-" 1. The origin of this software must not be misrepresented; you must not\n"
-" claim that you wrote the original software. If you use this software\n"
-" in a product, an acknowledgment in the product and its documentation \n"
-" *is* required.\n"
-" 2. Altered source versions must be plainly marked as such, and must not be\n"
-" misrepresented as being the original software.\n"
-" 3. This notice may not be removed or altered from any source distribution.\n"
-"\n"
-"If you redistribute modified sources, I would appreciate that you\n"
-"include in the files history information documenting your changes.";
+ "Copyright notice:\n"
+ "\n"
+ " (C) 1997-2021 Fabrice Bellard, Gek (DMHSW), C-Chads\n"
+ "\n"
+ " This software is provided 'as-is', without any express or implied\n"
+ " warranty. In no event will the authors be held liable for any damages\n"
+ " arising from the use of this software.\n"
+ "\n"
+ " Permission is granted to anyone to use this software for any purpose,\n"
+ " including commercial applications, and to alter it and redistribute it\n"
+ " freely, subject to the following restrictions:\n"
+ "\n"
+ " 1. The origin of this software must not be misrepresented; you must not\n"
+ " claim that you wrote the original software. If you use this software\n"
+ " in a product, an acknowledgment in the product and its documentation \n"
+ " *is* required.\n"
+ " 2. Altered source versions must be plainly marked as such, and must not be\n"
+ " misrepresented as being the original software.\n"
+ " 3. This notice may not be removed or altered from any source distribution.\n"
+ "\n"
+ "If you redistribute modified sources, I would appreciate that you\n"
+ "include in the files history information documenting your changes.";
const GLubyte* vendor_string = (const GLubyte*)"Fabrice Bellard, Gek, and the C-Chads";
const GLubyte* renderer_string = (const GLubyte*)"TinyGL";
-const GLubyte* version_string = (const GLubyte*)""
-xstr(TINYGL_VERSION)
-" TinyGLv"
-xstr(TINYGL_VERSION)
-" "
+const GLubyte* version_string = (const GLubyte*)"" xstr(TINYGL_VERSION) " TinyGLv" xstr(TINYGL_VERSION) " "
#ifdef __GNUC__
-"Compiled using GCC "
-__VERSION__
+ "Compiled using GCC " __VERSION__
#endif
#ifdef __TINYC__
-"Compiled using Tiny C Compiler "
-xstr(__TINYC__)
+ "Compiled using Tiny C Compiler " xstr(__TINYC__)
#endif
#ifdef _MSVC_VER
-"Compiled using the worst compiler on earth, M$VC. "
+ "Compiled using the worst compiler on earth, M$VC. "
#endif
#ifdef __clang__
-"Compiled Using Clang "
-__clang_version__
+ "Compiled Using Clang " __clang_version__
#endif
-;
-const GLubyte* extensions_string = (const GLubyte*)"TGL_TEXTURE "
-"TGL_SMOOTHSHADING "
-"TGL_LIGHTING "
-"TGL_OPTIMIZATION_HINT_BRANCH_COST=" xstr(TGL_OPTIMIZATION_HINT_BRANCH_COST) " "
+ ;
+const GLubyte* extensions_string =
+ (const GLubyte*)"TGL_TEXTURE "
+ "TGL_SMOOTHSHADING "
+ "TGL_LIGHTING "
+ "TGL_OPTIMIZATION_HINT_BRANCH_COST=" xstr(
+ TGL_OPTIMIZATION_HINT_BRANCH_COST) " "
#if TGL_FEATURE_ERROR_CHECK == 1
-"TGL_FEATURE_ERROR_CHECK "
-#endif
+ "TGL_FEATURE_ERROR_CHECK "
+#endif
#if TGL_FEATURE_STRICT_OOM_CHECKS == 1
-"TGL_FEATURE_STRICT_OOM_CHECKS "
+ "TGL_FEATURE_STRICT_OOM_CHECKS "
#endif
#if TGL_FEATURE_CUSTOM_MALLOC == 1
-"TGL_FEATURE_CUSTOM_MALLOC "
-#endif
+ "TGL_FEATURE_CUSTOM_MALLOC "
+#endif
#if TGL_FEATURE_FISR == 1
-"TGL_FEATURE_FISR "
-#endif
+ "TGL_FEATURE_FISR "
+#endif
#if TGL_FEATURE_ARRAYS == 1
-"TGL_FEATURE_ARRAYS "
+ "TGL_FEATURE_ARRAYS "
#endif
#if TGL_FEATURE_DISPLAYLISTS == 1
-"TGL_FEATURE_DISPLAYLISTS "
+ "TGL_FEATURE_DISPLAYLISTS "
#endif
#if ZB_POINT_T_FRAC_BITS == (ZB_POINT_S_FRAC_BITS + TGL_FEATURE_TEXTURE_POW2)
-"TGL_FEATURE_OPTIMIZED_TEXTURE_ACCESS "
+ "TGL_FEATURE_OPTIMIZED_TEXTURE_ACCESS "
#endif
-"TGL_FEATURE_TEXTURE_POW2=" xstr(TGL_FEATURE_TEXTURE_POW2) " "
+ "TGL_FEATURE_TEXTURE_POW2=" xstr(
+ TGL_FEATURE_TEXTURE_POW2) " "
#if TGL_FEATURE_LIT_TEXTURES == 1
-"TGL_FEATURE_LIT_TEXTURES "
+ "TGL_FEATURE_LIT_TEXTURES "
#endif
#if TGL_FEATURE_SPECULAR_BUFFERS == 1
-"TGL_FEATURE_SPECULAR_BUFFERS "
-#endif
+ "TGL_FEATURE_SPECULAR_BUFFERS "
+#endif
#if TGL_FEATURE_POLYGON_OFFSET == 1
-"TGL_FEATURE_POLYGON_OFFSET "
+ "TGL_FEATURE_POLYGON_OFFSET "
#endif
#if TGL_FEATURE_POLYGON_STIPPLE == 1
-"TGL_FEATURE_POLYGON_STIPPLE "
+ "TGL_FEATURE_POLYGON_STIPPLE "
#endif
#if TGL_FEATURE_GL_POLYGON == 1
-"TGL_FEATURE_GL_POLYGON "
+ "TGL_FEATURE_GL_POLYGON "
#endif
-
-
#if TGL_FEATURE_BLEND == 1
-"TGL_FEATURE_BLEND "
+ "TGL_FEATURE_BLEND "
#endif
#if TGL_FEATURE_BLEND_DRAW_PIXELS == 1
-"TGL_FEATURE_BLEND_DRAW_PIXELS "
+ "TGL_FEATURE_BLEND_DRAW_PIXELS "
#endif
#if TGL_FEATURE_NO_DRAW_COLOR == 1
-"TGL_FEATURE_NO_DRAW_COLOR "
+ "TGL_FEATURE_NO_DRAW_COLOR "
#endif
#if TGL_FEATURE_NO_COPY_COLOR == 1
-"TGL_FEATURE_NO_COPY_COLOR "
+ "TGL_FEATURE_NO_COPY_COLOR "
#endif
#if TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR == 1
-"TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR "
+ "TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR "
#endif
#if TGL_FEATURE_16_BITS == 1
-"TGL_FEATURE_16_BITS "
+ "TGL_FEATURE_16_BITS "
#endif
#if TGL_FEATURE_32_BITS == 1
-"TGL_FEATURE_32_BITS "
+ "TGL_FEATURE_32_BITS "
#endif
#if COMPILETIME_TINYGL_COMPAT_TEST == 1
-"TGL_COMPILETIME_TINYGL_COMPAT_TEST "
+ "TGL_COMPILETIME_TINYGL_COMPAT_TEST "
#endif
#if TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST == 1
-"TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST "
+ "TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST "
#endif
#if defined(_OPENMP)
-"TGL_FEATURE_MULTI_THREADED "
-"TGL_FEATURE_MULTI_THREADED_POST_PROCESS "
+ "TGL_FEATURE_MULTI_THREADED "
+ "TGL_FEATURE_MULTI_THREADED_POST_PROCESS "
#if TGL_FEATURE_MULTITHREADED_DRAWPIXELS == 1
-"TGL_FEATURE_MULTITHREADED_DRAWPIXELS "
+ "TGL_FEATURE_MULTITHREADED_DRAWPIXELS "
#endif
#if TGL_FEATURE_MULTITHREADED_COPY_TEXIMAGE_2D == 1
-"TGL_FEATURE_MULTITHREADED_COPY_TEXIMAGE_2D "
+ "TGL_FEATURE_MULTITHREADED_COPY_TEXIMAGE_2D "
#endif
#if TGL_FEATURE_MULTITHREADED_ZB_COPYBUFFER == 1
-"TGL_FEATURE_MULTITHREADED_ZB_COPYBUFFER "
+ "TGL_FEATURE_MULTITHREADED_ZB_COPYBUFFER "
#endif
#else
-"TGL_FEATURE_SINGLE_THREADED "
+ "TGL_FEATURE_SINGLE_THREADED "
#endif
#if TGL_FEATURE_ALIGNAS
-"TGL_FEATURE_ALIGNAS "
+ "TGL_FEATURE_ALIGNAS "
#endif
-"TGL_BUFFER_EXT "
+ "TGL_BUFFER_EXT "
#if TGL_FEATURE_ALT_RENDERMODES
-"TGL_FEEDBACK "
-"TGL_SELECT "
+ "TGL_FEEDBACK "
+ "TGL_SELECT "
#endif
-"TGL_SOFTWARE_ACCELERATED";
-const GLubyte* glGetString(GLenum name){
- switch(name){
- case GL_VENDOR: return vendor_string;
- case GL_RENDERER: return renderer_string;
- case GL_VERSION: return version_string;
- case GL_EXTENSIONS: return extensions_string;
- case GL_LICENSE: return license_string;
+ "TGL_SOFTWARE_ACCELERATED";
+const GLubyte* glGetString(GLenum name) {
+ switch (name) {
+ case GL_VENDOR:
+ return vendor_string;
+ case GL_RENDERER:
+ return renderer_string;
+ case GL_VERSION:
+ return version_string;
+ case GL_EXTENSIONS:
+ return extensions_string;
+ case GL_LICENSE:
+ return license_string;
}
return NULL;
}
-//NOTE: You should never be prevented from retrieving values from the GL state, even in GL_OUT_OF_MEMORY
+
void glGetIntegerv(GLint pname, GLint* params) {
- GLint i;GLContext* c = gl_get_context();
+ GLint i;
+ GLContext* c = gl_get_context();
i = 0;
switch (pname) {
case GL_MAX_BUFFERS:
@@ -182,7 +181,7 @@
case GL_TEXTURE_HASH_TABLE_SIZE:
*params = TEXTURE_HASH_TABLE_SIZE;
break;
-
+
case GL_LIGHT15:
i++;
case GL_LIGHT14:
@@ -217,7 +216,7 @@
*params = c->lights[i].enabled;
break;
case GL_COLOR_ARRAY:
- *params = ((c->client_states & COLOR_ARRAY)!=0);
+ *params = ((c->client_states & COLOR_ARRAY) != 0);
break;
case GL_COLOR_ARRAY_SIZE:
*params = (c->color_array_size);
@@ -226,7 +225,7 @@
*params = c->color_array_stride;
break;
case GL_VERTEX_ARRAY:
- *params = ((c->client_states & VERTEX_ARRAY)!=0);
+ *params = ((c->client_states & VERTEX_ARRAY) != 0);
break;
case GL_VERTEX_ARRAY_SIZE:
*params = c->vertex_array_size;
@@ -235,7 +234,7 @@
*params = c->vertex_array_stride;
break;
case GL_TEXTURE_COORD_ARRAY:
- *params = ((c->client_states & TEXCOORD_ARRAY)!=0);
+ *params = ((c->client_states & TEXCOORD_ARRAY) != 0);
break;
case GL_TEXTURE_COORD_ARRAY_SIZE:
*params = c->texcoord_array_size;
@@ -244,7 +243,7 @@
*params = c->texcoord_array_stride;
break;
case GL_NORMAL_ARRAY:
- *params = ((c->client_states & NORMAL_ARRAY)!=0);
+ *params = ((c->client_states & NORMAL_ARRAY) != 0);
break;
case GL_NORMAL_ARRAY_STRIDE:
*params = c->normal_array_stride;
@@ -266,9 +265,9 @@
params[1] = c->polygon_mode_back;
break;
case GL_LIST_MODE:
- if(c->compile_flag && !c->exec_flag)
+ if (c->compile_flag && !c->exec_flag)
params[0] = GL_COMPILE;
- else if(c->exec_flag && c->compile_flag)
+ else if (c->exec_flag && c->compile_flag)
params[0] = GL_COMPILE_AND_EXECUTE;
else
params[0] = 0;
@@ -275,8 +274,8 @@
break;
case GL_LIST_BASE:
*params = c->listbase;
- break;
- case GL_LIST_INDEX: //TODO
+ break;
+ case GL_LIST_INDEX: /* TODO*/
params[0] = 0;
break;
case GL_TEXTURE_2D:
@@ -340,7 +339,7 @@
*params = 6;
break;
case GL_MATRIX_MODE:
- if(c->matrix_mode == 0)
+ if (c->matrix_mode == 0)
*params = GL_MODELVIEW;
else if (c->matrix_mode == 1)
*params = GL_PROJECTION;
@@ -367,7 +366,7 @@
case GL_TEXTURE_GEN_S:
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_Q:
-
+
case GL_STEREO:
case GL_PACK_SWAP_BYTES:
case GL_PACK_SKIP_ROWS:
@@ -388,7 +387,7 @@
params[1] = 4096;
break;
case GL_MAX_LIST_NESTING:
- *params = 2147483647; //No checking is done, indicate it to the user!
+ *params = ~(GLuint)0; /* No checking is done, indicate it to the user!*/
break;
case GL_STENCIL_FUNC:
*params = GL_ALWAYS;
@@ -457,10 +456,10 @@
case GL_PIXEL_MAP_G_TO_G_SIZE:
case GL_PIXEL_MAP_B_TO_B_SIZE:
case GL_PIXEL_MAP_A_TO_A_SIZE:
- *params = 0;
+ *params = 0;
break;
case GL_RGBA_MODE:
- *params = 1; //yes, even in 565 (it's what the spec says)
+ *params = 1; /* yes, even in 565 (it's what the spec says)*/
break;
case GL_VIEWPORT:
params[0] = c->viewport.xmin;
@@ -487,10 +486,10 @@
*params = 0;
#endif
break;
- //->zEnableSpecular
+
case GL_IS_SPECULAR_ENABLED:
*params = c->zEnableSpecular;
- break;
+ break;
case GL_MAX_MODELVIEW_STACK_DEPTH:
*params = MAX_MODELVIEW_STACK_DEPTH;
break;
@@ -512,7 +511,7 @@
#elif TGL_FEATURE_RENDER_BITS == 32
*params = 8;
#endif
- break;
+ break;
case GL_BLUE_BITS:
case GL_RED_BITS:
#if TGL_FEATURE_RENDER_BITS == 16
@@ -535,7 +534,7 @@
break;
case GL_POLYGON_SMOOTH:
*params = GL_FALSE;
- break;
+ break;
case GL_CULL_FACE_MODE:
*params = c->current_cull_face;
break;
@@ -557,9 +556,9 @@
case GL_EDGE_FLAG:
*params = c->current_edge_flag;
break;
- case GL_DOUBLEBUFFER:
- case GL_DITHER:
- *params = GL_FALSE;
+ case GL_DOUBLEBUFFER:
+ case GL_DITHER:
+ *params = GL_FALSE;
break;
case GL_DEPTH_TEST:
*params = (c->zb->depth_test == 1);
@@ -567,7 +566,7 @@
case GL_DEPTH_FUNC:
*params = GL_LESS;
break;
-
+
default:
tgl_warning("glGet: option not implemented");
#if TGL_FEATURE_ERROR_CHECK == 1
@@ -578,112 +577,111 @@
}
}
-
-
void glGetFloatv(GLint pname, GLfloat* v) {
- GLint i, mnr; GLContext* c;
+ GLint i, mnr;
+ GLContext* c;
mnr = 0; /* just a trick to return the correct matrix */
c = gl_get_context();
switch (pname) {
- case GL_BLUE_SCALE:
- case GL_RED_SCALE:
- case GL_GREEN_SCALE:
- case GL_ALPHA_SCALE:
- case GL_FOG_END:
- case GL_FOG_DENSITY:
- *v = 1;
- break;
- case GL_BLUE_BIAS:
- case GL_RED_BIAS:
- case GL_GREEN_BIAS:
- case GL_ALPHA_BIAS:
- case GL_FOG_START:
- *v = 0;
- break;
- case GL_DEPTH_SCALE:
- *v = 1;
- break;
- case GL_TEXTURE_MATRIX:
- mnr++;
- case GL_PROJECTION_MATRIX:
- mnr++;
- case GL_MODELVIEW_MATRIX: {
- GLfloat* 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 GL_LINE_WIDTH:
- *v = 1.0f;
- break;
- case GL_DEPTH_CLEAR_VALUE:
- *v = 1; //This is not entirely true, but... good enough?
- break;
- case GL_DEPTH_RANGE:
- v[0] = 0;
- v[1] = 1;
- break;
- case GL_DEPTH_BIAS:
- *v = 0;
- break;
- case GL_CURRENT_TEXTURE_COORDS:
- v[0] = c->current_tex_coord.X;
- v[1] = c->current_tex_coord.Y;
- v[2] = c->current_tex_coord.Z;
- v[3] = c->current_tex_coord.W;
- break;
- case GL_CURRENT_RASTER_POSITION:
- v[0] = c->rastervertex.pc.X;
- v[1] = c->rastervertex.pc.Y;
- v[2] = c->rastervertex.pc.Z;
- v[3] = c->rastervertex.pc.W;
- break;
- case GL_CURRENT_RASTER_DISTANCE:
- *v = c->rastervertex.ec.Z;
- break;
- case GL_LINE_WIDTH_RANGE:
- v[0] = v[1] = 1.0f;
- break;
- case GL_POINT_SIZE:
- //case GL_POINT_SIZE_MIN:
- //case GL_POINT_SIZE_MAX:
- *v = c->zb->pointsize;
- break;
- case GL_FOG_COLOR:
- v[0] = 0;
- v[1] = 0;
- v[2] = 0;
- v[3] = 0;
+ case GL_BLUE_SCALE:
+ case GL_RED_SCALE:
+ case GL_GREEN_SCALE:
+ case GL_ALPHA_SCALE:
+ case GL_FOG_END:
+ case GL_FOG_DENSITY:
+ *v = 1;
break;
- case GL_POINT_SIZE_GRANULARITY:
- *v = 1.0f; //if we ever implement AA'd points...
- break;
- case GL_POLYGON_OFFSET_FACTOR:
- *v = 0;
- break;
- case GL_POLYGON_OFFSET_UNITS:
- *v = 0;
- break;
- case GL_LIGHT_MODEL_AMBIENT:
- for (i = 0; i < 4; i++)
- v[i] = c->ambient_light_model.v[i];
+ case GL_BLUE_BIAS:
+ case GL_RED_BIAS:
+ case GL_GREEN_BIAS:
+ case GL_ALPHA_BIAS:
+ case GL_FOG_START:
+ *v = 0;
break;
- case GL_ZOOM_X:
- *v = c->pzoomx;
- break;
- case GL_ZOOM_Y:
- *v = c->pzoomy;
- break;
- case GL_POINT_SIZE_RANGE:
- v[0] = c->zb->pointsize;
- v[1] = c->zb->pointsize;
- break;
- default:
- tgl_warning("warning: unknown pname in glGetFloatv()\n");
- break;
+ case GL_DEPTH_SCALE:
+ *v = 1;
+ break;
+ case GL_TEXTURE_MATRIX:
+ mnr++;
+ case GL_PROJECTION_MATRIX:
+ mnr++;
+ case GL_MODELVIEW_MATRIX: {
+ GLfloat* 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 GL_LINE_WIDTH:
+ *v = 1.0f;
+ break;
+ case GL_DEPTH_CLEAR_VALUE:
+ *v = 1; /* This is not entirely true, but... good enough?*/
+ break;
+ case GL_DEPTH_RANGE:
+ v[0] = 0;
+ v[1] = 1;
+ break;
+ case GL_DEPTH_BIAS:
+ *v = 0;
+ break;
+ case GL_CURRENT_TEXTURE_COORDS:
+ v[0] = c->current_tex_coord.X;
+ v[1] = c->current_tex_coord.Y;
+ v[2] = c->current_tex_coord.Z;
+ v[3] = c->current_tex_coord.W;
+ break;
+ case GL_CURRENT_RASTER_POSITION:
+ v[0] = c->rastervertex.pc.X;
+ v[1] = c->rastervertex.pc.Y;
+ v[2] = c->rastervertex.pc.Z;
+ v[3] = c->rastervertex.pc.W;
+ break;
+ case GL_CURRENT_RASTER_DISTANCE:
+ *v = c->rastervertex.ec.Z;
+ break;
+ case GL_LINE_WIDTH_RANGE:
+ v[0] = v[1] = 1.0f;
+ break;
+ case GL_POINT_SIZE:
+ /* case GL_POINT_SIZE_MIN:*/
+ /* case GL_POINT_SIZE_MAX:*/
+ *v = c->zb->pointsize;
+ break;
+ case GL_FOG_COLOR:
+ v[0] = 0;
+ v[1] = 0;
+ v[2] = 0;
+ v[3] = 0;
+ break;
+ case GL_POINT_SIZE_GRANULARITY:
+ *v = 1.0f; /* if we ever implement AA'd points...*/
+ break;
+ case GL_POLYGON_OFFSET_FACTOR:
+ *v = 0;
+ break;
+ case GL_POLYGON_OFFSET_UNITS:
+ *v = 0;
+ break;
+ case GL_LIGHT_MODEL_AMBIENT:
+ for (i = 0; i < 4; i++)
+ v[i] = c->ambient_light_model.v[i];
+ break;
+ case GL_ZOOM_X:
+ *v = c->pzoomx;
+ break;
+ case GL_ZOOM_Y:
+ *v = c->pzoomy;
+ break;
+ case GL_POINT_SIZE_RANGE:
+ v[0] = c->zb->pointsize;
+ v[1] = c->zb->pointsize;
+ break;
+ default:
+ tgl_warning("warning: unknown pname in glGetFloatv()\n");
+ break;
}
}
--- a/src/image_util.c
+++ b/src/image_util.c
@@ -1,6 +1,5 @@
#include "zgl.h"
-//#warning STDIO INCLUDE!!! REMOVE!!!
-//#include <stdio.h>
+
/*
* image conversion
*/
@@ -17,8 +16,10 @@
}
}
-// This actually converts to ARGB!!!
-// This is the format of the entire engine!!!
+/*
+ This actually converts to ARGB!!!
+ This is the format of the entire engine!!!
+*/
void gl_convertRGB_to_8A8R8G8B(GLuint* pixmap, GLubyte* rgb, GLint xsize, GLint ysize) {
GLint i, n;
GLubyte* p;
@@ -38,7 +39,7 @@
#define INTERP_NORM_BITS 16
#define INTERP_NORM (1 << INTERP_NORM_BITS)
-static inline GLint GLinterpolate_imutil(GLint v00, GLint v01, GLint v10, GLint xf, GLint yf) {
+static GLint GLinterpolate_imutil(GLint v00, GLint v01, GLint v10, GLint xf, GLint yf) {
return v00 + (((v01 - v00) * xf + (v10 - v00) * yf) >> INTERP_NORM_BITS);
}
@@ -53,7 +54,7 @@
pix = dest;
pix_src = src;
-// puts("\nIn here\n");
+
x1inc = (GLfloat)(xsize_src - 1) / (GLfloat)(xsize_dest - 1);
y1inc = (GLfloat)(ysize_src - 1) / (GLfloat)(ysize_dest - 1);
@@ -69,7 +70,7 @@
if ((xf + yf) <= INTERP_NORM) {
for (j = 0; j < 3; j++) {
pix[j] = GLinterpolate_imutil(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);
+ pix_src[((yi + 1) * xsize_src + xi) * 3 + j], xf, yf);
}
} else {
xf = INTERP_NORM - xf;
@@ -76,7 +77,7 @@
yf = INTERP_NORM - yf;
for (j = 0; j < 3; j++) {
pix[j] = GLinterpolate_imutil(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);
+ pix_src[(yi * xsize_src + xi + 1) * 3 + j], xf, yf);
}
}
@@ -85,7 +86,7 @@
}
y1 += y1inc;
}
-// puts("\nNot here\n");
+
}
#define FRAC_BITS 16
--- a/src/init.c
+++ b/src/init.c
@@ -1,5 +1,5 @@
-#include "zgl.h"
#include "msghandling.h"
+#include "zgl.h"
GLContext gl_ctx;
static const GLContext empty_gl_ctx = {0};
@@ -6,13 +6,13 @@
static void initSharedState(GLContext* c) {
GLSharedState* s = &c->shared_state;
s->lists = gl_zalloc(sizeof(GLList*) * MAX_DISPLAY_LISTS);
- if(!s->lists)
+ if (!s->lists)
gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
s->texture_hash_table = gl_zalloc(sizeof(GLTexture*) * TEXTURE_HASH_TABLE_SIZE);
- if(!s->texture_hash_table)
+ if (!s->texture_hash_table)
gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
s->buffers = gl_zalloc(sizeof(GLBuffer*) * MAX_BUFFERS);
- if(!s->buffers)
+ if (!s->buffers)
gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
alloc_texture(0);
#include "error_check.h"
@@ -55,10 +55,9 @@
}
}
gl_free(s->texture_hash_table);
- for(i = 0; i < MAX_BUFFERS; i++){
- if(s->buffers[i])
- {
- if(s->buffers[i]->data){
+ for (i = 0; i < MAX_BUFFERS; i++) {
+ if (s->buffers[i]) {
+ if (s->buffers[i]->data) {
gl_free(s->buffers[i]->data);
}
gl_free(s->buffers[i]);
@@ -69,62 +68,91 @@
#if TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST == 1
-#define TGL_RUNT_UNION_CAST(i) ((union{GLuint l; GLint ii; GLfloat f;}){i})
-#define TGL_FLOAT_ERR(a,b) ((a-b)/b)
-static int TinyGLRuntimeCompatibilityTest(){
+#define TGL_RUNT_UNION_CAST(i) \
+ ((union { \
+ GLuint l; \
+ GLint ii; \
+ GLfloat f; \
+ }){i})
+#define TGL_FLOAT_ERR(a, b) ((a - b) / b)
+static int TinyGLRuntimeCompatibilityTest() {
GLfloat t = -0, tf2;
- GLint t2 = 1<<31;
- if(TGL_RUNT_UNION_CAST(t2).f != t)
+ GLint t2 = 1 << 31;
+ if (TGL_RUNT_UNION_CAST(t2).f != t)
return 1;
t2 = 3212836864;
t = -1;
- if(TGL_RUNT_UNION_CAST(t2).f != t)
+ if (TGL_RUNT_UNION_CAST(t2).f != t)
return 1;
- if(((GLint)255<<8) != 65280) return 1;
- if((GLint)65280>>8 != 255) return 1;
- if( ((GLint)-1)>>14 != -1 ) return 1;
- if(((GLuint)255<<8) != 65280) return 1;
- if((GLuint)65280>>8 != 255) return 1;
- if(((GLushort)255<<8) != 65280) return 1;
- if((GLushort)65280>>8 != 255) return 1;
- if(((GLshort)255<<8) != 65280) return 1;
- if((GLshort)65280>>8 != -1) return 1;
+ if (((GLint)255 << 8) != 65280)
+ return 1;
+ if ((GLint)65280 >> 8 != 255)
+ return 1;
+ if (((GLint)-1) >> 14 != -1)
+ return 1;
+ if (((GLuint)255 << 8) != 65280)
+ return 1;
+ if ((GLuint)65280 >> 8 != 255)
+ return 1;
+ if (((GLushort)255 << 8) != 65280)
+ return 1;
+ if ((GLushort)65280 >> 8 != 255)
+ return 1;
+ if (((GLshort)255 << 8) != 65280)
+ return 1;
+ if ((GLshort)65280 >> 8 != -1)
+ return 1;
#if TGL_FEATURE_FISR == 1
t = fastInvSqrt(37);
- tf2 = 1.0/sqrt(37);
- if(TGL_FLOAT_ERR(t,tf2) > 0.05) return 1;
+ tf2 = 1.0 / sqrt(37);
+ if (TGL_FLOAT_ERR(t, tf2) > 0.05)
+ return 1;
t = fastInvSqrt(59);
- tf2 = 1.0/sqrt(59);
- if(TGL_FLOAT_ERR(t,tf2) > 0.05) return 1;
+ tf2 = 1.0 / sqrt(59);
+ if (TGL_FLOAT_ERR(t, tf2) > 0.05)
+ return 1;
t = fastInvSqrt(1023);
- tf2 = 1.0/sqrt(1023);
- if(TGL_FLOAT_ERR(t,tf2) > 0.05) return 1;
+ tf2 = 1.0 / sqrt(1023);
+ if (TGL_FLOAT_ERR(t, tf2) > 0.05)
+ return 1;
t = fastInvSqrt(10000);
- tf2 = 1.0/sqrt(10000);
- if(TGL_FLOAT_ERR(t,tf2) > 0.05) return 1;
+ tf2 = 1.0 / sqrt(10000);
+ if (TGL_FLOAT_ERR(t, tf2) > 0.05)
+ return 1;
#endif
- {GLint i;
- GLuint buf1[10];GLuint buf2[10];
- for(i = 0; i < 10; i++) buf1[i] = (1023<<i) + i + i%-1;
- for(i = 0; i < 10; i++) buf2[i] = (14<<i) + i + i%-4;
- memcpy(buf1,buf2,10*4);
- for(i = 0; i < 10; i++) if(buf2[i] != buf1[i]) return 1;
+ {
+ GLint i;
+ GLuint buf1[10];
+ GLuint buf2[10];
+ for (i = 0; i < 10; i++)
+ buf1[i] = (1023 << i) + i + i % -1;
+ for (i = 0; i < 10; i++)
+ buf2[i] = (14 << i) + i + i % -4;
+ memcpy(buf1, buf2, 10 * 4);
+ for (i = 0; i < 10; i++)
+ if (buf2[i] != buf1[i])
+ return 1;
}
- if(sizeof(void*) < 4) return 1;
- //ZALLOC TEST
- {GLint i, j;
- for(i = 0; i < 10; i++){
- GLubyte* data = gl_zalloc(1024); //A kilobyte.
- if(!data) return 1;
- for(j = 0; j <1024; j++) if(data[j] != 0) return 1;
- gl_free(data);
- }}
+ if (sizeof(void*) < 4)
+ return 1;
+ /* ZALLOC TEST*/
+ {
+ GLint i, j;
+ for (i = 0; i < 10; i++) {
+ GLubyte* data = gl_zalloc(1024);
+ if (!data)
+ return 1;
+ for (j = 0; j < 1024; j++)
+ if (data[j] != 0)
+ return 1;
+ gl_free(data);
+ }
+ }
return 0;
}
#endif
-
void glInit(void* zbuffer1) {
GLContext* c;
GLViewport* v;
@@ -131,12 +159,14 @@
GLint i;
ZBuffer* zbuffer = (ZBuffer*)zbuffer1;
#if TGL_FEATURE_TINYGL_RUNTIME_COMPAT_TEST == 1
- if(TinyGLRuntimeCompatibilityTest()) gl_fatal_error("TINYGL_FAILED_RUNTIME_COMPAT_TEST");
+ if (TinyGLRuntimeCompatibilityTest())
+ gl_fatal_error("TINYGL_FAILED_RUNTIME_COMPAT_TEST");
#endif
gl_ctx = empty_gl_ctx;
c = &gl_ctx;
- if(!c) gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
-
+ if (!c)
+ gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
+
c->zb = zbuffer;
#if TGL_FEATURE_ERROR_CHECK == 1
c->error_flag = GL_NO_ERROR;
@@ -151,7 +181,7 @@
v->ymin = 0;
v->xsize = zbuffer->xsize;
v->ysize = zbuffer->ysize;
- gl_eval_viewport(c);
+ gl_eval_viewport();
/* buffer stuff GL 1.1 */
c->drawbuffer = GL_FRONT;
c->readbuffer = GL_FRONT;
@@ -160,11 +190,11 @@
/* ztext */
c->textsize = 1;
/* buffer */
- c->boundarraybuffer = 0;
+ c->boundarraybuffer = 0;
c->boundvertexbuffer = 0;
- c->boundcolorbuffer = 0;
- c->boundnormalbuffer = 0;
- c->boundtexcoordbuffer = 0;
+ c->boundcolorbuffer = 0;
+ c->boundnormalbuffer = 0;
+ c->boundtexcoordbuffer = 0;
/* lists */
c->exec_flag = 1;
@@ -243,7 +273,7 @@
c->current_cull_face = GL_BACK;
c->current_shade_model = GL_SMOOTH;
c->cull_face_enabled = 0;
-
+
#if TGL_FEATURE_POLYGON_STIPPLE == 1
c->zb->dostipple = 0;
for (GLint i = 0; i < 128; i++)
@@ -278,7 +308,8 @@
for (i = 0; i < 3; i++) {
c->matrix_stack[i] = gl_zalloc(c->matrix_stack_depth_max[i] * sizeof(M4));
- if (!(c->matrix_stack[i])) gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
+ if (!(c->matrix_stack[i]))
+ gl_fatal_error("TINYGL_CANNOT_INIT_OOM");
c->matrix_stack_ptr[i] = c->matrix_stack[i];
}
@@ -328,8 +359,8 @@
}
void glClose(void) {
-
- GLuint i;
+
+ GLuint i;
GLContext* c = gl_get_context();
for (i = 0; i < 3; i++) {
gl_free(c->matrix_stack[i]);
@@ -336,12 +367,13 @@
}
i = 0;
#if TGL_FEATURE_SPECULAR_BUFFERS == 1
- {GLSpecBuf*b,*n = NULL;
- for(b = c->specbuf_first; b != NULL; b = n) {
- n = b->next;
- gl_free(b);
- i++;
- }
+ {
+ GLSpecBuf *b, *n = NULL;
+ for (b = c->specbuf_first; b != NULL; b = n) {
+ n = b->next;
+ gl_free(b);
+ i++;
+ }
}
#endif
endSharedState(c);
--- a/src/light.c
+++ b/src/light.c
@@ -1,8 +1,6 @@
#include "msghandling.h"
#include "zgl.h"
-
-
void glopMaterial(GLParam* p) {
GLContext* c = gl_get_context();
GLint mode = p[1].i;
@@ -28,19 +26,19 @@
switch (type) {
case GL_EMISSION:
for (i = 0; i < 4; i++)
- m->emission.v[i] = clampf(v[i],0,1);
+ m->emission.v[i] = clampf(v[i], 0, 1);
break;
case GL_AMBIENT:
for (i = 0; i < 4; i++)
- m->ambient.v[i] = clampf(v[i],0,1);
+ m->ambient.v[i] = clampf(v[i], 0, 1);
break;
case GL_DIFFUSE:
for (i = 0; i < 4; i++)
- m->diffuse.v[i] = clampf(v[i],0,1);
+ m->diffuse.v[i] = clampf(v[i], 0, 1);
break;
case GL_SPECULAR:
for (i = 0; i < 4; i++)
- m->specular.v[i] = clampf(v[i],0,1);
+ m->specular.v[i] = clampf(v[i], 0, 1);
break;
case GL_SHININESS:
m->shininess = v[0];
@@ -50,18 +48,18 @@
break;
case GL_AMBIENT_AND_DIFFUSE:
for (i = 0; i < 4; i++)
- m->diffuse.v[i] = clampf(v[i],0,1);
+ m->diffuse.v[i] = clampf(v[i], 0, 1);
for (i = 0; i < 4; i++)
- m->ambient.v[i] = clampf(v[i],0,1);
+ m->ambient.v[i] = clampf(v[i], 0, 1);
break;
-
+
#if TGL_FEATURE_ERROR_CHECK == 1
default:
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //default: return;
+ /* default: return;*/
#endif
}
}
@@ -83,24 +81,23 @@
GLLight* l;
GLint i;
- //assert(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS);
+ /* assert(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS);*/
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS))
+ if (!(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS))
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
-// if(!(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS)) return;
+/* if(!(light >= GL_LIGHT0 && light < GL_LIGHT0 + MAX_LIGHTS)) return;*/
#endif
- l = &c->lights[light - GL_LIGHT0];
+ l = &c->lights[light - GL_LIGHT0];
for (i = 0; i < 4; i++)
- if(type != GL_POSITION && type != GL_SPOT_DIRECTION && type != GL_SPOT_EXPONENT &&
- type != GL_SPOT_CUTOFF &&
- type != GL_LINEAR_ATTENUATION && type != GL_CONSTANT_ATTENUATION && type != GL_QUADRATIC_ATTENUATION)
- v.v[i] = clampf(p[3 + i].f,0,1);
+ if (type != GL_POSITION && type != GL_SPOT_DIRECTION && type != GL_SPOT_EXPONENT && type != GL_SPOT_CUTOFF && type != GL_LINEAR_ATTENUATION &&
+ type != GL_CONSTANT_ATTENUATION && type != GL_QUADRATIC_ATTENUATION)
+ v.v[i] = clampf(p[3 + i].f, 0, 1);
else
v.v[i] = p[3 + i].f;
@@ -124,7 +121,7 @@
l->norm_position.X = pos.X;
l->norm_position.Y = pos.Y;
l->norm_position.Z = pos.Z;
- //gl_V3_Norm(&l->norm_position);
+ /* gl_V3_Norm(&l->norm_position);*/
gl_V3_Norm_Fast(&l->norm_position);
}
} break;
@@ -145,7 +142,7 @@
#define ERROR_FLAG GL_INVALID_VALUE
#include "error_check.h"
#else
- //assert(a == 180 || (a >= 0 && a <= 90));
+ /* assert(a == 180 || (a >= 0 && a <= 90));*/
#endif
l->spot_cutoff = a;
@@ -170,7 +167,7 @@
}
}
-void glopLightModel( GLParam* p) {
+void glopLightModel(GLParam* p) {
GLContext* c = gl_get_context();
GLint pname = p[1].i;
GLint* v = &p[2].i;
@@ -192,27 +189,23 @@
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#endif
-// tgl_warning("glopLightModel: illegal pname: 0x%x\n", pname);
- // assert(0);
+ /*
+ tgl_warning("glopLightModel: illegal pname: 0x%x\n", pname);
+ assert(0);
+ */
break;
}
}
-
-
void gl_enable_disable_light(GLint light, GLint v) {
GLContext* c = gl_get_context();
GLLight* l = &c->lights[light];
- //l->enabled = v; //If you don't want the linked list.
-
if (v && !l->enabled) {
- //Push this light onto the front of the linked list.
l->enabled = 1;
l->next = c->first_light;
c->first_light = l;
l->prev = NULL;
} else if (!v && l->enabled) {
- //Pop this light out of the linked list.
l->enabled = 0;
if (l->prev == NULL)
c->first_light = l->next;
@@ -223,8 +216,8 @@
}
}
-// FEATURES
-void glSetEnableSpecular(GLint s){
+
+void glSetEnableSpecular(GLint s) {
GLParam p[2];
#include "error_check_no_context.h"
p[1].i = s;
@@ -231,9 +224,9 @@
p[0].op = OP_SetEnableSpecular;
gl_add_op(p);
}
-void glopSetEnableSpecular(GLParam* p){
- //tgl_warning("\nBeing Called!\n");
- gl_get_context()->zEnableSpecular = p[1].i;
+void glopSetEnableSpecular(GLParam* p) {
+
+ gl_get_context()->zEnableSpecular = p[1].i;
}
/* non optimized lightening model */
void gl_shade_vertex(GLVertex* v) {
@@ -242,7 +235,7 @@
GLMaterial* m;
GLLight* l;
V3 n, s, d;
- GLfloat dist, tmp, att, dot, dot_spot, dot_spec;
+ GLfloat dist=0, tmp, att, dot, dot_spot, dot_spec;
GLint twoside = c->light_model_two_side;
m = &c->materials[0];
@@ -254,12 +247,12 @@
R = m->emission.v[0] + m->ambient.v[0] * c->ambient_light_model.v[0];
G = m->emission.v[1] + m->ambient.v[1] * c->ambient_light_model.v[1];
B = m->emission.v[2] + m->ambient.v[2] * c->ambient_light_model.v[2];
- A = m->diffuse.v[3];
-//LINKED LIST LOOP
+ A = m->diffuse.v[3];
+
for (l = c->first_light; l != NULL; l = l->next) {
-//VECTOR LINEAR SEARCH LOOP
-//for(GLuint i = 0; i < MAX_LIGHTS; i++)
-// if(c->lights[i].enabled){ l = c->lights+i;
+
+
+
GLfloat lR, lB, lG;
/* ambient */
@@ -269,7 +262,7 @@
if (l->position.v[3] == 0) {
/* light at infinity */
- // Fixed by Gek, it used to use the unnormalized position?
+ /* Fixed by Gek, it used to use the unnormalized position?*/
d.X = l->norm_position.v[0];
d.Y = l->norm_position.v[1];
d.Z = l->norm_position.v[2];
@@ -280,7 +273,7 @@
d.Y = l->position.v[1] - v->ec.v[1];
d.Z = l->position.v[2] - v->ec.v[2];
#if TGL_FEATURE_FISR == 1
- tmp = fastInvSqrt(d.X * d.X + d.Y * d.Y + d.Z * d.Z); //FISR IMPL, MATCHED!
+ tmp = fastInvSqrt(d.X * d.X + d.Y * d.Y + d.Z * d.Z); /* FISR IMPL, MATCHED!*/
{
d.X *= tmp;
d.Y *= tmp;
@@ -288,7 +281,6 @@
}
#else
dist = sqrt(d.X * d.X + d.Y * d.Y + d.Z * d.Z);
- //dist = 1.0f/tmp;
if (dist > 1E-3) {
tmp = 1 / dist;
d.X *= tmp;
@@ -321,8 +313,8 @@
att = att * pow(dot_spot, l->spot_exponent);
}
}
- // GEK SAYS TO REMOVE THIS
- // printf("\nThis should not be being called.");
+
+
}
/* specular light */
@@ -332,18 +324,18 @@
vcoord.X = v->ec.X;
vcoord.Y = v->ec.Y;
vcoord.Z = v->ec.Z;
- //gl_V3_Norm(&vcoord);
+
gl_V3_Norm_Fast(&vcoord);
s.X = d.X - vcoord.X;
s.Y = d.Y - vcoord.X;
s.Z = d.Z - vcoord.X;
} else {
- //BLINN-PHONG SHADING: We're doing lighting calculations in Eye coordinates, this is ViewDir + LightDir
- s.X = d.X; //+0.0
- s.Y = d.Y; //+0.0
- s.Z = d.Z - 1.0;
+
+ s.X = d.X;
+ s.Y = d.Y;
+ s.Z = d.Z - 1.0;
}
- //dot_spec is dot(surfaceNormal, H)
+
dot_spec = n.X * s.X + n.Y * s.Y + n.Z * s.Z;
if (twoside && dot_spec < 0)
dot_spec = -dot_spec;
@@ -354,47 +346,46 @@
#endif
dot_spec = clampf(dot_spec, 0, 1);
#if TGL_FEATURE_FISR == 1
- tmp = fastInvSqrt(s.X * s.X + s.Y * s.Y + s.Z * s.Z); //FISR IMPL, MATCHED!
- //if (tmp < 1E+3)
- {
- dot_spec = dot_spec * tmp;
- }
- // else dot_spec = 0;
+ tmp = fastInvSqrt(s.X * s.X + s.Y * s.Y + s.Z * s.Z);
+
+ { dot_spec = dot_spec * tmp; }
+
#else
- //reference implementation.
- tmp= sqrt(s.X*s.X+s.Y*s.Y+s.Z*s.Z);
- if (tmp > 1E-3) {
- dot_spec=dot_spec / tmp;
- } else dot_spec = 0;
+
+ tmp = sqrt(s.X * s.X + s.Y * s.Y + s.Z * s.Z);
+ if (tmp > 1E-3) {
+ dot_spec = dot_spec / tmp;
+ } else
+ dot_spec = 0;
#endif
/* dot_spec= pow(dot_spec,m->shininess);*/
#if TGL_FEATURE_SPECULAR_BUFFERS == 1
specbuf = specbuf_get_buffer(c, m->shininess_i, m->shininess);
-//Check for GL_OUT_OF_MEMORY
+/* Check for GL_OUT_OF_MEMORY*/
#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
#endif
#else
- dot_spec= pow(dot_spec,m->shininess);
+ dot_spec = pow(dot_spec, m->shininess);
#endif
#if TGL_FEATURE_SPECULAR_BUFFERS == 1
idx = (GLint)(dot_spec * SPECULAR_BUFFER_SIZE);
if (idx > SPECULAR_BUFFER_SIZE)
- idx = SPECULAR_BUFFER_SIZE; //NOTE by GEK: this is poorly written, it's actually 1 larger.
+ idx = SPECULAR_BUFFER_SIZE; /* NOTE by GEK: this is poorly written, it's actually 1 larger.*/
dot_spec = specbuf->buf[idx];
#endif
lR += dot_spec * l->specular.v[0] * m->specular.v[0];
lG += dot_spec * l->specular.v[1] * m->specular.v[1];
lB += dot_spec * l->specular.v[2] * m->specular.v[2];
- } // EOF if dot_spec>0
- } // EOF zEnableSpecular
- } // EOF if dot > 0
+ }
+ }
+ }
R += att * lR;
G += att * lG;
B += att * lB;
- } // End of light loop.
+ } /* End of light loop.*/
v->color.v[0] = clampf(R, 0, 1);
v->color.v[1] = clampf(G, 0, 1);
--- a/src/list.c
+++ b/src/list.c
@@ -8,7 +8,7 @@
#include "opinfo.h"
};
*/
-//void (*op_table_func[])(GLContext*, GLParam*)
+
void (*op_table_func[])(GLParam*) = {
#define ADD_OP(a, b, c) glop##a,
@@ -21,20 +21,18 @@
#include "opinfo.h"
};
+static GLList* find_list(GLuint list) { return gl_get_context()->shared_state.lists[list]; }
-
-static inline GLList* find_list(GLuint list) { return gl_get_context()->shared_state.lists[list]; }
-
-static void delete_list( GLint list) {
+static void delete_list(GLint list) {
GLContext* c = gl_get_context();
GLParamBuffer *pb, *pb1;
GLList* l;
l = find_list(list);
- if (l == NULL) { //MARK <COST>
+ if (l == NULL) {
return;
}
- //assert(l != NULL);
+
/* free param buffer */
pb = l->first_op_buffer;
@@ -53,13 +51,14 @@
for (i = 0; i < list + range; i++)
glDeleteList(list + i);
}
-void glDeleteList(GLuint list) {
+void glDeleteList(GLuint list) {
#include "error_check_no_context.h"
-delete_list( list);
+ delete_list(list);
}
-static GLList* alloc_list( GLint list) {
- GLList* l;GLParamBuffer* ob;
+static GLList* alloc_list(GLint list) {
+ GLList* l;
+ GLParamBuffer* ob;
GLContext* c = gl_get_context();
#define RETVAL NULL
#include "error_check.h"
@@ -67,16 +66,18 @@
ob = gl_zalloc(sizeof(GLParamBuffer));
#if TGL_FEATURE_ERROR_CHECK
-if(!l || !ob)
+ if (!l || !ob)
#define ERROR_FLAG GL_OUT_OF_MEMORY
#define RETVAL NULL
#include "error_check.h"
#else
- //if(!l || !ob) gl_fatal_error("GL_OUT_OF_MEMORY");
- //This will crash a few lines down, so, let it!
+ /*
+ if(!l || !ob) gl_fatal_error("GL_OUT_OF_MEMORY");
+ This will crash a few lines down, so, let it!
+ */
#endif
- ob->next = NULL;
+ ob->next = NULL;
l->first_op_buffer = ob;
ob->ops[0].op = OP_EndList;
@@ -112,27 +113,22 @@
tgl_warning(f, "\n");
}
*/
-void glListBase(GLint n){
+void glListBase(GLint n) {
GLContext* c = gl_get_context();
#include "error_check.h"
c->listbase = n;
}
-void glCallLists( GLsizei n,
- GLenum type,
- const GLuint* lists){
+void glCallLists(GLsizei n, GLenum type, const GLuint* lists) {
GLint i;
GLContext* c = gl_get_context();
-//A ridiculously expensive error check.
-/*
-#include "error_check.h"
-#if TGL_FEATURE_ERROR_CHECK == 1
- if(type != GL_UNSIGNED_INT &&
- type != GL_INT)
-#define ERROR_FLAG GL_INVALID_ENUM
-#include "error_check.h"
-#endif
-*/
- for(i = 0; i < n; i++)
+ #include "error_check.h"
+ #if TGL_FEATURE_ERROR_CHECK == 1
+ if(type != GL_UNSIGNED_INT &&
+ type != GL_INT)
+ #define ERROR_FLAG GL_INVALID_ENUM
+ #include "error_check.h"
+ #endif
+ for (i = 0; i < n; i++)
glCallList(c->listbase + lists[i]);
}
void gl_compile_op(GLParam* p) {
@@ -152,14 +148,14 @@
ob1 = gl_zalloc(sizeof(GLParamBuffer));
#if TGL_FEATURE_ERROR_CHECK == 1
-if(!ob1)
+ if (!ob1)
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
#else
- //if(!ob1) gl_fatal_error("GL_OUT_OF_MEMORY");
- //This will crash a few lines down, so, let it!
+
+
#endif
- ob1->next = NULL;
+ ob1->next = NULL;
ob->next = ob1;
ob->ops[index].op = OP_NextBuffer;
@@ -183,20 +179,24 @@
void glopNextBuffer(GLParam* p) { exit(1); }
void glopCallList(GLParam* p) {
- //GLContext* c = gl_get_context();
- GLList* l;GLint list;
+
+ GLList* l;
+ GLint list;
#include "error_check_no_context.h"
list = p[1].ui;
l = find_list(list);
#if TGL_FEATURE_ERROR_CHECK == 1
- if (l == NULL) {gl_fatal_error("Bad list op, not defined");}
+ if (l == NULL) {
+ gl_fatal_error("Bad list op, not defined");
+ }
#else
- //if(l == NULL)return; //MARK <COST>
+
#endif
p = l->first_op_buffer->ops;
- while (1) {GLint op;
+ while (1) {
+ GLint op;
#include "error_check.h"
op = p[0].op;
if (op == OP_EndList)
@@ -217,31 +217,33 @@
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE))
+ if (!(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
- if(!(c->compile_flag == 0))
+ if (!(c->compile_flag == 0))
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- //assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE); //MARK <COST>
- //assert(c->compile_flag == 0); //MARK <COST>
+
+
#endif
- l = find_list(list);
- if (l != NULL) delete_list(list);
+ l = find_list(list);
+ if (l != NULL)
+ delete_list(list);
l = alloc_list(list);
#include "error_check.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(l==NULL)
+ if (l == NULL)
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
#else
- //Nearly cost-free
- if(l==NULL) gl_fatal_error("Could not find or allocate list.");
+
+ if (l == NULL)
+ gl_fatal_error("Could not find or allocate list.");
#endif
- c->current_op_buffer = l->first_op_buffer;
+ c->current_op_buffer = l->first_op_buffer;
c->current_op_buffer_index = 0;
c->compile_flag = 1;
@@ -253,15 +255,15 @@
GLParam p[1];
#include "error_check.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->compile_flag != 1)
+ if (c->compile_flag != 1)
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- if(c->compile_flag != 1)
+ if (c->compile_flag != 1)
return;
#endif
- /* end of list */
- p[0].op = OP_EndList;
+ /* end of list */
+ p[0].op = OP_EndList;
gl_compile_op(p);
c->compile_flag = 0;
@@ -269,7 +271,7 @@
}
GLint glIsList(GLuint list) {
- //GLContext* c = gl_get_context();
+
GLList* l;
l = find_list(list);
return (l != NULL);
--- a/src/matrix.c
+++ b/src/matrix.c
@@ -8,9 +8,12 @@
}
}
-static inline void gl_matrix_update() { GLContext* c = gl_get_context(); c->matrix_model_projection_updated = (c->matrix_mode <= 1); }
+static void gl_matrix_update() {
+ GLContext* c = gl_get_context();
+ c->matrix_model_projection_updated = (c->matrix_mode <= 1);
+}
-void glopMatrixMode( GLParam* p) {
+void glopMatrixMode(GLParam* p) {
GLContext* c = gl_get_context();
GLint mode = p[1].i;
switch (mode) {
@@ -23,8 +26,9 @@
case GL_TEXTURE:
c->matrix_mode = 2;
break;
- default:break;
- //assert(0);
+ default:
+ break;
+
}
}
@@ -78,18 +82,18 @@
gl_matrix_update();
}
-void glopPushMatrix( GLParam* p) {
+void glopPushMatrix(GLParam* p) {
GLContext* c = gl_get_context();
GLint n = c->matrix_mode;
M4* m;
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!((c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1) < c->matrix_stack_depth_max[n]))
- #define ERROR_FLAG GL_INVALID_OPERATION
- #include "error_check.h"
+ if (!((c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1) < c->matrix_stack_depth_max[n]))
+#define ERROR_FLAG GL_INVALID_OPERATION
+#include "error_check.h"
#endif
- m = ++c->matrix_stack_ptr[n];
+ m = ++c->matrix_stack_ptr[n];
gl_M4_Move(&m[0], &m[-1]);
@@ -96,23 +100,21 @@
gl_matrix_update();
}
-void glopPopMatrix( GLParam* p) {
+void glopPopMatrix(GLParam* p) {
GLContext* c = gl_get_context();
GLint n = c->matrix_mode;
- //assert(c->matrix_stack_ptr[n] > c->matrix_stack[n]);
+
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(c->matrix_stack_ptr[n] > c->matrix_stack[n]))
- #define ERROR_FLAG GL_INVALID_OPERATION
- #include "error_check.h"
+ if (!(c->matrix_stack_ptr[n] > c->matrix_stack[n]))
+#define ERROR_FLAG GL_INVALID_OPERATION
+#include "error_check.h"
#endif
- c->matrix_stack_ptr[n]--;
+ c->matrix_stack_ptr[n]--;
gl_matrix_update();
}
-
-
void glopRotate(GLParam* p) {
GLContext* c = gl_get_context();
M4 m;
@@ -151,14 +153,14 @@
GLfloat cost, sint;
/* normalize vector */
-
+
#if TGL_FEATURE_FISR == 1
- GLfloat len = u[0] + u[1] + u[2];
+ GLfloat len = u[0] + u[1] + u[2];
if (len == 0.0f)
return;
- len = fastInvSqrt(len); //FISR
+ len = fastInvSqrt(len); /* FISR*/
#else
- GLfloat 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);
--- a/src/memory.c
+++ b/src/memory.c
@@ -7,8 +7,7 @@
/* modify these functions so that they suit your needs */
-
-#include<string.h>
+#include <string.h>
void gl_free(void* p) { free(p); }
void* gl_malloc(GLint size) { return malloc(size); }
--- a/src/misc.c
+++ b/src/misc.c
@@ -14,13 +14,9 @@
#endif
}
-
-
-void glopViewport( GLParam* p) {
+void glopViewport(GLParam* p) {
GLContext* c = gl_get_context();
- GLint 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;
@@ -41,15 +37,15 @@
gl_fatal_error("glViewport: size too small");
}
- //tgl_trace("glViewport: %d %d %d %d\n", xmin, ymin, xsize, ysize);
+
c->viewport.xmin = xmin;
c->viewport.ymin = ymin;
c->viewport.xsize = xsize;
c->viewport.ysize = ysize;
- //c->viewport.updated = 1;
- gl_eval_viewport(c);
- //c->viewport.updated = 0;
+
+ gl_eval_viewport();
+
}
}
void glBlendFunc(GLenum sfactor, GLenum dfactor) {
@@ -61,13 +57,12 @@
gl_add_op(p);
return;
}
-void glopBlendFunc( GLParam* p) {
+void glopBlendFunc(GLParam* p) {
GLContext* c = gl_get_context();
c->zb->sfactor = p[1].i;
c->zb->dfactor = p[2].i;
}
-
void glBlendEquation(GLenum mode) {
GLParam p[2];
#include "error_check_no_context.h"
@@ -75,14 +70,18 @@
p[1].i = mode;
gl_add_op(p);
}
-void glopBlendEquation(GLParam* p) {GLContext* c = gl_get_context(); c->zb->blendeq = p[1].i; }
+void glopBlendEquation(GLParam* p) {
+ GLContext* c = gl_get_context();
+ c->zb->blendeq = p[1].i;
+}
-void glopPointSize(GLParam* p){
+void glopPointSize(GLParam* p) {
GLContext* c = gl_get_context();
c->zb->pointsize = p[1].f;
}
-void glPointSize(GLfloat f){
- GLParam p[2]; p[0].op = OP_PointSize;
+void glPointSize(GLfloat f) {
+ GLParam p[2];
+ p[0].op = OP_PointSize;
#include "error_check_no_context.h"
p[1].f = f;
gl_add_op(p);
@@ -142,7 +141,7 @@
if (code >= GL_LIGHT0 && code < GL_LIGHT0 + MAX_LIGHTS) {
gl_enable_disable_light(code - GL_LIGHT0, v);
} else {
- tgl_warning("glEnableDisable: 0x%X not supported.\n",code);
+ tgl_warning("glEnableDisable: 0x%X not supported.\n", code);
}
break;
}
@@ -182,22 +181,22 @@
c->polygon_mode_front = mode;
c->polygon_mode_back = mode;
break;
- default:break;
+ default:
+ break;
}
}
-
-void glopPolygonOffset( GLParam* p) {
+void glopPolygonOffset(GLParam* p) {
GLContext* c = gl_get_context();
c->offset_factor = p[1].f;
c->offset_units = p[2].f;
}
-GLenum glGetError(){
+GLenum glGetError() {
#if TGL_FEATURE_ERROR_CHECK == 1
GLContext* c = gl_get_context();
GLenum eflag = c->error_flag;
- if(eflag != GL_OUT_OF_MEMORY) //Unrecoverable!
+ if (eflag != GL_OUT_OF_MEMORY)
c->error_flag = GL_NO_ERROR;
return eflag;
#else
@@ -205,12 +204,10 @@
#endif
}
-void glDrawBuffer(GLenum mode){
+void glDrawBuffer(GLenum mode) {
GLContext* c = gl_get_context();
#include "error_check.h"
- if((mode != GL_FRONT &&
- mode != GL_NONE) || c->in_begin)
- {
+ if ((mode != GL_FRONT && mode != GL_NONE) || c->in_begin) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
@@ -221,12 +218,10 @@
c->drawbuffer = mode;
}
-void glReadBuffer(GLenum mode){
+void glReadBuffer(GLenum mode) {
GLContext* c = gl_get_context();
#include "error_check.h"
- if((mode != GL_FRONT &&
- mode != GL_NONE) || c->in_begin)
- {
+ if ((mode != GL_FRONT && mode != GL_NONE) || c->in_begin) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
@@ -237,18 +232,11 @@
c->readbuffer = mode;
}
-//TODO
-void glReadPixels( GLint x,
- GLint y,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- void * data){
+
+void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* data) {
GLContext* c = gl_get_context();
- #include "error_check.h"
- if(c->readbuffer != GL_FRONT ||
- (format != GL_RGBA && format != GL_RGB && format != GL_DEPTH_COMPONENT) ||
+#include "error_check.h"
+ if (c->readbuffer != GL_FRONT || (format != GL_RGBA && format != GL_RGB && format != GL_DEPTH_COMPONENT) ||
#if TGL_FEATURE_RENDER_BITS == 32
(type != GL_UNSIGNED_INT && type != GL_UNSIGNED_INT_8_8_8_8)
#elif TGL_FEATURE_RENDER_BITS == 16
@@ -256,8 +244,8 @@
#else
#error "Unsupported TGL_FEATURE_RENDER_BITS"
#endif
-
- ){
+
+ ) {
#if TGL_FEATURE_ERROR_CHECK
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
@@ -265,9 +253,7 @@
return;
#endif
}
- //TODO: implement read pixels.
+ /* TODO: implement read pixels.*/
}
-void glFinish(){
- return;
-}
+void glFinish() { return; }
--- a/src/msghandling.c
+++ b/src/msghandling.c
@@ -1,11 +1,9 @@
+#include "msghandling.h"
#include "../include/GL/gl.h"
#include "zgl.h"
-#include "msghandling.h"
#include <stdarg.h>
-//#define NDEBUG
-//TinyC doesnt like my stdio.
#ifdef __TINYC__
#define NO_DEBUG_OUTPUT
#endif
@@ -63,7 +61,4 @@
#else
exit(1);
#endif
-
}
-
-
--- a/src/opinfo.h
+++ b/src/opinfo.h
@@ -38,14 +38,14 @@
ADD_OP(PopName, 0, "")
ADD_OP(LoadName, 1, "%d")
-ADD_OP(TexImage2D, 9, "%d %d %d %d %d %d %d %d %d")
-ADD_OP(TexImage1D, 8, "%d %d %d %d %d %d %d %d")
+ADD_OP(TexImage2D, 9, "%d %d %d %d %d %d %d %d %d")
+ADD_OP(TexImage1D, 8, "%d %d %d %d %d %d %d %d")
ADD_OP(CopyTexImage2D, 8, "%d %d %d %d %d %d %d %d")
ADD_OP(BindTexture, 2, "%C %d")
-//ADD_OP(TexEnv, 7, "%C %C %C %f %f %f %f")
-//ADD_OP(TexParameter, 7, "%C %C %C %f %f %f %f")
-//ADD_OP(PixelStore, 2, "%C %C")
+
+
+
ADD_OP(ShadeModel, 1, "%C")
ADD_OP(CullFace, 1, "%C")
ADD_OP(FrontFace, 1, "%C")
@@ -52,8 +52,8 @@
ADD_OP(PolygonMode, 2, "%C %C")
ADD_OP(CallList, 1, "%d")
-//ADD_OP(Hint, 2, "%C %C")
+
/* special opcodes */
ADD_OP(EndList, 0, "")
ADD_OP(NextBuffer, 1, "%p")
@@ -88,6 +88,5 @@
ADD_OP(PlotPixel, 2, "%d %d")
ADD_OP(TextSize, 1, "%d")
ADD_OP(SetEnableSpecular, 1, "%d")
-
#undef ADD_OP
--- a/src/quick.sh
+++ b/src/quick.sh
@@ -8,6 +8,6 @@
#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
-#sed -i 's/unsigned GLshort/GLushort/g' *.c *.h
+sed -i 's/inline//g' *.c *.h
#gcc *.c -o executable.out -lglut -lGL -lm -lGLU
--- a/src/select.c
+++ b/src/select.c
@@ -5,7 +5,8 @@
GLint result = 0;
#if TGL_FEATURE_ALT_RENDERMODES == 1
switch (c->render_mode) {
- case GL_RENDER:break;
+ case GL_RENDER:
+ break;
case GL_SELECT:
if (c->select_overflow) {
result = -c->select_hits;
@@ -17,7 +18,7 @@
c->name_stack_size = 0;
break;
case GL_FEEDBACK:
- if(c->feedback_overflow)
+ if (c->feedback_overflow)
result = -c->feedback_hits;
else
result = c->feedback_hits;
@@ -24,7 +25,7 @@
c->feedback_overflow = 0;
c->feedback_hits = 0;
c->feedback_ptr = c->feedback_buffer;
- break;
+ break;
default:
gl_fatal_error("GLContext's Rendermode was somehow erroneously set.");
}
@@ -33,16 +34,17 @@
c->render_mode = GL_RENDER;
break;
case GL_SELECT:
-
+
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->select_buffer == NULL)
+ if (c->select_buffer == NULL)
#define ERROR_FLAG GL_INVALID_OPERATION
#define RETVAL 0
#include "error_check.h"
#else
- if(c->select_buffer == NULL)return 0;
+ if (c->select_buffer == NULL)
+ return 0;
#endif
- c->render_mode = GL_SELECT;
+ c->render_mode = GL_SELECT;
c->select_ptr = c->select_buffer;
c->select_hits = 0;
c->select_overflow = 0;
@@ -50,18 +52,19 @@
break;
case GL_FEEDBACK:
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->feedback_buffer == NULL)
+ if (c->feedback_buffer == NULL)
#define ERROR_FLAG GL_INVALID_OPERATION
#define RETVAL 0
#include "error_check.h"
#else
- if(c->feedback_buffer == NULL) return 0;
+ if (c->feedback_buffer == NULL)
+ return 0;
#endif
- c->render_mode = GL_FEEDBACK;
+ c->render_mode = GL_FEEDBACK;
c->feedback_hits = 0;
c->feedback_ptr = c->feedback_buffer;
c->feedback_overflow = 0;
- break;
+ break;
default:
#if TGL_FEATURE_ERROR_CHECK == 1
#define RETVAL 0
@@ -74,25 +77,25 @@
}
return result;
#else
-//GL_SELECT and GL_FEEDBACK are disabled.
+
return 0;
#endif
-
}
void glSelectBuffer(GLint size, GLuint* buf) {
-
+
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->render_mode == GL_SELECT)
+ if (c->render_mode == GL_SELECT)
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- if(c->render_mode == GL_SELECT) return;
+ if (c->render_mode == GL_SELECT)
+ return;
#endif
- c->select_buffer = buf;
+ c->select_buffer = buf;
c->select_size = size;
#else
return;
@@ -99,49 +102,30 @@
#endif
}
-void glFeedbackBuffer(GLint size, GLenum type, GLfloat* buf){
+void glFeedbackBuffer(GLint size, GLenum type, GLfloat* buf) {
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->render_mode == GL_FEEDBACK ||
- !(
- type == GL_2D ||
- type == GL_3D ||
- type == GL_3D_COLOR ||
- type == GL_3D_COLOR_TEXTURE ||
- type == GL_4D_COLOR_TEXTURE
- )
- )
+ if (c->render_mode == GL_FEEDBACK || !(type == GL_2D || type == GL_3D || type == GL_3D_COLOR || type == GL_3D_COLOR_TEXTURE || type == GL_4D_COLOR_TEXTURE))
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- if(c->render_mode == GL_FEEDBACK ||
- !(
- type == GL_2D ||
- type == GL_3D ||
- type == GL_3D_COLOR ||
- type == GL_3D_COLOR_TEXTURE ||
- type == GL_4D_COLOR_TEXTURE
- )
- )return;
-#endif
- c->feedback_buffer = buf;
+ if (c->render_mode == GL_FEEDBACK || !(type == GL_2D || type == GL_3D || type == GL_3D_COLOR || type == GL_3D_COLOR_TEXTURE || type == GL_4D_COLOR_TEXTURE))
+ return;
+#endif
+ c->feedback_buffer = buf;
c->feedback_size = size;
c->feedback_type = type;
#else
-return;
+ return;
#endif
}
-void gl_add_feedback(GLfloat token,
- GLVertex* v1,
- GLVertex* v2,
- GLVertex* v3,
- GLfloat passthrough_token_value
-){
+void gl_add_feedback(GLfloat token, GLVertex* v1, GLVertex* v2, GLVertex* v3, GLfloat passthrough_token_value) {
#if TGL_FEATURE_ALT_RENDERMODES == 1
-GLContext* c = gl_get_context();
- if(c->feedback_overflow) return;
+ GLContext* c = gl_get_context();
+ if (c->feedback_overflow)
+ return;
GLuint feedback_hits_needed = 2;
GLuint vertex_feedback_hits_needed = 0;
GLuint vertex_pos_hits_needed = 2;
@@ -150,117 +134,147 @@
#if TGL_FEATURE_ERROR_CHECK == 1
GLuint done = 0;
#endif
- switch(c->feedback_type){
- case GL_2D: vertex_feedback_hits_needed = 2;
- vertex_pos_hits_needed = 2;
- vertex_color_hits_needed = 0;
- vertex_texture_hits_needed = 0; break;
- case GL_3D: vertex_feedback_hits_needed = 3;
- vertex_pos_hits_needed = 3;
- vertex_color_hits_needed = 0;
- vertex_texture_hits_needed = 0; break;
- case GL_3D_COLOR: vertex_feedback_hits_needed = 3 + 4;
- vertex_pos_hits_needed = 3;
- vertex_color_hits_needed = 4;
- vertex_texture_hits_needed = 0; break;
- case GL_3D_COLOR_TEXTURE: vertex_feedback_hits_needed = 3 + 4 + 4;
- vertex_pos_hits_needed = 3;
- vertex_color_hits_needed = 4;
- vertex_texture_hits_needed = 4; break;
- case GL_4D_COLOR_TEXTURE: vertex_feedback_hits_needed = 4 + 4 + 4;
- vertex_pos_hits_needed = 4;
- vertex_color_hits_needed = 4;
- vertex_texture_hits_needed = 4; break;
- default:
- vertex_feedback_hits_needed = 0;
- vertex_pos_hits_needed = 0;
- vertex_color_hits_needed = 0;
- vertex_texture_hits_needed = 0;
+ switch (c->feedback_type) {
+ case GL_2D:
+ vertex_feedback_hits_needed = 2;
+ vertex_pos_hits_needed = 2;
+ vertex_color_hits_needed = 0;
+ vertex_texture_hits_needed = 0;
break;
+ case GL_3D:
+ vertex_feedback_hits_needed = 3;
+ vertex_pos_hits_needed = 3;
+ vertex_color_hits_needed = 0;
+ vertex_texture_hits_needed = 0;
+ break;
+ case GL_3D_COLOR:
+ vertex_feedback_hits_needed = 3 + 4;
+ vertex_pos_hits_needed = 3;
+ vertex_color_hits_needed = 4;
+ vertex_texture_hits_needed = 0;
+ break;
+ case GL_3D_COLOR_TEXTURE:
+ vertex_feedback_hits_needed = 3 + 4 + 4;
+ vertex_pos_hits_needed = 3;
+ vertex_color_hits_needed = 4;
+ vertex_texture_hits_needed = 4;
+ break;
+ case GL_4D_COLOR_TEXTURE:
+ vertex_feedback_hits_needed = 4 + 4 + 4;
+ vertex_pos_hits_needed = 4;
+ vertex_color_hits_needed = 4;
+ vertex_texture_hits_needed = 4;
+ break;
+ default:
+ vertex_feedback_hits_needed = 0;
+ vertex_pos_hits_needed = 0;
+ vertex_color_hits_needed = 0;
+ vertex_texture_hits_needed = 0;
+ break;
}
- if(token == GL_PASS_THROUGH_TOKEN) feedback_hits_needed = 1 + 1; //GL_PASSTHROUGH_TOKEN, value
- else if(token == GL_POINT_TOKEN) feedback_hits_needed = 1 + 1*vertex_feedback_hits_needed; //GL_POINT_TOKEN vertex
- else if(token == GL_LINE_TOKEN || token == GL_LINE_RESET_TOKEN) feedback_hits_needed = 1 + 2*vertex_feedback_hits_needed; //2 verts
- else if(token == GL_POLYGON_TOKEN) feedback_hits_needed = 1 + 1 + 3*vertex_feedback_hits_needed; //GL_POLYGON_TOKEN, "3", v,v,v
- else if(token == GL_BITMAP_TOKEN) feedback_hits_needed = 1 + 1*vertex_feedback_hits_needed; //GL_BITMAP_TOKEN vertex
- else if(token == GL_DRAW_PIXEL_TOKEN || token == GL_COPY_PIXEL_TOKEN)
- feedback_hits_needed = 1 + 1*vertex_feedback_hits_needed; //token vertex
- else return;
+ if (token == GL_PASS_THROUGH_TOKEN)
+ feedback_hits_needed = 1 + 1;
+ else if (token == GL_POINT_TOKEN)
+ feedback_hits_needed = 1 + 1 * vertex_feedback_hits_needed;
+ else if (token == GL_LINE_TOKEN || token == GL_LINE_RESET_TOKEN)
+ feedback_hits_needed = 1 + 2 * vertex_feedback_hits_needed;
+ else if (token == GL_POLYGON_TOKEN)
+ feedback_hits_needed = 1 + 1 + 3 * vertex_feedback_hits_needed;
+ else if (token == GL_BITMAP_TOKEN)
+ feedback_hits_needed = 1 + 1 * vertex_feedback_hits_needed;
+ else if (token == GL_DRAW_PIXEL_TOKEN || token == GL_COPY_PIXEL_TOKEN)
+ feedback_hits_needed = 1 + 1 * vertex_feedback_hits_needed;
+ else
+ return;
c->feedback_hits += feedback_hits_needed;
- if(c->feedback_hits > (GLint)c->feedback_size){
+ if (c->feedback_hits > (GLint)c->feedback_size) {
c->feedback_overflow = 1;
c->feedback_hits -= feedback_hits_needed;
return;
}
- //c->feedback_hits -= feedback_hits_needed;
+
#if TGL_FEATURE_ERROR_CHECK == 1
-#define DONE_ERROR_CHECK {if(++done > feedback_hits_needed) {gl_fatal_error("\nBAD FEEDBACK BUFFER WRITE DETECTED\n");}}
+#define DONE_ERROR_CHECK \
+ { \
+ if (++done > feedback_hits_needed) { \
+ gl_fatal_error("\nBAD FEEDBACK BUFFER WRITE DETECTED\n"); \
+ } \
+ }
#else
#define DONE_ERROR_CHECK /* a comment*/
#endif
- #define WRITE_FLOAT(f) {DONE_ERROR_CHECK;*(c->feedback_ptr++) = f;}
- #define WRITE_UINT(u) {DONE_ERROR_CHECK;*( ((GLuint*)c->feedback_ptr++)) = u;}
- #define WRITE_VERTEX(v){\
- if(vertex_pos_hits_needed == 2){\
- WRITE_FLOAT(v->zp.x)\
- WRITE_FLOAT(v->zp.y)\
- }\
- if(vertex_pos_hits_needed == 3){\
- WRITE_FLOAT(v->zp.x)\
- WRITE_FLOAT(v->zp.y)\
- WRITE_FLOAT(v->zp.z)\
- }\
- if(vertex_pos_hits_needed == 4){\
- WRITE_FLOAT(v->zp.x)\
- WRITE_FLOAT(v->zp.y)\
- WRITE_FLOAT(v->zp.z)\
- WRITE_FLOAT(v->pc.W)\
- }\
- if(vertex_color_hits_needed == 4){\
- WRITE_FLOAT(v->color.X)\
- WRITE_FLOAT(v->color.Y)\
- WRITE_FLOAT(v->color.Z)\
- WRITE_FLOAT(v->color.W)\
- }\
- if(vertex_texture_hits_needed == 4){\
- WRITE_FLOAT(v->tex_coord.X)\
- WRITE_FLOAT(v->tex_coord.Y)\
- WRITE_FLOAT(v->tex_coord.Z)\
- WRITE_FLOAT(v->tex_coord.W)\
- }\
+#define WRITE_FLOAT(f) \
+ { \
+ DONE_ERROR_CHECK; \
+ *(c->feedback_ptr++) = f; \
}
- if(token == GL_PASS_THROUGH_TOKEN) {
+#define WRITE_UINT(u) \
+ { \
+ DONE_ERROR_CHECK; \
+ *(((GLuint*)c->feedback_ptr++)) = u; \
+ }
+#define WRITE_VERTEX(v) \
+ { \
+ if (vertex_pos_hits_needed == 2) { \
+ WRITE_FLOAT(v->zp.x) \
+ WRITE_FLOAT(v->zp.y) \
+ } \
+ if (vertex_pos_hits_needed == 3) { \
+ WRITE_FLOAT(v->zp.x) \
+ WRITE_FLOAT(v->zp.y) \
+ WRITE_FLOAT(v->zp.z) \
+ } \
+ if (vertex_pos_hits_needed == 4) { \
+ WRITE_FLOAT(v->zp.x) \
+ WRITE_FLOAT(v->zp.y) \
+ WRITE_FLOAT(v->zp.z) \
+ WRITE_FLOAT(v->pc.W) \
+ } \
+ if (vertex_color_hits_needed == 4) { \
+ WRITE_FLOAT(v->color.X) \
+ WRITE_FLOAT(v->color.Y) \
+ WRITE_FLOAT(v->color.Z) \
+ WRITE_FLOAT(v->color.W) \
+ } \
+ if (vertex_texture_hits_needed == 4) { \
+ WRITE_FLOAT(v->tex_coord.X) \
+ WRITE_FLOAT(v->tex_coord.Y) \
+ WRITE_FLOAT(v->tex_coord.Z) \
+ WRITE_FLOAT(v->tex_coord.W) \
+ } \
+ }
+ if (token == GL_PASS_THROUGH_TOKEN) {
WRITE_UINT(GL_PASS_THROUGH_TOKEN);
WRITE_FLOAT(passthrough_token_value);
- }else if(token == GL_LINE_TOKEN || token == GL_LINE_RESET_TOKEN){
+ } else if (token == GL_LINE_TOKEN || token == GL_LINE_RESET_TOKEN) {
WRITE_UINT(token);
WRITE_VERTEX(v1);
WRITE_VERTEX(v2);
- } else if(token == GL_POLYGON_TOKEN) {
+ } else if (token == GL_POLYGON_TOKEN) {
WRITE_UINT(GL_POLYGON_TOKEN);
WRITE_UINT(3);
WRITE_VERTEX(v1);
WRITE_VERTEX(v2);
WRITE_VERTEX(v3);
- } else if(token == GL_BITMAP_TOKEN) {
+ } else if (token == GL_BITMAP_TOKEN) {
WRITE_UINT(GL_BITMAP_TOKEN);
WRITE_VERTEX(v1);
- } else if(token == GL_DRAW_PIXEL_TOKEN || token == GL_COPY_PIXEL_TOKEN) {
+ } else if (token == GL_DRAW_PIXEL_TOKEN || token == GL_COPY_PIXEL_TOKEN) {
WRITE_UINT(token);
WRITE_VERTEX(v1);
}
#if TGL_FEATURE_ERROR_CHECK == 1
- if(done != feedback_hits_needed)
+ if (done != feedback_hits_needed)
gl_fatal_error("Failed to write enough information to the buffer.");
#endif
-//End of gl_add_feedback
+/* End of gl_add_feedback*/
#endif
return;
}
-void glPassThrough(GLfloat token){
-//GLContext* c = gl_get_context(); //needed for error check.
+void glPassThrough(GLfloat token) {
+
#include "error_check_no_context.h"
- gl_add_feedback(GL_PASS_THROUGH_TOKEN,NULL,NULL,NULL,token);
+ gl_add_feedback(GL_PASS_THROUGH_TOKEN, NULL, NULL, NULL, token);
}
void glopInitNames(GLParam* p) {
#if TGL_FEATURE_ALT_RENDERMODES == 1
@@ -276,7 +290,7 @@
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLContext* c = gl_get_context();
if (c->render_mode == GL_SELECT) {
- //assert(c->name_stack_size < MAX_NAME_STACK_DEPTH);
+
c->name_stack[c->name_stack_size++] = p[1].i;
c->select_hit = NULL;
}
@@ -283,16 +297,11 @@
#endif
}
-
-
-
-
-
void glopPopName(GLParam* p) {
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLContext* c = gl_get_context();
if (c->render_mode == GL_SELECT) {
- //assert(c->name_stack_size > 0);
+
c->name_stack_size--;
c->select_hit = NULL;
}
@@ -303,7 +312,7 @@
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLContext* c = gl_get_context();
if (c->render_mode == GL_SELECT) {
- //assert(c->name_stack_size > 0);
+
c->name_stack[c->name_stack_size - 1] = p[1].i;
c->select_hit = NULL;
}
@@ -319,7 +328,7 @@
if (!c->select_overflow) {
if (c->select_hit == NULL) {
n = c->name_stack_size;
- if ((c->select_ptr - c->select_buffer + 3 + n) > c->select_size) { //Detect overflows
+ if ((c->select_ptr - c->select_buffer + 3 + n) > c->select_size) {
c->select_overflow = 1;
} else {
ptr = c->select_ptr;
@@ -340,6 +349,6 @@
}
}
#else
-return;
+ return;
#endif
}
--- a/src/specbuf.c
+++ b/src/specbuf.c
@@ -33,15 +33,15 @@
/* create new buffer */
GLSpecBuf* buf = gl_malloc(sizeof(GLSpecBuf));
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!buf)
+ if (!buf)
#define ERROR_FLAG GL_OUT_OF_MEMORY
#define RETVAL NULL
#include "error_check.h"
#else
- //if (!buf) gl_fatal_error("GL_OUT_OF_MEMORY");
- //It will crash a few lines down, just LET IT
+
+
#endif
- c->specbuf_num_buffers++;
+ c->specbuf_num_buffers++;
buf->next = c->specbuf_first;
c->specbuf_first = buf;
buf->last_used = c->specbuf_used_counter++;
@@ -56,6 +56,5 @@
calc_buf(oldest, shininess);
return oldest;
}
-
#endif
--- a/src/texture.c
+++ b/src/texture.c
@@ -16,25 +16,26 @@
return NULL;
}
-GLboolean glAreTexturesResident( GLsizei n,
- const GLuint * textures,
- GLboolean * residences){
+GLboolean glAreTexturesResident(GLsizei n, const GLuint* textures, GLboolean* residences) {
#define RETVAL GL_FALSE
-GLboolean retval = GL_TRUE; GLint i;
+ GLboolean retval = GL_TRUE;
+ GLint i;
#include "error_check_no_context.h"
- for(i = 0; i < n; i++)
- if(find_texture(textures[i]))
- {residences[i] = GL_TRUE;}
- else
- {residences[i] = GL_FALSE;retval = GL_FALSE;}
+ for (i = 0; i < n; i++)
+ if (find_texture(textures[i])) {
+ residences[i] = GL_TRUE;
+ } else {
+ residences[i] = GL_FALSE;
+ retval = GL_FALSE;
+ }
return retval;
}
-GLboolean glIsTexture( GLuint texture){
+GLboolean glIsTexture(GLuint texture) {
GLContext* c = gl_get_context();
#define RETVAL GL_FALSE
#include "error_check.h"
- if(find_texture(texture))
+ if (find_texture(texture))
return GL_TRUE;
return GL_FALSE;
}
@@ -43,7 +44,7 @@
GLTexture* tex;
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(text >= 0 && level < MAX_TEXTURE_LEVELS))
+ if (!(text >= 0 && level < MAX_TEXTURE_LEVELS))
#define ERROR_FLAG GL_INVALID_ENUM
#define RETVAL NULL
#include "error_check.h"
@@ -50,7 +51,7 @@
#else
/*assert(text >= 0 && level < MAX_TEXTURE_LEVELS);*/
#endif
- tex = find_texture(text);
+ tex = find_texture(text);
if (!tex)
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_ENUM
@@ -59,7 +60,7 @@
#else
return NULL;
#endif
- *xsize = tex->images[level].xsize;
+ *xsize = tex->images[level].xsize;
*ysize = tex->images[level].ysize;
return tex->images[level].pixmap;
}
@@ -86,7 +87,7 @@
#define RETVAL NULL
#include "error_check.h"
t = gl_zalloc(sizeof(GLTexture));
- if(!t)
+ if (!t)
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#define RETVAL NULL
@@ -95,7 +96,7 @@
gl_fatal_error("GL_OUT_OF_MEMORY");
#endif
- ht = &c->shared_state.texture_hash_table[h & TEXTURE_HASH_TABLE_MASK];
+ ht = &c->shared_state.texture_hash_table[h & TEXTURE_HASH_TABLE_MASK];
t->next = *ht;
t->prev = NULL;
@@ -130,12 +131,13 @@
}
}
for (i = 0; i < n; i++) {
- textures[i] = max + i + 1; //MARK: How texture handles are created.
+ textures[i] = max + i + 1; /* MARK: How texture handles are created.*/
}
}
void glDeleteTextures(GLint n, const GLuint* textures) {
- GLint i;GLTexture* t;
+ GLint i;
+ GLTexture* t;
GLContext* c = gl_get_context();
#include "error_check.h"
for (i = 0; i < n; i++) {
@@ -156,18 +158,18 @@
GLTexture* t;
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(!(target == GL_TEXTURE_2D && target > 0))
+ if (!(target == GL_TEXTURE_2D && target > 0))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- //assert(target == GL_TEXTURE_2D && target > 0);
+
#endif
- t = find_texture(texture);
+ t = find_texture(texture);
if (t == NULL) {
t = alloc_texture(texture);
#include "error_check.h"
}
- if(t == NULL) { //Failed malloc.
+ if (t == NULL) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
@@ -177,23 +179,18 @@
}
c->current_texture = t;
}
-//
-
-void glCopyTexImage2D(
- GLenum target, //1
- GLint level,//2
- GLenum internalformat, //3
- GLint x,//4
- GLint y,//5
- GLsizei width,//6
- GLsizei height,
- GLint border)
-{
- //GLContext* c = gl_get_context();
-#include "error_check_no_context.h"
+void glCopyTexImage2D(GLenum target,
+ GLint level,
+ GLenum internalformat,
+ GLint x,
+ GLint y,
+ GLsizei width,
+ GLsizei height, GLint border) {
GLParam p[9];
+#include "error_check_no_context.h"
+
p[0].op = OP_CopyTexImage2D;
p[1].i = target;
p[2].i = level;
@@ -205,30 +202,26 @@
p[8].i = border;
gl_add_op(p);
}
-void glopCopyTexImage2D(GLParam* p){
- GLImage* im; PIXEL* data;
+void glopCopyTexImage2D(GLParam* p) {
+ GLImage* im;
+ PIXEL* data;
+ GLint i, j;
GLint target = p[1].i;
GLint level = p[2].i;
-
GLint x = p[4].i;
GLint y = p[5].i;
GLsizei w = p[6].i;
GLsizei h = p[7].i;
- GLContext* c = gl_get_context();
- y -= h;
GLint border = p[8].i;
-
- if(c->readbuffer != GL_FRONT ||
- c->current_texture == NULL ||
- target != GL_TEXTURE_2D ||
- border != 0 ||
- w != TGL_FEATURE_TEXTURE_DIM || /*TODO Implement image interp*/
- h != TGL_FEATURE_TEXTURE_DIM
- )
- {
+ GLContext* c = gl_get_context();
+ y -= h;
+
+ if (c->readbuffer != GL_FRONT || c->current_texture == NULL || target != GL_TEXTURE_2D || border != 0 ||
+ w != TGL_FEATURE_TEXTURE_DIM || /*TODO Implement image interp*/
+ h != TGL_FEATURE_TEXTURE_DIM) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_INVALID_OPERATION
-#include "error_check.h"
+#include "error_check.h"
#else
return;
#endif
@@ -237,30 +230,27 @@
data = c->current_texture->images[level].pixmap;
im->xsize = TGL_FEATURE_TEXTURE_DIM;
im->ysize = TGL_FEATURE_TEXTURE_DIM;
- //sample the buffer.
- //TODO implement the scaling and stuff that the GL spec says it should have.
+ /* TODO implement the scaling and stuff that the GL spec says it should have.*/
#if TGL_FEATURE_MULTITHREADED_COPY_TEXIMAGE_2D == 1
#pragma omp parallel for
- for(GLint j = 0; j < h; j++)
- for(GLint i = 0; i < w; i++){
- data[i+j*w] = c->zb->pbuf[ ((i+x)%(c->zb->xsize))
- + ((j+y)%(c->zb->ysize))*(c->zb->xsize)];
- }
+ for (j = 0; j < h; j++)
+ for (i = 0; i < w; i++) {
+ data[i + j * w] = c->zb->pbuf[((i + x) % (c->zb->xsize)) + ((j + y) % (c->zb->ysize)) * (c->zb->xsize)];
+ }
#else
- for(GLint j = 0; j < h; j++)
- for(GLint i = 0; i < w; i++){
- data[i+j*w] = c->zb->pbuf[ ((i+x)%(c->zb->xsize))
- + ((j+y)%(c->zb->ysize))*(c->zb->xsize)];
- }
+ for (j = 0; j < h; j++)
+ for (i = 0; i < w; i++) {
+ data[i + j * w] = c->zb->pbuf[((i + x) % (c->zb->xsize)) + ((j + y) % (c->zb->ysize)) * (c->zb->xsize)];
+ }
#endif
}
-void glopTexImage1D( GLParam* p){
+void glopTexImage1D(GLParam* p) {
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 height = p[5].i;*/
GLint height = 1;
GLint border = p[5].i;
GLint format = p[6].i;
@@ -268,22 +258,24 @@
void* pixels = p[8].p;
GLImage* im;
GLubyte* pixels1;
- GLint do_free;
+ GLint do_free=0;
GLContext* c = gl_get_context();
{
#if TGL_FEATURE_ERROR_CHECK == 1
- if (!(c->current_texture != NULL && target == GL_TEXTURE_1D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
+ if (!(c->current_texture != NULL && target == GL_TEXTURE_1D && level == 0 && components == 3 && border == 0 && format == GL_RGB &&
+ type == GL_UNSIGNED_BYTE))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- if (!(c->current_texture != NULL && target == GL_TEXTURE_1D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
+ if (!(c->current_texture != NULL && target == GL_TEXTURE_1D && level == 0 && components == 3 && border == 0 && format == GL_RGB &&
+ type == GL_UNSIGNED_BYTE))
gl_fatal_error("glTexImage2D: combination of parameters not handled!!");
#endif
}
if (width != TGL_FEATURE_TEXTURE_DIM || height != TGL_FEATURE_TEXTURE_DIM) {
- pixels1 = gl_malloc(TGL_FEATURE_TEXTURE_DIM * TGL_FEATURE_TEXTURE_DIM * 3);//GUARDED
- if(pixels1 == NULL){
+ pixels1 = gl_malloc(TGL_FEATURE_TEXTURE_DIM * TGL_FEATURE_TEXTURE_DIM * 3); /* GUARDED*/
+ if (pixels1 == NULL) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
@@ -292,20 +284,18 @@
#endif
}
/* no GLinterpolation is done here to respect the original image aliasing ! */
- //TODO: Make this more efficient.
+
gl_resizeImageNoInterpolate(pixels1, TGL_FEATURE_TEXTURE_DIM, TGL_FEATURE_TEXTURE_DIM, pixels, width, height);
do_free = 1;
width = TGL_FEATURE_TEXTURE_DIM;
- height = TGL_FEATURE_TEXTURE_DIM; //TODO: make this more efficient.
+ height = TGL_FEATURE_TEXTURE_DIM;
} else {
pixels1 = pixels;
}
-
im = &c->current_texture->images[level];
im->xsize = width;
im->ysize = height;
- //if (im->pixmap != NULL) gl_free(im->pixmap);
#if TGL_FEATURE_RENDER_BITS == 32
gl_convertRGB_to_8A8R8G8B(im->pixmap, pixels1, width, height);
#elif TGL_FEATURE_RENDER_BITS == 16
@@ -328,24 +318,24 @@
void* pixels = p[9].p;
GLImage* im;
GLubyte* pixels1;
- GLint do_free;
+ GLint do_free=0;
GLContext* c = gl_get_context();
- {
+ {
#if TGL_FEATURE_ERROR_CHECK == 1
- if (!(c->current_texture != NULL && target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
+ if (!(c->current_texture != NULL && target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB &&
+ type == GL_UNSIGNED_BYTE))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#else
- if (!(c->current_texture != NULL && target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE))
- gl_fatal_error("glTexImage2D: combination of parameters not handled!!");
+ if (!(c->current_texture != NULL && target == GL_TEXTURE_2D && level == 0 && components == 3 && border == 0 && format == GL_RGB &&
+ type == GL_UNSIGNED_BYTE))
+ gl_fatal_error("glTexImage2D: combination of parameters not handled!!");
#endif
}
-
- do_free = 0;
if (width != TGL_FEATURE_TEXTURE_DIM || height != TGL_FEATURE_TEXTURE_DIM) {
- pixels1 = gl_malloc(TGL_FEATURE_TEXTURE_DIM * TGL_FEATURE_TEXTURE_DIM * 3);//GUARDED
- if(pixels1 == NULL){
+ pixels1 = gl_malloc(TGL_FEATURE_TEXTURE_DIM * TGL_FEATURE_TEXTURE_DIM * 3); /* GUARDED*/
+ if (pixels1 == NULL) {
#if TGL_FEATURE_ERROR_CHECK == 1
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
@@ -354,7 +344,7 @@
#endif
}
/* no GLinterpolation is done here to respect the original image aliasing ! */
- //printf("\nYes this is being called.");
+
gl_resizeImageNoInterpolate(pixels1, TGL_FEATURE_TEXTURE_DIM, TGL_FEATURE_TEXTURE_DIM, pixels, width, height);
do_free = 1;
width = TGL_FEATURE_TEXTURE_DIM;
@@ -367,9 +357,9 @@
im->xsize = width;
im->ysize = height;
#if TGL_FEATURE_RENDER_BITS == 32
- gl_convertRGB_to_8A8R8G8B(im->pixmap, pixels1, width, height);
+ gl_convertRGB_to_8A8R8G8B(im->pixmap, pixels1, width, height);
#elif TGL_FEATURE_RENDER_BITS == 16
- gl_convertRGB_to_5R6G5B(im->pixmap, pixels1, width, height);
+ gl_convertRGB_to_5R6G5B(im->pixmap, pixels1, width, height);
#else
#error Bad TGL_FEATURE_RENDER_BITS
#endif
@@ -394,7 +384,7 @@
#else
gl_fatal_error("glTexParameter: unsupported option");
#endif
-
+
}
if (pname != GL_TEXTURE_ENV_MODE)
@@ -427,7 +417,7 @@
}
}
*/
-//TODO: implement pixel packing?
+
/*
void glopPixelStore(GLContext* c, GLParam* p) {
GLint pname = p[1].i;
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -13,7 +13,7 @@
c->current_normal.W = 0;
}
-void glopTexCoord( GLParam* p) {
+void glopTexCoord(GLParam* p) {
GLContext* c = gl_get_context();
c->current_tex_coord.X = p[1].f;
c->current_tex_coord.Y = p[2].f;
@@ -21,7 +21,10 @@
c->current_tex_coord.W = p[4].f;
}
-void glopEdgeFlag(GLParam* p) {GLContext* c = gl_get_context(); c->current_edge_flag = p[1].i; }
+void glopEdgeFlag(GLParam* p) {
+ GLContext* c = gl_get_context();
+ c->current_edge_flag = p[1].i;
+}
void glopColor(GLParam* p) {
GLContext* c = gl_get_context();
@@ -43,19 +46,18 @@
}
}
-
void glopBegin(GLParam* p) {
GLint type;
M4 tmp;
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->in_begin != 0)
+ if (c->in_begin != 0)
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- //if(c->in_begin != 0)return; //<COST>
+
#endif
- type = p[1].i;
+ type = p[1].i;
c->begin_type = type;
c->in_begin = 1;
c->vertex_n = 0;
@@ -74,9 +76,11 @@
/* test to accelerate computation */
c->matrix_model_projection_no_w_transform = 0;
if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0)
- //if(c->matrix_model_projection.m[3][0] == 0.0 &&
- // c->matrix_model_projection.m[3][1] == 0.0 &&
- // c->matrix_model_projection.m[3][2] == 0.0)
+ /*
+ if(c->matrix_model_projection.m[3][0] == 0.0 &&
+ c->matrix_model_projection.m[3][1] == 0.0 &&
+ c->matrix_model_projection.m[3][2] == 0.0)
+ */
c->matrix_model_projection_no_w_transform = 1;
}
@@ -85,20 +89,21 @@
c->matrix_model_projection_updated = 0;
}
- /* viewport- this is now updated on a glViewport call. */
- //if (c->viewport.updated) {
- // gl_eval_viewport(c);
- // c->viewport.updated = 0;
- //}
- /* triangle drawing functions */
+ /* viewport- this is now updated on a glViewport call.
+ if (c->viewport.updated) {
+ gl_eval_viewport(c);
+ c->viewport.updated = 0;
+ }
+ triangle drawing functions
+ */
#if TGL_FEATURE_ALT_RENDERMODES == 1
if (c->render_mode == GL_SELECT) {
c->draw_triangle_front = gl_draw_triangle_select;
c->draw_triangle_back = gl_draw_triangle_select;
- }else if (c->render_mode == GL_FEEDBACK){
+ } else if (c->render_mode == GL_FEEDBACK) {
c->draw_triangle_front = gl_draw_triangle_feedback;
c->draw_triangle_back = gl_draw_triangle_feedback;
- } else
+ } else
#endif
{
switch (c->polygon_mode_front) {
@@ -108,7 +113,6 @@
case GL_LINE:
c->draw_triangle_front = gl_draw_triangle_line;
break;
- //case GL_FILL:
default:
c->draw_triangle_front = gl_draw_triangle_fill;
break;
@@ -128,7 +132,7 @@
}
}
-static inline void gl_transform_to_viewport_vertex_c(GLVertex* v) {
+static void gl_transform_to_viewport_vertex_c(GLVertex* v) {
GLContext* c = gl_get_context();
{
GLfloat winv = 1.0 / v->pc.W;
@@ -136,25 +140,23 @@
v->zp.y = (GLint)(v->pc.Y * winv * c->viewport.scale.Y + c->viewport.trans.Y);
v->zp.z = (GLint)(v->pc.Z * winv * c->viewport.scale.Z + c->viewport.trans.Z);
}
-
+
v->zp.r = (GLint)(v->color.v[0] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
v->zp.g = (GLint)(v->color.v[1] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
v->zp.b = (GLint)(v->color.v[2] * COLOR_CORRECTED_MULT_MASK + COLOR_MIN_MULT) & COLOR_MASK;
-
- if (c->texture_2d_enabled)
- {
- v->zp.s = (GLint)(v->tex_coord.X * (ZB_POINT_S_MAX - ZB_POINT_S_MIN) + ZB_POINT_S_MIN); //MARKED
- v->zp.t = (GLint)(v->tex_coord.Y * (ZB_POINT_T_MAX - ZB_POINT_T_MIN) + ZB_POINT_T_MIN); //MARKED
+ if (c->texture_2d_enabled) {
+ v->zp.s = (GLint)(v->tex_coord.X * (ZB_POINT_S_MAX - ZB_POINT_S_MIN) + ZB_POINT_S_MIN);
+ v->zp.t = (GLint)(v->tex_coord.Y * (ZB_POINT_T_MAX - ZB_POINT_T_MIN) + ZB_POINT_T_MIN);
}
}
-static inline void gl_vertex_transform(GLVertex* v) {
- GLfloat* m;GLContext* c = gl_get_context();
+static void gl_vertex_transform(GLVertex* v) {
+ GLfloat* m;
+ GLContext* c = gl_get_context();
+ if (c->lighting_enabled)
- if (c->lighting_enabled)
-
{
/* eye coordinates needed for lighting */
V4* n;
@@ -181,7 +183,7 @@
if (c->normalize_enabled) {
gl_V3_Norm_Fast(&v->normal);
}
- }
+ }
else {
/* no eye coordinates needed, no normal */
@@ -206,14 +208,14 @@
GLint n, i, cnt;
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->in_begin == 0)
+ if (c->in_begin == 0)
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- //assert(c->in_begin != 0);
+
#endif
- n = c->vertex_n;
+ n = c->vertex_n;
cnt = c->vertex_cnt;
cnt++;
c->vertex_cnt = cnt;
@@ -227,7 +229,7 @@
v->coord.Z = p[3].f;
v->coord.W = p[4].f;
- gl_vertex_transform( v);
+ gl_vertex_transform(v);
/* color */
@@ -234,13 +236,13 @@
if (c->lighting_enabled) {
gl_shade_vertex(v);
#include "error_check.h"
-//^ Don't proceed on an OUT OF MEMORY error.
+
} else {
v->color = c->current_color;
}
/* tex coords */
#if TGL_OPTIMIZATION_HINT_BRANCH_COST < 1
- if (c->texture_2d_enabled)
+ if (c->texture_2d_enabled)
#endif
{
if (c->apply_texture_matrix) {
@@ -253,103 +255,103 @@
#if TGL_OPTIMIZATION_HINT_BRANCH_COST < 2
if (v->clip_code == 0)
#endif
- { gl_transform_to_viewport_vertex_c(v);}
+ {
+ gl_transform_to_viewport_vertex_c(v);
+ }
/* edge flag */
v->edge_flag = c->current_edge_flag;
switch (c->begin_type) {
- case GL_POINTS:
- gl_draw_point(&c->vertex[0]);
- n = 0;
- break;
+ case GL_POINTS:
+ gl_draw_point(&c->vertex[0]);
+ n = 0;
+ break;
- case GL_LINES:
- if (n == 2) {
- gl_draw_line(&c->vertex[0], &c->vertex[1]);
- n = 0;
- }
- break;
- case GL_LINE_STRIP:
+ case GL_LINES:
+ if (n == 2) {
+ gl_draw_line(&c->vertex[0], &c->vertex[1]);
+ n = 0;
+ }
+ break;
+ case GL_LINE_STRIP:
#if TGL_FEATURE_GL_POLYGON == 1
- case GL_LINE_LOOP:
+ case GL_LINE_LOOP:
#endif
- switch(n){
- case 1:
- {
- c->vertex[2] = c->vertex[0];
- }
- break;
- case 2:
- {
- gl_draw_line(&c->vertex[0], &c->vertex[1]);
- c->vertex[0] = c->vertex[1];
- n = 1;
- }
- break;
- default:
- break;
- };
+ switch (n) {
+ case 1: {
+ c->vertex[2] = c->vertex[0];
+ } break;
+ case 2: {
+ gl_draw_line(&c->vertex[0], &c->vertex[1]);
+ c->vertex[0] = c->vertex[1];
+ n = 1;
+ } break;
+ default:
break;
- case GL_TRIANGLES:
- if (n == 3) {
- gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
+ };
+ break;
+ case GL_TRIANGLES:
+ if (n == 3) {
+ gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
+ n = 0;
+ }
+ break;
+ case GL_TRIANGLE_STRIP:
+ if (cnt >= 3) {
+ if (n == 3)
n = 0;
- }
- break;
- case GL_TRIANGLE_STRIP:
- if (cnt >= 3) {
- if (n == 3)
- n = 0;
- /* needed to respect triangle orientation */
- switch (cnt & 1) {
- case 0:
- gl_draw_triangle(&c->vertex[2], &c->vertex[1], &c->vertex[0]);
- break;
- default:
- case 1:
- gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
- break;
- }
- }
- break;
- case GL_TRIANGLE_FAN:
- if (n == 3) {
+ /* needed to respect triangle orientation */
+ switch (cnt & 1) {
+ case 0:
+ gl_draw_triangle(&c->vertex[2], &c->vertex[1], &c->vertex[0]);
+ break;
+ default:
+ case 1:
gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
- c->vertex[1] = c->vertex[2];
- n = 2;
+ break;
}
- break;
+ }
+ break;
+ case GL_TRIANGLE_FAN:
+ if (n == 3) {
+ gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
+ c->vertex[1] = c->vertex[2];
+ n = 2;
+ }
+ break;
- case GL_QUADS:
- if (n == 4) {
- c->vertex[2].edge_flag = 0;
- gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
- c->vertex[2].edge_flag = 1;
- c->vertex[0].edge_flag = 0;
- gl_draw_triangle(&c->vertex[0], &c->vertex[2], &c->vertex[3]);
- n = 0;
- }
- break;
+ case GL_QUADS:
+ if (n == 4) {
+ c->vertex[2].edge_flag = 0;
+ gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
+ c->vertex[2].edge_flag = 1;
+ c->vertex[0].edge_flag = 0;
+ gl_draw_triangle(&c->vertex[0], &c->vertex[2], &c->vertex[3]);
+ n = 0;
+ }
+ break;
- case GL_QUAD_STRIP:
- if (n == 4) {
- gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
- gl_draw_triangle(&c->vertex[1], &c->vertex[3], &c->vertex[2]);
- for (i = 0; i < 2; i++)
- c->vertex[i] = c->vertex[i + 2];
- n = 2;
- }
- break;
+ case GL_QUAD_STRIP:
+ if (n == 4) {
+ gl_draw_triangle(&c->vertex[0], &c->vertex[1], &c->vertex[2]);
+ gl_draw_triangle(&c->vertex[1], &c->vertex[3], &c->vertex[2]);
+ for (i = 0; i < 2; i++)
+ c->vertex[i] = c->vertex[i + 2];
+ n = 2;
+ }
+ break;
#if TGL_FEATURE_GL_POLYGON == 1
- case GL_POLYGON:break;
+ case GL_POLYGON:
+ break;
#endif
#if TGL_FEATURE_ERROR_CHECK == 1
- default:
- gl_fatal_error("glBegin: type %x not handled\n", c->begin_type);
+ default:
+ gl_fatal_error("glBegin: type %x not handled\n", c->begin_type);
#else
- default:break;
+ default:
+ break;
#endif
}
@@ -359,29 +361,28 @@
void glopEnd(GLParam* param) {
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
- if(c->in_begin != 1)
+ if (c->in_begin != 1)
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
#else
- //assert(c->in_begin == 1);
- //Assume it went alright.
+
+ /* Assume it went alright.*/
#endif
-//#if TGL_FEATURE_GL_POLYGON == 1
-//#endif
+
+
#if TGL_FEATURE_GL_POLYGON == 1
if (c->begin_type == GL_LINE_LOOP) {
- if (c->vertex_cnt >= 3) {
- gl_draw_line(&c->vertex[0], &c->vertex[2]);
+ if (c->vertex_cnt >= 3) {
+ gl_draw_line(&c->vertex[0], &c->vertex[2]);
+ }
+ } else if (c->begin_type == GL_POLYGON) {
+ GLint i = c->vertex_cnt;
+ while (i >= 3) {
+ i--;
+ gl_draw_triangle(&c->vertex[i], &c->vertex[0], &c->vertex[i - 1]);
+ }
}
- }
- else if (c->begin_type == GL_POLYGON) {
- GLint i = c->vertex_cnt;
- while (i >= 3) {
- i--;
- gl_draw_triangle(&c->vertex[i], &c->vertex[0], &c->vertex[i - 1]);
- }
- }
-#endif
+#endif
c->in_begin = 0;
}
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -3,15 +3,15 @@
* Z buffer: 16 bits Z / 16 bits color
*
*/
-//#include <stdio.h>
+
#include <stdlib.h>
#include <string.h>
-//#include "../include/GL/gl.h"
+
#include "../include/zbuffer.h"
#include "msghandling.h"
ZBuffer* ZB_open(GLint xsize, GLint ysize, GLint mode,
-// GLint nb_colors, GLubyte* color_indexes, GLint* color_table,
- void* frame_buffer) {
+
+ void* frame_buffer) {
ZBuffer* zb;
GLint size;
@@ -19,19 +19,20 @@
if (zb == NULL)
return NULL;
- zb->xsize = xsize & ~3; //The xsize will ALWAYS be a multiple of four!
+ zb->xsize = xsize & ~3;
zb->ysize = ysize;
- //zb->mode = mode;
- //zb->linesize = (xsize * PSZB + 3) & ~3;
+
+
zb->linesize = (xsize * PSZB);
switch (mode) {
#if TGL_FEATURE_32_BITS == 1
- case ZB_MODE_RGBA: break;
+ case ZB_MODE_RGBA:
+ break;
#endif
#if TGL_FEATURE_16_BITS == 1
case ZB_MODE_5R6G5B:
- break;
+ break;
#endif
default:
@@ -65,10 +66,6 @@
}
void ZB_close(ZBuffer* zb) {
-//#if TGL_FEATURE_8_BITS == 1
-// if (zb->mode == ZB_MODE_INDEX)
-// ZB_closeDither(zb);
-//#endif
if (zb->frame_buffer_allocated)
gl_free(zb->pbuf);
@@ -91,13 +88,15 @@
gl_free(zb->zbuf);
zb->zbuf = gl_malloc(size);
- if(zb->zbuf == NULL) exit(1);
+ if (zb->zbuf == NULL)
+ exit(1);
if (zb->frame_buffer_allocated)
gl_free(zb->pbuf);
if (frame_buffer == NULL) {
zb->pbuf = gl_malloc(zb->ysize * zb->linesize);
- if(!zb->pbuf) exit(1);
+ if (!zb->pbuf)
+ exit(1);
zb->frame_buffer_allocated = 1;
} else {
zb->pbuf = frame_buffer;
@@ -106,26 +105,26 @@
}
#if TGL_FEATURE_32_BITS == 1
-inline PIXEL pxReverse32(PIXEL x) {
-
+ PIXEL pxReverse32(PIXEL x) {
return
- // Source is in format: 0xAARRGGBB
- ((x & 0xFF000000) >> 24) | //______AA
- ((x & 0x00FF0000) >> 8) | //____RR__
- ((x & 0x0000FF00) << 8) | //__GG____
- ((x & 0x000000FF) << 24); // BB______
- // Return value is in format: 0xBBGGRRAA
+ ((x & 0xFF000000) >> 24) | /*______AA*/
+ ((x & 0x00FF0000) >> 8) | /*____RR__*/
+ ((x & 0x0000FF00) << 8) | /*__GG____*/
+ ((x & 0x000000FF) << 24); /* BB______*/
}
#endif
static void ZB_copyBuffer(ZBuffer* zb, void* buf, GLint linesize) {
+ GLint y, i;
#if TGL_FEATURE_MULTITHREADED_ZB_COPYBUFFER == 1
#pragma omp parallel for
- for (GLint y = 0; y < zb->ysize; y++) {
- PIXEL* q = zb->pbuf + y * zb->xsize;
- GLubyte* p1 = buf + y * linesize;
+ for (y = 0; y < zb->ysize; y++) {
+ PIXEL* q;
+ GLubyte* p1;
+ q = zb->pbuf + y * zb->xsize;
+ p1 = buf + y * linesize;
#if TGL_FEATURE_NO_COPY_COLOR == 1
- for (GLint i = 0; i < zb->xsize; i++) {
+ for (i = 0; i < zb->xsize; i++) {
if ((*(q + i) & TGL_COLOR_MASK) != TGL_NO_COPY_COLOR)
*(((PIXEL*)p1) + i) = *(q + i);
}
@@ -132,15 +131,17 @@
#else
memcpy(p1, q, linesize);
#endif
- //p1 += linesize;
- //q = (PIXEL*)((GLbyte*)q + zb->linesize);
+
+
}
#else
- for (GLint y = 0; y < zb->ysize; y++) {
- PIXEL* q = zb->pbuf + y * zb->xsize;
- GLubyte* p1 = buf + y * linesize;
+ for (y = 0; y < zb->ysize; y++) {
+ PIXEL* q;
+ GLubyte* p1;
+ q = zb->pbuf + y * zb->xsize;
+ p1 = buf + y * linesize;
#if TGL_FEATURE_NO_COPY_COLOR == 1
- for (GLint i = 0; i < zb->xsize; i++) {
+ for (i = 0; i < zb->xsize; i++) {
if ((*(q + i) & TGL_COLOR_MASK) != TGL_NO_COPY_COLOR)
*(((PIXEL*)p1) + i) = *(q + i);
}
@@ -147,8 +148,6 @@
#else
memcpy(p1, q, linesize);
#endif
- //p1 += linesize;
- //q = (PIXEL*)((GLbyte*)q + zb->linesize);
}
#endif
}
@@ -170,7 +169,7 @@
p1 = (gb >> 16) | ((v & 0xF8000000) >> 8);\
}
-//This function is never called.
+
static void ZB_copyFrameBufferRGB32(ZBuffer * zb,
void *buf,
GLint linesize)
@@ -181,7 +180,7 @@
q = zb->pbuf;
p1 = (GLuint *) buf;
- //puts("\nBEING CALLED\n");
+
for (y = 0; y < zb->ysize; y++) {
p = p1;
n = zb->xsize >> 2;
@@ -291,149 +290,27 @@
void ZB_copyFrameBuffer(ZBuffer* zb, void* buf, GLint linesize) {
ZB_copyBuffer(zb, buf, linesize);
- // switch (zb->mode) {
- /*
- #ifdef TGL_FEATURE_8_BITS
- case ZB_MODE_INDEX:
- ZB_ditherFrameBuffer(zb, buf, linesize >> 1);
- break;
- #endif
- */
- /*#ifdef TGL_FEATURE_16_BITS
- case ZB_MODE_5R6G5B:
- ZB_copyBuffer(zb, buf, linesize);
- break;
- #endif*/
-
- /*#ifdef TGL_FEATURE_32_BITS
- case ZB_MODE_RGBA:
- ZB_copyFrameBufferRGB32(zb, buf, linesize >> 1);
- break;
- #endif
- */
- // default:
- // assert(0);
- // }
}
-#endif /* TGL_FEATURE_RENDER_BITS == 16 */
+#endif
+/*^ TGL_FEATURE_RENDER_BITS == 16 */
-/*
-#if TGL_FEATURE_RENDER_BITS == 24
-
-#define RGB24_TO_RGB16(r, g, b) \
- ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
-
-// XXX: not optimized
-static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
- void *buf, GLint linesize)
-{
- PIXEL *q;
- GLushort *p, *p1;
- GLint y, n;
-
- q = zb->pbuf;
- p1 = (GLushort *) buf;
-
- for (y = 0; y < zb->ysize; y++) {
- p = p1;
- n = zb->xsize >> 2;
- do {
- p[0] = RGB24_TO_RGB16(q[0], q[1], q[2]);
- 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 *)((GLbyte *)q + 4 * PSZB);
- p += 4;
- } while (--n > 0);
- p1 = (GLushort *)((GLbyte *)p1 + linesize);
- }
-}
-
-void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
- GLint linesize)
-{
- switch (zb->mode) {
-#ifdef TGL_FEATURE_16_BITS
- case ZB_MODE_5R6G5B:
- ZB_copyFrameBuffer5R6G5B(zb, buf, linesize);
- break;
-#endif
-#ifdef TGL_FEATURE_24_BITS
- case ZB_MODE_RGB24:
- ZB_copyBuffer(zb, buf, linesize);
- break;
-#endif
- default:
- assert(0);
- }
-}
-
-#endif
-*/
-/* TGL_FEATURE_RENDER_BITS == 24
- */
-
#if TGL_FEATURE_RENDER_BITS == 32
#define RGB32_TO_RGB16(v) (((v >> 8) & 0xf800) | (((v) >> 5) & 0x07e0) | (((v)&0xff) >> 3))
-/* XXX: not optimized */
-/*
-static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb,
- void *buf, GLint linesize)
-{
- PIXEL *q;
- GLushort *p, *p1;
- GLint y, n;
- q = zb->pbuf;
- p1 = (GLushort *) buf;
-
- for (y = 0; y < zb->ysize; y++) {
- p = p1;
- n = zb->xsize >> 2;
- do {
- p[0] = RGB32_TO_RGB16(q[0]);
- p[1] = RGB32_TO_RGB16(q[1]);
- p[2] = RGB32_TO_RGB16(q[2]);
- p[3] = RGB32_TO_RGB16(q[3]);
- q += 4;
- p += 4;
- } while (--n > 0);
- p1 = (GLushort *)((GLbyte *)p1 + linesize);
- }
-}
-*/
void ZB_copyFrameBuffer(ZBuffer* zb, void* buf, GLint linesize) {
ZB_copyBuffer(zb, buf, linesize);
- // switch (zb->mode) {
- /*
-#ifdef TGL_FEATURE_16_BITS
-case ZB_MODE_5R6G5B:
-ZB_copyFrameBuffer5R6G5B(zb, buf, linesize);
-break;
-#endif
- */
- /*
- #ifdef TGL_FEATURE_32_BITS
- case ZB_MODE_RGBA:
- ZB_copyBuffer(zb, buf, linesize);
- break;
- #endif
- default:
- assert(0);
- }
- */
}
-#endif /* TGL_FEATURE_RENDER_BITS == 32 */
+#endif
+/* ^TGL_FEATURE_RENDER_BITS == 32 */
/*
* adr must be aligned on an 'int'
*/
-// Used in 16 bit mode
static void memset_s(void* adr, GLint val, GLint count) {
GLint i, n, v;
GLuint* p;
@@ -457,11 +334,10 @@
*q++ = val;
}
-// Used in 32 bit mode
+/* Used in 32 bit mode*/
static void memset_l(void* adr, GLint val, GLint count) {
GLint i, n, v;
GLuint* p;
-
p = adr;
v = val;
n = count >> 2;
@@ -472,50 +348,15 @@
p[3] = v;
p += 4;
}
-
n = count & 3;
for (i = 0; i < n; i++)
*p++ = val;
}
-/* count must be a multiple of 4 and >= 4 */
-// Gek's note: Should never be used.
-static void memset_RGB24(void* adr, GLint r, GLint v, GLint b, long count) {
- long i, n;
- register long v1, v2, v3, *pt = (long*)(adr);
- GLubyte *p, R = (GLubyte)r, V = (GLubyte)v, B = (GLubyte)b;
-
- p = (GLubyte*)adr;
- *p++ = R;
- *p++ = V;
- *p++ = B;
- *p++ = R;
- *p++ = V;
- *p++ = B;
- *p++ = R;
- *p++ = V;
- *p++ = B;
- *p++ = R;
- *p++ = V;
- *p++ = B;
- v1 = *pt++;
- v2 = *pt++;
- v3 = *pt++;
- n = count >> 2;
- for (i = 1; i < n; i++) {
- *pt++ = v1;
- *pt++ = v2;
- *pt++ = v3;
- }
-}
-
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
GLuint color;
- //#endif
GLint y;
PIXEL* pp;
-
if (clear_z) {
memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
}
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -1,21 +1,21 @@
#ifndef _tgl_zgl_h_
#define _tgl_zgl_h_
#ifndef NDEBUG
-#define NDEBUG
+#define NDEBUG
#endif
#include "../include/GL/gl.h"
-#include "../include/zfeatures.h"
#include "../include/zbuffer.h"
+#include "../include/zfeatures.h"
#include "zmath.h"
#include <math.h>
#include <stdlib.h>
-//Needed for memcpy
+
#include <string.h>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
-//#define DEBUG
+
enum {
#define ADD_OP(a, b, c) OP_##a,
@@ -24,22 +24,22 @@
};
-//
+
#if TGL_FEATURE_GL_POLYGON == 1
-//Large enough for your nice juicy GL_POLYGONs
+
#define POLYGON_MAX_VERTEX 16
-#else
-//Just large enough for a quad!
+#else
+
#define POLYGON_MAX_VERTEX 4
#endif
/* Max # of specular light pow buffers */
#define MAX_SPECULAR_BUFFERS 32
-//#define MAX_SPECULAR_BUFFERS 16
+
/* # of entries in specular buffer */
#define SPECULAR_BUFFER_SIZE 512
/* specular buffer granularity */
-//#define SPECULAR_BUFFER_RESOLUTION 1024
+
#define MAX_MODELVIEW_STACK_DEPTH 32
#define MAX_PROJECTION_STACK_DEPTH 8
#define MAX_TEXTURE_STACK_DEPTH 8
@@ -47,7 +47,6 @@
#define MAX_TEXTURE_LEVELS 1
#define MAX_LIGHTS 16
-
#define VERTEX_ARRAY 0x0001
#define COLOR_ARRAY 0x0002
#define NORMAL_ARRAY 0x0004
@@ -60,8 +59,6 @@
#define TGL_OFFSET_LINE 0x2
#define TGL_OFFSET_POINT 0x4
-
-
typedef struct GLSpecBuf {
GLint shininess_i;
GLint last_used;
@@ -84,7 +81,7 @@
GLfloat cos_spot_cutoff;
/* we use a linked list to know which are the enabled lights */
- //Old system based on pointers
+
struct GLLight *next, *prev;
GLubyte enabled;
} GLLight;
@@ -105,7 +102,7 @@
V3 scale;
V3 trans;
GLint xmin, ymin, xsize, ysize;
-// GLint updated;
+
} GLViewport;
typedef union {
@@ -127,7 +124,7 @@
} GLList;
typedef struct GLVertex {
-
+
V3 normal;
V4 coord;
V4 tex_coord;
@@ -158,7 +155,7 @@
/* buffers */
#define MAX_BUFFERS 2048
-typedef struct GLBuffer{
+typedef struct GLBuffer {
void* data;
GLuint size;
} GLBuffer;
@@ -183,7 +180,7 @@
GLViewport viewport;
GLMaterial materials[2];
GLVertex vertex[POLYGON_MAX_VERTEX];
-
+
M4 matrix_model_view_inv;
M4 matrix_model_projection;
V4 ambient_light_model;
@@ -217,8 +214,6 @@
GLfloat* feedback_ptr;
#endif
-
-
GLint local_light_model;
GLint lighting_enabled;
GLint light_model_two_side;
@@ -229,13 +224,11 @@
GLint current_color_material_type;
/* textures */
-
+
GLint texture_2d_enabled;
-
-
/* current list */
-
+
GLint current_op_buffer_index;
GLint exec_flag, compile_flag, print_flag;
GLuint listbase;
@@ -245,13 +238,10 @@
GLint matrix_stack_depth_max[3];
-
GLint matrix_model_projection_updated;
GLint matrix_model_projection_no_w_transform;
GLint apply_texture_matrix;
-
-
/* current state */
GLint polygon_mode_back;
GLint polygon_mode_front;
@@ -261,14 +251,13 @@
GLint current_cull_face;
GLint cull_face_enabled;
GLint normalize_enabled;
-
/* selection */
#if TGL_FEATURE_ALT_RENDERMODES == 1
GLint render_mode;
-
+
GLint select_size;
-
+
GLint select_overflow;
GLint select_hits;
#endif
@@ -276,9 +265,9 @@
GLenum drawbuffer;
GLenum readbuffer;
/* feedback */
- //render_mode as seen above
-#if TGL_FEATURE_ALT_RENDERMODES == 1
+#if TGL_FEATURE_ALT_RENDERMODES == 1
+
GLuint feedback_size;
GLint feedback_hits;
GLubyte feedback_overflow;
@@ -287,9 +276,7 @@
GLuint name_stack[MAX_NAME_STACK_DEPTH];
GLint name_stack_size;
#endif
-
-
/* clear */
GLfloat clear_depth;
@@ -299,16 +286,15 @@
GLint in_begin;
GLint begin_type;
GLint vertex_n, vertex_cnt;
-
/* opengl 1.1 arrays */
-
+
GLint vertex_array_size;
GLint vertex_array_stride;
GLint normal_array_stride;
GLint color_array_size;
GLint color_array_stride;
-
+
GLint texcoord_array_size;
GLint texcoord_array_stride;
GLint client_states;
@@ -319,7 +305,7 @@
GLint offset_states;
/* opengl blending */
- // All the settings are in the Zbuffer!
+
/* specular buffer. could probably be shared between contexts,
but that wouldn't be 100% thread safe */
@@ -327,10 +313,9 @@
GLSpecBuf* specbuf_first;
GLint specbuf_used_counter;
GLint specbuf_num_buffers;
-#endif
- GLint zEnableSpecular; // Enable specular lighting
+#endif
+ GLint zEnableSpecular;
-
/* raster position */
GLint rasterpos_zz;
GLfloat pzoomx, pzoomy;
@@ -338,7 +323,7 @@
/* text */
GLTEXTSIZE textsize;
/* buffers */
- GLint boundarraybuffer;
+ GLint boundarraybuffer;
GLint boundvertexbuffer;
GLint boundnormalbuffer;
GLint boundcolorbuffer;
@@ -350,12 +335,12 @@
} GLContext;
extern GLContext gl_ctx;
-static inline GLContext* gl_get_context(void) { return &gl_ctx; }
-//void gl_add_op(GLParam* p);
+static GLContext* gl_get_context(void) { return &gl_ctx; }
+
extern void (*op_table_func[])(GLParam*);
extern GLint op_table_size[];
extern void gl_compile_op(GLParam* p);
-static inline void gl_add_op(GLParam* p) {
+static void gl_add_op(GLParam* p) {
GLContext* c = gl_get_context();
#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
@@ -369,30 +354,22 @@
#endif
}
if (c->compile_flag) {
- gl_compile_op( p);
+ gl_compile_op(p);
#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
#endif
}
- //if (c->print_flag) {
- // gl_print_op(stderr, p);
- //}
}
/* select.c */
-void gl_add_select( GLuint zmin, GLuint zmax);
-void gl_add_feedback( GLfloat token,
- GLVertex* v1,
- GLVertex* v2,
- GLVertex* v3,
- GLfloat passthrough_token_value
-);
+void gl_add_select(GLuint zmin, GLuint zmax);
+void gl_add_feedback(GLfloat token, GLVertex* v1, GLVertex* v2, GLVertex* v3, GLfloat passthrough_token_value);
/* clip.c */
#define CLIP_EPSILON (1E-5)
-//Many of Clip.c's functions are inlined.
-static inline GLint gl_clipcode(GLfloat x, GLfloat y, GLfloat z, GLfloat w1) {
+
+static GLint gl_clipcode(GLfloat x, GLfloat y, GLfloat z, GLfloat w1) {
GLfloat w;
w = w1 * (1.0 + CLIP_EPSILON);
@@ -406,7 +383,7 @@
#define CLIP_ZMIN (1 << 4)
#define CLIP_ZMAX (1 << 5)
-static inline GLfloat clampf(GLfloat a, GLfloat min, GLfloat max) {
+static GLfloat clampf(GLfloat a, GLfloat min, GLfloat max) {
if (a < min)
return min;
else if (a > max)
@@ -416,9 +393,8 @@
}
-//void gl_transform_to_viewport( GLVertex* v);
-//inline void gl_draw_triangle( GLVertex* p0, GLVertex* p1, GLVertex* p2);
+
/* triangle */
/*
@@ -432,18 +408,15 @@
-//inline void gl_draw_triangle_clip( GLVertex* p0, GLVertex* p1, GLVertex* p2, GLint clip_bit);
+void gl_draw_triangle(GLVertex* p0, GLVertex* p1, GLVertex* p2);
+void gl_draw_line(GLVertex* p0, GLVertex* p1);
+void gl_draw_point(GLVertex* p0);
-void gl_draw_triangle( GLVertex* p0, GLVertex* p1, GLVertex* p2);
-void gl_draw_line( GLVertex* p0, GLVertex* p1);
-void gl_draw_point( GLVertex* p0);
-
-
-void gl_draw_triangle_point( GLVertex* p0, GLVertex* p1, GLVertex* p2); //MUST BE FUNCTION POINTER
-void gl_draw_triangle_line( GLVertex* p0, GLVertex* p1, GLVertex* p2); //MUST BE FUNCTION POINTER
-void gl_draw_triangle_fill( GLVertex* p0, GLVertex* p1, GLVertex* p2); //MUST BE FUNCTION POINTER
-void gl_draw_triangle_select( GLVertex* p0, GLVertex* p1, GLVertex* p2); //MUST BE FUNCTION POINTER
-void gl_draw_triangle_feedback( GLVertex* p0, GLVertex* p1, GLVertex* p2); //MUST BE FUNCTION POINTER
+void gl_draw_triangle_point(GLVertex* p0, GLVertex* p1, GLVertex* p2);
+void gl_draw_triangle_line(GLVertex* p0, GLVertex* p1, GLVertex* p2);
+void gl_draw_triangle_fill(GLVertex* p0, GLVertex* p1, GLVertex* p2);
+void gl_draw_triangle_select(GLVertex* p0, GLVertex* p1, GLVertex* p2);
+void gl_draw_triangle_feedback(GLVertex* p0, GLVertex* p1, GLVertex* p2);
/* matrix.c */
void gl_print_matrix(const GLfloat* m);
/*
@@ -450,15 +423,13 @@
void glopLoadIdentity(GLParam *p);
void glopTranslate(GLParam *p);*/
-
-
/* light.c */
-void gl_enable_disable_light( GLint light, GLint v);
+void gl_enable_disable_light(GLint light, GLint v);
void gl_shade_vertex(GLVertex* v);
void glInitTextures();
void glEndTextures();
-GLTexture* alloc_texture( GLint h);
+GLTexture* alloc_texture(GLint h);
/* image_util.c */
void gl_convertRGB_to_5R6G5B(GLushort* pixmap, GLubyte* rgb, GLint xsize, GLint ysize);
@@ -466,12 +437,12 @@
void gl_resizeImage(GLubyte* dest, GLint xsize_dest, GLint ysize_dest, GLubyte* src, GLint xsize_src, GLint ysize_src);
void gl_resizeImageNoInterpolate(GLubyte* dest, GLint xsize_dest, GLint ysize_dest, GLubyte* src, GLint xsize_src, GLint ysize_src);
-//static GLContext* gl_get_context(void);
+
void gl_fatal_error(char* format, ...);
/* specular buffer "api" */
-GLSpecBuf* specbuf_get_buffer( const GLint shininess_i, const GLfloat shininess);
+GLSpecBuf* specbuf_get_buffer(const GLint shininess_i, const GLfloat shininess);
#ifdef __BEOS__
void dprintf(const char*, ...);
@@ -497,9 +468,7 @@
/* this clip epsilon is needed to avoid some rounding errors after
several clipping stages */
-
-
-static inline void gl_eval_viewport() {
+static void gl_eval_viewport() {
GLContext* c = gl_get_context();
GLViewport* v;
GLfloat zsize = (1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS));
@@ -514,6 +483,5 @@
v->scale.Y = -(v->ysize - 0.5) / 2.0;
v->scale.Z = -((zsize - 0.5) / 2.0);
}
-
#endif /* _tgl_zgl_h_ */
--- a/src/zline.c
+++ b/src/zline.c
@@ -7,24 +7,23 @@
/* TODO: Implement blending for lines and points. */
void ZB_plot(ZBuffer* zb, ZBufferPoint* p) {
-
-
- GLint zz;
- GLubyte zbdw = zb->depth_write;
+
+ GLint zz, y, x;
+ GLubyte zbdw = zb->depth_write;
GLubyte zbdt = zb->depth_test;
GLfloat zbps = zb->pointsize;
TGL_BLEND_VARS
zz = p->z >> ZB_POINT_Z_FRAC_BITS;
- // PIXEL col;
- if(zbps == 1){
+
+ if (zbps == 1) {
GLushort* pz;
PIXEL* pp;
pz = zb->zbuf + (p->y * zb->xsize + p->x);
pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * p->y + p->x * PSZB);
-
+
if (ZCMP(zz, *pz)) {
#if TGL_FEATURE_BLEND == 1
- if(!zb->enable_blend)
+ if (!zb->enable_blend)
*pp = RGB_TO_PIXEL(p->r, p->g, p->b);
else
TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
@@ -31,45 +30,46 @@
#else
*pp = RGB_TO_PIXEL(p->r, p->g, p->b);
#endif
- if(zbdw)
+ if (zbdw)
*pz = zz;
}
} else {
PIXEL col = RGB_TO_PIXEL(p->r, p->g, p->b);
GLfloat hzbps = zbps / 2.0f;
- GLint bx = (GLfloat)p->x - hzbps; GLint ex = (GLfloat)p->x + hzbps;
- GLint by = (GLfloat)p->y - hzbps; GLint ey = (GLfloat)p->y + hzbps;
- bx = (bx<0)?0:bx;
- by = (by<0)?0:by;
- ex = (ex>zb->xsize)?zb->xsize:ex;
- ey = (ey>zb->ysize)?zb->ysize:ey;
- for(GLint y = by; y < ey; y++)
- for(GLint x = bx; x < ex; x++)
- {
- GLushort* pz = zb->zbuf + (y * zb->xsize + x);
- PIXEL* pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * y + x * PSZB);
- //zz = p->z >> ZB_POINT_Z_FRAC_BITS;
- if (ZCMP(zz, *pz)) {
+ GLint bx = (GLfloat)p->x - hzbps;
+ GLint ex = (GLfloat)p->x + hzbps;
+ GLint by = (GLfloat)p->y - hzbps;
+ GLint ey = (GLfloat)p->y + hzbps;
+ bx = (bx < 0) ? 0 : bx;
+ by = (by < 0) ? 0 : by;
+ ex = (ex > zb->xsize) ? zb->xsize : ex;
+ ey = (ey > zb->ysize) ? zb->ysize : ey;
+ for (y = by; y < ey; y++)
+ for (x = bx; x < ex; x++) {
+ GLushort* pz = zb->zbuf + (y * zb->xsize + x);
+ PIXEL* pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * y + x * PSZB);
+
+ if (ZCMP(zz, *pz)) {
#if TGL_FEATURE_BLEND == 1
- if(!zb->enable_blend)
- *pp = col;
- else
- TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
+ if (!zb->enable_blend)
+ *pp = col;
+ else
+ TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
#else
- *pp = col;
+ *pp = col;
#endif
- if(zbdw)
- *pz = zz;
+ if (zbdw)
+ *pz = zz;
+ }
}
- }
}
}
#define INTERP_Z
static void ZB_line_flat_z(ZBuffer* zb, ZBufferPoint* p1, ZBufferPoint* p2, GLint color) {
- //GLubyte zbdw = zb->depth_write;
+
GLubyte zbdt = zb->depth_test;
- GLubyte zbdw = zb->depth_write;
+ GLubyte zbdw = zb->depth_write;
#include "zline.h"
}
@@ -77,9 +77,9 @@
#define INTERP_Z
#define INTERP_RGB
static void ZB_line_interp_z(ZBuffer* zb, ZBufferPoint* p1, ZBufferPoint* p2) {
- //GLubyte zbdw = zb->depth_write;
+
GLubyte zbdt = zb->depth_test;
- GLubyte zbdw = zb->depth_write;
+ GLubyte zbdw = zb->depth_write;
#include "zline.h"
}
@@ -86,20 +86,20 @@
/* no Z GLinterpolation */
static void ZB_line_flat(ZBuffer* zb, ZBufferPoint* p1, ZBufferPoint* p2, GLint color) {
- //GLubyte zbdw = zb->depth_write;
- //GLubyte zbdt = zb->depth_test;
+
+
#include "zline.h"
}
#define INTERP_RGB
static void ZB_line_interp(ZBuffer* zb, ZBufferPoint* p1, ZBufferPoint* p2) {
-// GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+
#include "zline.h"
}
void ZB_line_z(ZBuffer* zb, ZBufferPoint* p1, ZBufferPoint* p2) {
GLint color1, color2;
-// GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+
color1 = RGB_TO_PIXEL(p1->r, p1->g, p1->b);
color2 = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
--- a/src/zline.h
+++ b/src/zline.h
@@ -39,7 +39,7 @@
#ifdef INTERP_RGB
#define RGB(x) x
#define RGBPIXEL *pp = RGB_TO_PIXEL(r >> 8, g >> 8, b >> 8)
-//#define RGBPIXEL TGL_BLEND_FUNC_RGB(r>>8, g>>8, b>>8, (*pp))
+
#else /* INTERP_RGB */
#define RGB(x)
@@ -47,7 +47,7 @@
#define RGBPIXEL pp[0] = r, pp[1] = g, pp[2] = b
#else
#define RGBPIXEL *pp = color
-//#define RGBPIXEL *pp = color
+
#endif
#endif /* INTERP_RGB */
@@ -58,7 +58,9 @@
zz = z >> ZB_POINT_Z_FRAC_BITS; \
if (ZCMP(zz, *pz)) { \
RGBPIXEL; \
- if(zbdw) {*pz = zz;} \
+ if (zbdw) { \
+ *pz = zz; \
+ } \
} \
}
#else /* INTERP_Z */
--- a/src/zmath.c
+++ b/src/zmath.c
@@ -9,45 +9,45 @@
/* ******* Gestion des matrices 4x4 ****** */
void gl_M4_Id(M4* a) {
-/*
- GLint i, j;
-#pragma omp simd collapse(2)
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- if (i == j)
- a->m[i][j] = 1.0;
- else
- a->m[i][j] = 0.0;
-*/
-const M4 c = (M4){{
- {1,0,0,0},
- {0,1,0,0},
- {0,0,1,0},
- {0,0,0,1},}
- };
-*a = c;
+ /*
+ GLint i, j;
+ #pragma omp simd collapse(2)
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ if (i == j)
+ a->m[i][j] = 1.0;
+ else
+ a->m[i][j] = 0.0;
+ */
+ const M4 c = (M4){{
+ {1, 0, 0, 0},
+ {0, 1, 0, 0},
+ {0, 0, 1, 0},
+ {0, 0, 0, 1},
+ }};
+ *a = c;
}
GLint gl_M4_IsId(M4* a) {
- //GLint i, j;
+
const M4 c = (M4){{
- {1,0,0,0},
- {0,1,0,0},
- {0,0,1,0},
- {0,0,0,1},}
- };
- return (memcmp(a->m,c.m, 16 * sizeof(GLfloat)) == 0);
-/*
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++) {
- if (i == j) {
- if (a->m[i][j] != 1.0)
+ {1, 0, 0, 0},
+ {0, 1, 0, 0},
+ {0, 0, 1, 0},
+ {0, 0, 0, 1},
+ }};
+ return (memcmp(a->m, c.m, 16 * sizeof(GLfloat)) == 0);
+ /*
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++) {
+ if (i == j) {
+ if (a->m[i][j] != 1.0)
+ return 0;
+ } else if (a->m[i][j] != 0.0)
return 0;
- } else if (a->m[i][j] != 0.0)
- return 0;
- }
- return 1;
-*/
+ }
+ return 1;
+ */
}
void gl_M4_Mul(M4* c, M4* a, M4* b) {
@@ -109,28 +109,28 @@
/* transposition of a 4x4 matrix */
void gl_M4_Transpose(M4* a, M4* b) {
-{
- a->m[0][0] = b->m[0][0];
- a->m[0][1] = b->m[1][0];
- a->m[0][2] = b->m[2][0];
- a->m[0][3] = b->m[3][0];
+ {
+ a->m[0][0] = b->m[0][0];
+ a->m[0][1] = b->m[1][0];
+ a->m[0][2] = b->m[2][0];
+ a->m[0][3] = b->m[3][0];
- a->m[1][0] = b->m[0][1];
- a->m[1][1] = b->m[1][1];
- a->m[1][2] = b->m[2][1];
- a->m[1][3] = b->m[3][1];
+ a->m[1][0] = b->m[0][1];
+ a->m[1][1] = b->m[1][1];
+ a->m[1][2] = b->m[2][1];
+ a->m[1][3] = b->m[3][1];
- a->m[2][0] = b->m[0][2];
- a->m[2][1] = b->m[1][2];
- a->m[2][2] = b->m[2][2];
- a->m[2][3] = b->m[3][2];
+ a->m[2][0] = b->m[0][2];
+ a->m[2][1] = b->m[1][2];
+ a->m[2][2] = b->m[2][2];
+ a->m[2][3] = b->m[3][2];
- a->m[3][0] = b->m[0][3];
- a->m[3][1] = b->m[1][3];
- a->m[3][2] = b->m[2][3];
- a->m[3][3] = b->m[3][3];
+ a->m[3][0] = b->m[0][3];
+ a->m[3][1] = b->m[1][3];
+ a->m[3][2] = b->m[2][3];
+ a->m[3][3] = b->m[3][3];
+ }
}
-}
/* inversion of an orthogonal matrix of type Y=M.X+P */
void gl_M4_InvOrtho(M4* a, M4 b) {
@@ -258,16 +258,13 @@
a->m[2][0] = (m->m[1][0] * m->m[2][1] - m->m[1][1] * m->m[2][0]) / det;
a->m[2][1] = -(m->m[0][0] * m->m[2][1] - m->m[0][1] * m->m[2][0]) / det;
a->m[2][2] = (m->m[0][0] * m->m[1][1] - m->m[0][1] * m->m[1][0]) / det;
-
}
/* vector arithmetic */
-//NEW
-// OLD
/*
int gl_V3_Norm(V3* a) {
GLfloat n;
--- a/src/zmath.h
+++ b/src/zmath.h
@@ -2,9 +2,9 @@
#define __ZMATH__
#include "../include/GL/gl.h"
#include "../include/zfeatures.h"
-#include <stdlib.h>
-#include <string.h> //For memcpy
#include <math.h>
+#include <stdlib.h>
+#include <string.h>
/* Matrix & Vertex */
typedef struct {
@@ -46,8 +46,6 @@
void gl_M4_MulLeft(M4* c, M4* a);
void gl_M4_Transpose(M4* a, M4* b);
void gl_M4_Rotate(M4* c, GLfloat t, GLint u);
-//int gl_V3_Norm(V3* a);
-//int gl_V3_Norm_Fast(V3* a);
@@ -56,31 +54,13 @@
GLint gl_Matrix_Inv(GLfloat* r, GLfloat* m, GLint n);
-/*
-static inline GLfloat fastInvSqrt(float x){
- GLint i; GLfloat y;
- memcpy(&i, &x, 4);
- i = 0x5f3759df - (i>>1);
- //y = (union{GLint l; GLfloat f; }){i}.f;
- memcpy(&y, &i, 4);
- return y * (1.5F - 0.5F * x * y * y);
-}
-*/
+
#if TGL_FEATURE_FISR == 1
-/*
-inline GLfloat fastInvSqrt(float x){
- union{GLfloat f; GLint i;} conv;
- conv.f = x;
- conv.i = 0x5F1FFFF9 - (conv.i>>1);
- conv.f *= 0.703952253f * (2.38924456f - x * conv.f * conv.f);
- return conv.f;
-}*/
-//Defined behavior fastinvsqrt
-static inline GLfloat fastInvSqrt(GLfloat x){
- GLint i;
+static GLfloat fastInvSqrt(GLfloat x) {
+ GLint i;
GLfloat x2;
memcpy(&i, &x, 4);
- i = 0x5F1FFFF9 - (i>>1);
+ i = 0x5F1FFFF9 - (i >> 1);
memcpy(&x2, &i, 4);
x2 *= 0.703952253f * (2.38924456f - x * x2 * x2);
return x2;
@@ -87,15 +67,14 @@
}
#endif
-
-static inline int gl_V3_Norm_Fast(V3* a) {
+static int gl_V3_Norm_Fast(V3* a) {
GLfloat n;
#if TGL_FEATURE_FISR == 1
- n = fastInvSqrt(a->X * a->X + a->Y * a->Y + a->Z * a->Z); //FISR
- if(n>1E+3)
+ n = fastInvSqrt(a->X * a->X + a->Y * a->Y + a->Z * a->Z);
+ if (n > 1E+3)
return 1;
#else
- n = sqrt(a->X * a->X + a->Y * a->Y + a->Z * a->Z); //NONFISR
+ n = sqrt(a->X * a->X + a->Y * a->Y + a->Z * a->Z);
if (n == 0)
return 1;
n = 1.0 / n;
@@ -106,4 +85,4 @@
return 0;
}
#endif
-// __ZMATH__
+
--- a/src/zpostprocess.c
+++ b/src/zpostprocess.c
@@ -2,11 +2,11 @@
#include "../include/zbuffer.h"
#include "zgl.h"
-void glPostProcess(GLuint (*postprocess)(GLint x, GLint y, GLuint pixel, GLushort z)){
- GLint i,j;
+void glPostProcess(GLuint (*postprocess)(GLint x, GLint y, GLuint pixel, GLushort z)) {
+ GLint i, j;
GLContext* c = gl_get_context();
#pragma omp parallel for collapse(2)
- for(j = 0; j < c->zb->ysize; j++)
- for(i = 0; i < c->zb->xsize; i++)
- c->zb->pbuf[i+j*(c->zb->xsize)] = postprocess(i,j,c->zb->pbuf[i+j*(c->zb->xsize)],c->zb->zbuf[i+j*(c->zb->xsize)]);
+ for (j = 0; j < c->zb->ysize; j++)
+ for (i = 0; i < c->zb->xsize; i++)
+ c->zb->pbuf[i + j * (c->zb->xsize)] = postprocess(i, j, c->zb->pbuf[i + j * (c->zb->xsize)], c->zb->zbuf[i + j * (c->zb->xsize)]);
}
--- a/src/zraster.c
+++ b/src/zraster.c
@@ -1,11 +1,11 @@
#include "../include/GL/gl.h"
#include "../include/zbuffer.h"
-#include "zgl.h"
#include "msghandling.h"
+#include "zgl.h"
-static inline void gl_vertex_transform_raster(GLVertex* v) {
+static void gl_vertex_transform_raster(GLVertex* v) {
GLContext* c = gl_get_context();
-
+
{
/* no eye coordinates needed, no normal */
/* NOTE: W = 1 is assumed */
@@ -15,7 +15,6 @@
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 {
@@ -31,8 +30,7 @@
v->clip_code = gl_clipcode(v->pc.X, v->pc.Y, v->pc.Z, v->pc.W);
}
-
-void glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w){
+void glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
GLParam p[5];
p[0].op = OP_RasterPos;
p[1].f = x;
@@ -41,7 +39,7 @@
p[4].f = w;
gl_add_op(p);
}
-void glopRasterPos(GLParam* p){
+void glopRasterPos(GLParam* p) {
GLContext* c = gl_get_context();
GLVertex v;
v.coord.X = p[1].f;
@@ -49,57 +47,49 @@
v.coord.Z = p[3].f;
v.coord.W = p[4].f;
gl_vertex_transform_raster(&v);
- if (v.clip_code == 0)
+ if (v.clip_code == 0) {
{
- {
- GLfloat winv = 1.0 / v.pc.W;
- v.zp.x = (GLint)(v.pc.X * winv * c->viewport.scale.X + c->viewport.trans.X);
- v.zp.y = (GLint)(v.pc.Y * winv * c->viewport.scale.Y + c->viewport.trans.Y);
- v.zp.z = (GLint)(v.pc.Z * winv * c->viewport.scale.Z + c->viewport.trans.Z);
-
- }
- c->rasterpos.v[0] = v.zp.x;
- c->rasterpos.v[1] = v.zp.y;
- c->rastervertex = v;
- //c->rasterpos.v[2] = v.zp.z;
- c->rasterpos_zz = v.zp.z >> ZB_POINT_Z_FRAC_BITS; //I believe this is it?
- c->rasterposvalid = 1;
+ GLfloat winv = 1.0 / v.pc.W;
+ v.zp.x = (GLint)(v.pc.X * winv * c->viewport.scale.X + c->viewport.trans.X);
+ v.zp.y = (GLint)(v.pc.Y * winv * c->viewport.scale.Y + c->viewport.trans.Y);
+ v.zp.z = (GLint)(v.pc.Z * winv * c->viewport.scale.Z + c->viewport.trans.Z);
}
- else
+ c->rasterpos.v[0] = v.zp.x;
+ c->rasterpos.v[1] = v.zp.y;
+ c->rastervertex = v;
+ /* c->rasterpos.v[2] = v.zp.z;*/
+ c->rasterpos_zz = v.zp.z >> ZB_POINT_Z_FRAC_BITS;
+ c->rasterposvalid = 1;
+ } else
c->rasterposvalid = 0;
}
-void glRasterPos2f(GLfloat x, GLfloat y){glRasterPos4f(x,y,0,1);}
-void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z){glRasterPos4f(x,y,z,1);}
+void glRasterPos2f(GLfloat x, GLfloat y) { glRasterPos4f(x, y, 0, 1); }
+void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) { glRasterPos4f(x, y, z, 1); }
-void glRasterPos2fv(GLfloat* v){glRasterPos2f(v[0],v[1]);}
-void glRasterPos3fv(GLfloat* v){glRasterPos3f(v[0],v[1],v[2]);}
-void glRasterPos4fv(GLfloat* v){glRasterPos4f(v[0],v[1],v[2],v[3]);}
+void glRasterPos2fv(GLfloat* v) { glRasterPos2f(v[0], v[1]); }
+void glRasterPos3fv(GLfloat* v) { glRasterPos3f(v[0], v[1], v[2]); }
+void glRasterPos4fv(GLfloat* v) { glRasterPos4f(v[0], v[1], v[2], v[3]); }
-
-void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void* data){
+void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void* data) {
/* TODO: Come up with a clever scheme for storing the data to avoid pointer dependency. */
#if TGL_FEATURE_RENDER_BITS == 32
- if( type != GL_UNSIGNED_INT &&
- type != GL_UNSIGNED_INT_8_8_8_8 )
- {
+ if (type != GL_UNSIGNED_INT && type != GL_UNSIGNED_INT_8_8_8_8) {
tgl_warning("\nERROR: Incorrect type for glDrawPixels. It MUST be GL_UNSIGNED_INT or GL_UNSIGNED_INT_8_8_8_8, A R G B!");
return;
}
#elif TGL_FEATURE_RENDER_BITS == 16
- if( type != GL_UNSIGNED_SHORT &&
- type != GL_UNSIGNED_SHORT_5_6_5)
- {
+ if (type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_SHORT_5_6_5) {
tgl_warning("\nERROR: Incorrect type for glDrawPixels. it MUST be GL_UNSIGNED_SHORT or GL_UNSIGNED_SHORT_5_6_5, R5 G6 B5!");
return;
}
-#else
+#else
#error "Bad TGL_FEATURE_RENDER_BITS"
#endif
- if( format != GL_RGB ){
- tgl_warning("\nERROR: Incorrect format for glDrawPixels.");
- return;
- }
+ if (format != GL_RGB) {
+ tgl_warning("\nERROR: Incorrect format for glDrawPixels.");
+ return;
+ }
GLParam p[6];
p[0].op = OP_DrawPixels;
p[1].i = width;
@@ -108,11 +98,11 @@
gl_add_op(p);
}
#define ZCMP(z, zpix) (!(zbdt) || z >= (zpix))
-#define CLIPTEST(_x,_y,_w,_h)((0<=_x) && (_w>_x) && (0<=_y) && (_h>_y))
-void glopDrawPixels(GLParam* p){
+#define CLIPTEST(_x, _y, _w, _h) ((0 <= _x) && (_w > _x) && (0 <= _y) && (_h > _y))
+void glopDrawPixels(GLParam* p) {
GLContext* c = gl_get_context();
- // p[3]
- if(!c->rasterposvalid) return;
+ GLint sy, sx, ty, tx;
+
GLint w = p[1].i;
GLint h = p[2].i;
V4 rastpos = c->rasterpos;
@@ -120,14 +110,13 @@
PIXEL* d = p[3].p;
PIXEL* pbuf = zb->pbuf;
GLushort* zbuf = zb->zbuf;
-
- GLubyte zbdw = zb->depth_write;
+
+ GLubyte zbdw = zb->depth_write;
GLubyte zbdt = zb->depth_test;
GLint tw = zb->xsize;
GLint th = zb->ysize;
GLfloat pzoomx = c->pzoomx;
GLfloat pzoomy = c->pzoomy;
-
GLint zz = c->rasterpos_zz;
#if TGL_FEATURE_BLEND_DRAW_PIXELS == 1
@@ -138,100 +127,92 @@
GLuint zbeb = zb->enable_blend;
#endif
#endif
- //Looping over the source pixels.
+ if (!c->rasterposvalid)return;
+
#if TGL_FEATURE_ALT_RENDERMODES == 1
- if(c->render_mode == GL_SELECT){
- gl_add_select( zz, zz);
+ if (c->render_mode == GL_SELECT) {
+ gl_add_select(zz, zz);
return;
- } else if(c->render_mode == GL_FEEDBACK){
- gl_add_feedback(
- GL_DRAW_PIXEL_TOKEN,
- &(c->rastervertex),
- NULL,
- NULL,
- 0
- );
+ } else if (c->render_mode == GL_FEEDBACK) {
+ gl_add_feedback(GL_DRAW_PIXEL_TOKEN, &(c->rastervertex), NULL, NULL, 0);
return;
}
#endif
-// Works.
+
#if TGL_FEATURE_MULTITHREADED_DRAWPIXELS == 1
#pragma omp parallel for
- for(GLint sy = 0; sy < h; sy++)
- for(GLint sx = 0; sx < w; sx++)
- {
- PIXEL col = d[sy*w+sx];
- V4 rastoffset;
- rastoffset.v[0] = rastpos.v[0] + (GLfloat)sx * pzoomx;
- rastoffset.v[1] = rastpos.v[1] - ((GLfloat)(h-sy) * pzoomy);
- rastoffset.v[2] = rastoffset.v[0] + pzoomx;
- rastoffset.v[3] = rastoffset.v[1] - pzoomy;
-
- for(GLint ty = rastoffset.v[1]; (GLfloat)ty > rastoffset.v[3];ty--)
- for(GLint tx = rastoffset.v[0]; (GLfloat)tx < rastoffset.v[2];tx++)
- if(CLIPTEST(tx,ty,tw,th)){
- GLushort* pz = zbuf + (ty * tw + tx);
+ for (sy = 0; sy < h; sy++)
+ for (sx = 0; sx < w; sx++) {
+ PIXEL col = d[sy * w + sx];
+ V4 rastoffset;
+ rastoffset.v[0] = rastpos.v[0] + (GLfloat)sx * pzoomx;
+ rastoffset.v[1] = rastpos.v[1] - ((GLfloat)(h - sy) * pzoomy);
+ rastoffset.v[2] = rastoffset.v[0] + pzoomx;
+ rastoffset.v[3] = rastoffset.v[1] - pzoomy;
- if(ZCMP(zz,*pz)){
+ for (ty = rastoffset.v[1]; (GLfloat)ty > rastoffset.v[3]; ty--)
+ for (tx = rastoffset.v[0]; (GLfloat)tx < rastoffset.v[2]; tx++)
+ if (CLIPTEST(tx, ty, tw, th)) {
+ GLushort* pz = zbuf + (ty * tw + tx);
+ if (ZCMP(zz, *pz)) {
+
#if TGL_FEATURE_BLEND == 1
#if TGL_FEATURE_BLEND_DRAW_PIXELS == 1
- if(!zbeb)
- pbuf[tx+ty*tw] = col;
- else
- TGL_BLEND_FUNC(col, pbuf[tx+ty*tw])
+ if (!zbeb)
+ pbuf[tx + ty * tw] = col;
+ else
+ TGL_BLEND_FUNC(col, pbuf[tx + ty * tw])
#else
- pbuf[tx+ty*tw] = col;
+ pbuf[tx + ty * tw] = col;
#endif
#else
- pbuf[tx+ty*tw] = col;
+ pbuf[tx + ty * tw] = col;
#endif
- if(zbdw) *pz = zz;
- }
- }
- }
+ if (zbdw)
+ *pz = zz;
+ }
+ }
+ }
#else
- for(GLint sy = 0; sy < h; sy++)
- for(GLint sx = 0; sx < w; sx++)
- {
- PIXEL col = d[sy*w+sx];
- V4 rastoffset;
- rastoffset.v[0] = rastpos.v[0] + (GLfloat)sx * pzoomx;
- rastoffset.v[1] = rastpos.v[1] - ((GLfloat)(h-sy) * pzoomy);
- rastoffset.v[2] = rastoffset.v[0] + pzoomx;
- rastoffset.v[3] = rastoffset.v[1] - pzoomy;
-
- for(GLint ty = rastoffset.v[1]; (GLfloat)ty > rastoffset.v[3];ty--)
- for(GLint tx = rastoffset.v[0]; (GLfloat)tx < rastoffset.v[2];tx++)
- if(CLIPTEST(tx,ty,tw,th)){
- GLushort* pz = zbuf + (ty * tw + tx);
+ for (sy = 0; sy < h; sy++)
+ for (sx = 0; sx < w; sx++) {
+ PIXEL col = d[sy * w + sx];
+ V4 rastoffset;
+ rastoffset.v[0] = rastpos.v[0] + (GLfloat)sx * pzoomx;
+ rastoffset.v[1] = rastpos.v[1] - ((GLfloat)(h - sy) * pzoomy);
+ rastoffset.v[2] = rastoffset.v[0] + pzoomx;
+ rastoffset.v[3] = rastoffset.v[1] - pzoomy;
- if(ZCMP(zz,*pz)){
+ for (ty = rastoffset.v[1]; (GLfloat)ty > rastoffset.v[3]; ty--)
+ for (tx = rastoffset.v[0]; (GLfloat)tx < rastoffset.v[2]; tx++)
+ if (CLIPTEST(tx, ty, tw, th)) {
+ GLushort* pz = zbuf + (ty * tw + tx);
+ if (ZCMP(zz, *pz)) {
+
#if TGL_FEATURE_BLEND == 1
#if TGL_FEATURE_BLEND_DRAW_PIXELS == 1
- if(!zbeb)
- pbuf[tx+ty*tw] = col;
- else
- TGL_BLEND_FUNC(col, pbuf[tx+ty*tw])
+ if (!zbeb)
+ pbuf[tx + ty * tw] = col;
+ else
+ TGL_BLEND_FUNC(col, pbuf[tx + ty * tw])
#else
- pbuf[tx+ty*tw] = col;
+ pbuf[tx + ty * tw] = col;
#endif
#else
- pbuf[tx+ty*tw] = col;
+ pbuf[tx + ty * tw] = col;
#endif
- if(zbdw) *pz = zz;
- }
- }
- }
+ if (zbdw)
+ *pz = zz;
+ }
+ }
+ }
#endif
}
-
-
-
-void glPixelZoom(GLfloat x, GLfloat y){
+void glPixelZoom(GLfloat x, GLfloat y) {
GLParam p[3];
p[0].op = OP_PixelZoom;
p[1].f = x;
@@ -239,7 +220,7 @@
gl_add_op(p);
}
-void glopPixelZoom(GLParam* p){
+void glopPixelZoom(GLParam* p) {
GLContext* c = gl_get_context();
c->pzoomx = p[1].f;
c->pzoomy = p[2].f;
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -3,9 +3,8 @@
#include "font8x8_basic.h"
#include "zgl.h"
-//#include <stdio.h>
+
#include <stdlib.h>
-//#include <string.h>
void glTextSize(GLTEXTSIZE mode) {
@@ -12,18 +11,21 @@
#define NEED_CONTEXT
#include "error_check_no_context.h"
#if TGL_FEATURE_ERROR_CHECK == 1
- if(mode < 1 || GL_MAX_TEXT_SIZE < mode)
+ if (mode < 1 || GL_MAX_TEXT_SIZE < mode)
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#endif
- GLParam p[2];
+ GLParam p[2];
p[0].op = OP_TextSize;
p[1].ui = mode;
gl_add_op(p);
}
-void glopTextSize(GLParam* p) { GLContext* c = gl_get_context(); c->textsize = p[1].ui; } // Set text size
-static inline void renderchar(GLbyte* bitmap, GLint _x, GLint _y, GLuint p) {
- GLint x, y;
+void glopTextSize(GLParam* p) {
+ GLContext* c = gl_get_context();
+ c->textsize = p[1].ui;
+}
+static void renderchar(GLbyte* bitmap, GLint _x, GLint _y, GLuint p) {
+ GLint x, y, i, j;
GLint set;
GLContext* c = gl_get_context();
GLint mult = c->textsize;
@@ -31,8 +33,8 @@
for (y = 0; y < 8; y++) {
set = bitmap[x] & (1 << y);
if (set)
- for (GLint i = 0; i < mult; i++)
- for (GLint j = 0; j < mult; j++)
+ for (i = 0; i < mult; i++)
+ for (j = 0; j < mult; j++)
glPlotPixel(y * mult + i + _x, x * mult + j + _y, p);
}
}
@@ -41,20 +43,9 @@
void glopPlotPixel(GLParam* p) {
GLContext* c = gl_get_context();
GLint x = p[1].i;
- PIXEL pix = p[2].ui;;
-/*
-#if TGL_FEATURE_BLEND == 1
- ZBuffer* zb = c->zb;
- PIXEL* targ = zb->pbuf + x;
- TGL_BLEND_VARS
- if(zb->enable_blend){
- TGL_BLEND_FUNC(pix, (*targ));
- }else{
- *targ = pix;
- }
-#else*/
+ PIXEL pix = p[2].ui;
c->zb->pbuf[x] = pix;
-//#endif
+
}
void glPlotPixel(GLint x, GLint y, GLuint pix) {
@@ -61,7 +52,7 @@
GLParam p[3];
GLContext* c = gl_get_context();
#include "error_check.h"
- // PIXEL* pbuf = gl_get_context()->zb->pbuf;
+
GLint w = c->zb->xsize;
GLint h = c->zb->ysize;
p[0].op = OP_PlotPixel;
@@ -68,7 +59,7 @@
if (x > -1 && x < w && y > -1 && y < h) {
#if TGL_FEATURE_RENDER_BITS == 16
- pix = RGB_TO_PIXEL((pix & COLOR_MULT_MASK), ((pix & 0xFF00)<<(COLOR_SHIFT - 8)), ((pix & 255) << COLOR_SHIFT) );
+ pix = RGB_TO_PIXEL((pix & COLOR_MULT_MASK), ((pix & 0xFF00) << (COLOR_SHIFT - 8)), ((pix & 255) << COLOR_SHIFT));
#endif
p[1].i = x + y * w;
p[2].ui = pix;
@@ -76,22 +67,22 @@
}
}
void glDrawText(const GLubyte* text, GLint x, GLint y, GLuint p) {
-GLContext* c = gl_get_context();
-GLint i = 0;
+ GLContext* c = gl_get_context();
+ GLint i = 0;
#include "error_check.h"
-
+
#if TGL_FEATURE_ERROR_CHECK == 1
if (!text)
#define ERROR_FLAG GL_INVALID_VALUE
#include "error_check.h"
#endif
- // PIXEL* pbuf = gl_get_context()->zb->pbuf;
- GLint w = c->zb->xsize;
+
+ GLint w = c->zb->xsize;
GLint h = c->zb->ysize;
GLint xoff = 0;
GLint yoff = 0;
GLint mult = c->textsize;
- for (;text[i] != '\0' && y + 7 < h; i++) {
+ for (; text[i] != '\0' && y + 7 < h; i++) {
if (text[i] != '\n' && xoff + x < w) {
renderchar(font8x8_basic[text[i]], x + xoff, y + yoff, p);
xoff += 8 * mult;
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -2,16 +2,14 @@
#include "msghandling.h"
#include <stdlib.h>
-//#include <stdio.h>
-//#warning STDIO INCLUDE!!!
-//TODO: Switch from scanline rasterizer to easily parallelized cross product rasterizer.
-static inline GLfloat edgeFunction(GLfloat ax, GLfloat ay, GLfloat bx, GLfloat by, GLfloat cx, GLfloat cy)
-{
- return (cx - ax) * (by - ay) - (cy - ay) * (bx - ax);
-}
+/* TODO: Switch from scanline rasterizer to easily parallelized cross product rasterizer.*/
+static GLfloat edgeFunction(GLfloat ax, GLfloat ay, GLfloat bx, GLfloat by, GLfloat cx, GLfloat cy) {
+ return (cx - ax) * (by - ay) - (cy - ay) * (bx - ax);
+}
+
#if TGL_FEATURE_RENDER_BITS == 32
#elif TGL_FEATURE_RENDER_BITS == 16
#else
@@ -20,37 +18,39 @@
#if TGL_FEATURE_POLYGON_STIPPLE == 1
-#define TGL_STIPPLEVARS GLubyte* zbstipplepattern = zb->stipplepattern; GLubyte zbdostipple = zb->dostipple;
+#define TGL_STIPPLEVARS \
+ GLubyte* zbstipplepattern = zb->stipplepattern; \
+ GLubyte zbdostipple = zb->dostipple;
#define THE_X ((GLint)(pp - pp1))
#define XSTIP(_a) ((THE_X + _a) & TGL_POLYGON_STIPPLE_MASK_X)
#define YSTIP (the_y & TGL_POLYGON_STIPPLE_MASK_Y)
-// NOTES Divide by 8 to get the byte Get the actual bit
+/* NOTES Divide by 8 to get the byte Get the actual bit*/
#define STIPBIT(_a) (zbstipplepattern[(XSTIP(_a) | (YSTIP << TGL_POLYGON_STIPPLE_POW2_WIDTH)) >> 3] & (1 << (XSTIP(_a) & 7)))
-#define STIPTEST(_a) && (!(zbdostipple && !STIPBIT(_a)))
+#define STIPTEST(_a) &&(!(zbdostipple && !STIPBIT(_a)))
#else
#define TGL_STIPPLEVARS /* a comment */
-#define STIPTEST(_a) /* a comment*/
+#define STIPTEST(_a) /* a comment*/
-
#endif
#if TGL_FEATURE_NO_DRAW_COLOR == 1
-#define NODRAWTEST(c) && ((c & TGL_COLOR_MASK) != TGL_NO_DRAW_COLOR)
+#define NODRAWTEST(c) &&((c & TGL_COLOR_MASK) != TGL_NO_DRAW_COLOR)
#else
#define NODRAWTEST(c) /* a comment */
#endif
-#define ZCMP(z, zpix, _a, c) ( ((!zbdt) || (z >= zpix)) STIPTEST(_a) NODRAWTEST(c))
-#define ZCMPSIMP(z, zpix, _a, crabapple) ( ((!zbdt) || (z >= zpix)) STIPTEST(_a) )
+#define ZCMP(z, zpix, _a, c) (((!zbdt) || (z >= zpix)) STIPTEST(_a) NODRAWTEST(c))
+#define ZCMPSIMP(z, zpix, _a, crabapple) (((!zbdt) || (z >= zpix)) STIPTEST(_a))
void ZB_fillTriangleFlat(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
-GLubyte zbdt = zb->depth_test;GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
+ GLubyte zbdw = zb->depth_write;
GLuint color;
TGL_BLEND_VARS
TGL_STIPPLEVARS
-
+
#undef INTERP_Z
#undef INTERP_RGB
#undef INTERP_ST
@@ -57,17 +57,21 @@
#undef INTERP_STZ
#define INTERP_Z
-//#define INTERP_RGB
-#define DRAW_INIT() {color=RGB_TO_PIXEL(p2->r, p2->g, p2->b);}
+#define DRAW_INIT() \
+ { color = RGB_TO_PIXEL(p2->r, p2->g, p2->b); }
+
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, color)) { \
- TGL_BLEND_FUNC(color, (pp[_a])) /*pp[_a] = color;*/ \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, color)) { \
+ TGL_BLEND_FUNC(color, (pp[_a])) /*pp[_a] = color;*/ \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
}
@@ -75,7 +79,9 @@
}
void ZB_fillTriangleFlatNOBLEND(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
- PIXEL color = RGB_TO_PIXEL(p2->r, p2->g, p2->b); GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+ PIXEL color = RGB_TO_PIXEL(p2->r, p2->g, p2->b);
+ GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
TGL_STIPPLEVARS
#undef INTERP_Z
#undef INTERP_RGB
@@ -82,16 +88,20 @@
#undef INTERP_ST
#undef INTERP_STZ
#define INTERP_Z
-//#define INTERP_RGB
-#define DRAW_INIT() { }
+#define DRAW_INIT() \
+ {}
+
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = color; \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ pp[_a] = color; \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
}
@@ -104,10 +114,11 @@
*/
void ZB_fillTriangleSmooth(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
- GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+ GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
TGL_BLEND_VARS
TGL_STIPPLEVARS
-// GLuint color;
+
#define INTERP_Z
#define INTERP_RGB
@@ -114,57 +125,60 @@
#define SAR_RND_TO_ZERO(v, n) (v / (1 << n))
#if TGL_FEATURE_RENDER_BITS == 32
-#define DRAW_INIT() {}
+#define DRAW_INIT() \
+ {}
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- /*pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);*/ \
- TGL_BLEND_FUNC_RGB(or1, og1, ob1, (pp[_a])); \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ /*pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);*/ \
+ TGL_BLEND_FUNC_RGB(or1, og1, ob1, (pp[_a])); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx; \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx; \
}
-// END OF 32 bit mode
+
#elif TGL_FEATURE_RENDER_BITS == 16
-#define DRAW_INIT() {}
+#define DRAW_INIT() \
+ {}
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- /*pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);*/ \
- TGL_BLEND_FUNC_RGB(or1, og1, ob1, (pp[_a])); \
- \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ /*pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);*/ \
+ TGL_BLEND_FUNC_RGB(or1, og1, ob1, (pp[_a])); \
+ \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx; \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx; \
}
-
-
#endif
-//^ End of 16 bit mode stuff
+
#include "ztriangle.h"
-} // EOF smooth fill triangle
+}
-
-
-
-
void ZB_fillTriangleSmoothNOBLEND(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
- GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+ GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
TGL_STIPPLEVARS
-// GLuint color;
+
#define INTERP_Z
#define INTERP_RGB
@@ -171,198 +185,155 @@
#define SAR_RND_TO_ZERO(v, n) (v / (1 << n))
#if TGL_FEATURE_RENDER_BITS == 32
-#define DRAW_INIT() {}
+#define DRAW_INIT() \
+ {}
#if TGL_FEATURE_NO_DRAW_COLOR != 1
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx; \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx; \
}
#else
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- /*c = RGB_TO_PIXEL(or1, og1, ob1);*/ \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = RGB_TO_PIXEL(or1,og1,ob1); \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ /*c = RGB_TO_PIXEL(or1, og1, ob1);*/ \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx; \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx; \
}
#endif
-// END OF 32 bit mode
+
#elif TGL_FEATURE_RENDER_BITS == 16
-#define DRAW_INIT() {}
+#define DRAW_INIT() \
+ {}
-
-
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); \
- \
- if(zbdw)pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); \
+ \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx; \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx; \
}
-
-
#endif
-//^ End of 16 bit mode stuff
+/* End of 16 bit mode stuff*/
#include "ztriangle.h"
-} // EOF smooth fill triangle
+}
+/*
+ TEXTURE MAPPED TRIANGLES
+ Section_Header
-
-
-//
-//
-// TEXTURE MAPPED TRIANGLES
-// Section_Header
-//
-//
-//
-//
-
+*/
void ZB_setTexture(ZBuffer* zb, PIXEL* texture) { zb->current_texture = texture; }
-// Ignore this it is never used
-/*
-void ZB_fillTriangleMapping(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
- PIXEL* texture;
-//#if TGL_FEATURE_NO_DRAW_COLOR == 1
- PIXEL c;
-//#endif
-//#define INTERP_Z
-//#define INTERP_ST
-//#define INTERP_RGB
-//#define DRAW_INIT() \ { texture = zb->current_texture; }
-//#if TGL_FEATURE_NO_DRAW_COLOR != 1
-//#define PUT_PIXEL(_a) \
+#if 1
+
+#define DRAW_LINE_TRI_TEXTURED() \
{ \
- register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = texture[((t & 0x3FC00000) | s) >> 14]; \
- pz[_a] = zz; \
+ register GLushort* pz; \
+ register PIXEL* pp; \
+ register GLuint s, t, z; \
+ register GLint n; \
+ OR1OG1OB1DECL \
+ GLfloat sz, tz, fzl, zinv; \
+ n = (x2 >> 16) - x1; \
+ fzl = (GLfloat)z1; \
+ zinv = 1.0 / fzl; \
+ pp = (PIXEL*)((GLbyte*)pp1 + x1 * PSZB); \
+ pz = pz1 + x1; \
+ z = z1; \
+ sz = sz1; \
+ tz = tz1; \
+ while (n >= (NB_INTERP - 1)) { \
+ register GLint dsdx, dtdx; \
+ { \
+ GLfloat ss, tt; \
+ ss = (sz * zinv); \
+ tt = (tz * zinv); \
+ s = (GLint)ss; \
+ t = (GLint)tt; \
+ dsdx = (GLint)((dszdx - ss * fdzdx) * zinv); \
+ dtdx = (GLint)((dtzdx - tt * fdzdx) * zinv); \
+ } \
+ fzl += fndzdx; \
+ zinv = 1.0 / fzl; \
+ PUT_PIXEL(0); /*the_x++;*/ \
+ PUT_PIXEL(1); /*the_x++;*/ \
+ PUT_PIXEL(2); /*the_x++;*/ \
+ PUT_PIXEL(3); /*the_x++;*/ \
+ PUT_PIXEL(4); /*the_x++;*/ \
+ PUT_PIXEL(5); /*the_x++;*/ \
+ PUT_PIXEL(6); /*the_x++;*/ \
+ PUT_PIXEL(7); /*the_x-=7;*/ \
+ pz += NB_INTERP; \
+ pp += NB_INTERP; /*the_x+=NB_INTERP * PSZB;*/ \
+ n -= NB_INTERP; \
+ sz += ndszdx; \
+ tz += ndtzdx; \
} \
- z += dzdx; \
- s += dsdx; \
- t += dtdx; \
- }
-//#else
-//#define PUT_PIXEL(_a) \
- { \
- register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- c = texture[((t & 0x3FC00000) | s) >> 14]; \
- if (ZCMP(zz, pz[_a], _a, c)) { \
- pp[_a] = c; \
- pz[_a] = zz; \
+ { \
+ register GLint dsdx, dtdx; \
+ { \
+ GLfloat ss, tt; \
+ ss = (sz * zinv); \
+ tt = (tz * zinv); \
+ s = (GLint)ss; \
+ t = (GLint)tt; \
+ dsdx = (GLint)((dszdx - ss * fdzdx) * zinv); \
+ dtdx = (GLint)((dtzdx - tt * fdzdx) * zinv); \
+ } \
+ while (n >= 0) { \
+ PUT_PIXEL(0); \
+ pz += 1; \
+ /*pp = (PIXEL*)((GLbyte*)pp + PSZB);*/ \
+ pp++; \
+ n -= 1; \
+ } \
} \
- z += dzdx; \
- s += dsdx; \
- t += dtdx; \
- }
-//#endif
-//#include "ztriangle.h"
-}
-*/
+ }
-#if 1 // IF 1
-
-
-
-
-#define DRAW_LINE_TRI_TEXTURED() \
- { \
- register GLushort* pz; \
- register PIXEL* pp; \
- register GLuint s, t, z; \
- register GLint n; \
- OR1OG1OB1DECL \
- GLfloat sz, tz, fzl, zinv; \
- n = (x2 >> 16) - x1; \
- fzl = (GLfloat)z1; \
- zinv = 1.0 / fzl; \
- pp = (PIXEL*)((GLbyte*)pp1 + x1 * PSZB); \
- pz = pz1 + x1; \
- z = z1; \
- sz = sz1; \
- tz = tz1; \
- while (n >= (NB_INTERP - 1)) { \
- register GLint dsdx, dtdx; \
- { \
- GLfloat ss, tt; \
- ss = (sz * zinv); \
- tt = (tz * zinv); \
- s = (GLint)ss; \
- t = (GLint)tt; \
- dsdx = (GLint)((dszdx - ss * fdzdx) * zinv); \
- dtdx = (GLint)((dtzdx - tt * fdzdx) * zinv); \
- } \
- fzl += fndzdx; \
- zinv = 1.0 / fzl; \
- PUT_PIXEL(0); /*the_x++;*/ \
- PUT_PIXEL(1); /*the_x++;*/ \
- PUT_PIXEL(2); /*the_x++;*/ \
- PUT_PIXEL(3); /*the_x++;*/ \
- PUT_PIXEL(4); /*the_x++;*/ \
- PUT_PIXEL(5); /*the_x++;*/ \
- PUT_PIXEL(6); /*the_x++;*/ \
- PUT_PIXEL(7); /*the_x-=7;*/ \
- pz += NB_INTERP; \
- pp += NB_INTERP; /*the_x+=NB_INTERP * PSZB;*/ \
- n -= NB_INTERP; \
- sz += ndszdx; \
- tz += ndtzdx; \
- } \
- { register GLint dsdx, dtdx; \
- { \
- GLfloat ss, tt; \
- ss = (sz * zinv); \
- tt = (tz * zinv); \
- s = (GLint)ss; \
- t = (GLint)tt; \
- dsdx = (GLint)((dszdx - ss * fdzdx) * zinv); \
- dtdx = (GLint)((dtzdx - tt * fdzdx) * zinv); \
- } \
- while (n >= 0) { \
- PUT_PIXEL(0); \
- pz += 1; \
- /*pp = (PIXEL*)((GLbyte*)pp + PSZB);*/ \
- pp ++; \
- n -= 1; \
- } \
- } \
- } //EOF draw line
-
void ZB_fillTriangleMappingPerspective(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
PIXEL* texture;
-
- GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+ GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
TGL_BLEND_VARS
TGL_STIPPLEVARS
#define INTERP_Z
@@ -369,7 +340,7 @@
#define INTERP_STZ
#define INTERP_RGB
-//NB_INTERP refers to some sort of texture mapping speedup enhancement.
+
#define NB_INTERP 8
#define DRAW_INIT() \
@@ -382,14 +353,14 @@
}
#if TGL_FEATURE_LIT_TEXTURES == 1
#define OR1OG1OB1DECL \
- register GLint or1, og1, ob1; \
+ register GLint or1, og1, ob1; \
or1 = r1; \
og1 = g1; \
ob1 = b1;
-#define OR1G1B1INCR \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx;
+#define OR1G1B1INCR \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx;
#else
#define OR1OG1OB1DECL /*A comment*/
#define OR1G1B1INCR /*Another comment*/
@@ -401,12 +372,15 @@
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- /*pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, TEXTURE_SAMPLE(texture, s, t));*/ \
- TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, (TEXTURE_SAMPLE(texture, s, t))), (pp[_a]) ); \
- if(zbdw) pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ /*pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, TEXTURE_SAMPLE(texture, s, t));*/ \
+ TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, (TEXTURE_SAMPLE(texture, s, t))), (pp[_a])); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
s += dsdx; \
t += dtdx; \
@@ -415,12 +389,15 @@
#else
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- PIXEL c = TEXTURE_SAMPLE(texture, s, t); \
- if (ZCMP(zz, pz[_a], _a, c)) { \
- TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, c), (pp[_a])); \
- if(zbdw) pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ PIXEL c = TEXTURE_SAMPLE(texture, s, t); \
+ if (ZCMP(zz, pz[_a], _a, c)) { \
+ TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, c), (pp[_a])); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
s += dsdx; \
t += dtdx; \
@@ -427,22 +404,17 @@
OR1G1B1INCR \
}
#endif
-#define DRAW_LINE() {DRAW_LINE_TRI_TEXTURED()}
+#define DRAW_LINE() \
+ { DRAW_LINE_TRI_TEXTURED() }
-
#include "ztriangle.h"
}
-
-
-
-
-
-
void ZB_fillTriangleMappingPerspectiveNOBLEND(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
PIXEL* texture;
- //GLfloat fdzdx, fndzdx, ndszdx, ndtzdx;
- GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+
+ GLubyte zbdw = zb->depth_write;
+ GLubyte zbdt = zb->depth_test;
TGL_STIPPLEVARS
#define INTERP_Z
#define INTERP_STZ
@@ -460,14 +432,14 @@
}
#if TGL_FEATURE_LIT_TEXTURES == 1
#define OR1OG1OB1DECL \
- register GLint or1, og1, ob1; \
+ register GLint or1, og1, ob1; \
or1 = r1; \
og1 = g1; \
ob1 = b1;
-#define OR1G1B1INCR \
- og1 += dgdx; \
- or1 += drdx; \
- ob1 += dbdx;
+#define OR1G1B1INCR \
+ og1 += dgdx; \
+ or1 += drdx; \
+ ob1 += dbdx;
#else
#define OR1OG1OB1DECL /*A comment*/
#define OR1G1B1INCR /*Another comment*/
@@ -478,11 +450,14 @@
#if TGL_FEATURE_NO_DRAW_COLOR != 1
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
- pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, TEXTURE_SAMPLE(texture, s, t)); \
- if(zbdw) pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
+ pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, TEXTURE_SAMPLE(texture, s, t)); \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
s += dsdx; \
t += dtdx; \
@@ -491,13 +466,16 @@
#else
#define PUT_PIXEL(_a) \
{ \
- {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
- PIXEL c = TEXTURE_SAMPLE(texture, s, t); \
- if (ZCMP(zz, pz[_a], _a, c)) { \
- pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, c); \
- /*TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, c), (pp[_a]));*/ \
- if(zbdw) pz[_a] = zz; \
- }} \
+ { \
+ register GLuint zz = z >> ZB_POINT_Z_FRAC_BITS; \
+ PIXEL c = TEXTURE_SAMPLE(texture, s, t); \
+ if (ZCMP(zz, pz[_a], _a, c)) { \
+ pp[_a] = RGB_MIX_FUNC(or1, og1, ob1, c); \
+ /*TGL_BLEND_FUNC(RGB_MIX_FUNC(or1, og1, ob1, c), (pp[_a]));*/ \
+ if (zbdw) \
+ pz[_a] = zz; \
+ } \
+ } \
z += dzdx; \
s += dsdx; \
t += dtdx; \
@@ -504,11 +482,9 @@
OR1G1B1INCR \
}
#endif
-#define DRAW_LINE() {DRAW_LINE_TRI_TEXTURED()}
+#define DRAW_LINE() \
+ { DRAW_LINE_TRI_TEXTURED() }
#include "ztriangle.h"
}
-
-#endif // if 1
-
-
+#endif
--- a/src/ztriangle.h
+++ b/src/ztriangle.h
@@ -23,8 +23,8 @@
GLfloat fdx1, fdx2, fdy1, fdy2;
GLushort* pz1;
PIXEL* pp1;
-
+ GLint part;
GLint dx1, dy1, dx2, dy2;
#if TGL_FEATURE_POLYGON_STIPPLE == 1
GLint the_y;
@@ -32,7 +32,7 @@
GLint error, derror;
GLint x1, dxdy_min, dxdy_max;
/* warning: x2 is multiplied by 2^16 */
- GLint x2, dx2dy2;
+ GLint x2=0, dx2dy2=0;
#ifdef INTERP_Z
GLint z1, dzdx, dzdy, dzdl_min, dzdl_max;
@@ -54,119 +54,119 @@
/* we sort the vertex with increasing y */
if (p1->y < p0->y) {
- ZBufferPoint *t = p0;
+ ZBufferPoint* t = p0;
p0 = p1;
p1 = t;
}
if (p2->y < p0->y) {
- ZBufferPoint *t = p2;
+ ZBufferPoint* t = p2;
p2 = p1;
p1 = p0;
p0 = t;
} else if (p2->y < p1->y) {
- ZBufferPoint *t = p1;
+ ZBufferPoint* t = p1;
p1 = p2;
p2 = t;
}
-
/* we compute dXdx and dXdy for all GLinterpolated values */
- fdx1 = p1->x - p0->x;//fdx1 first usage (VALUE_FDX1_USED)
- fdy1 = p1->y - p0->y;//fdy1 first usage (VALUE_FDY1_USED)
+ fdx1 = p1->x - p0->x;
+ fdy1 = p1->y - p0->y;
fdx2 = p2->x - p0->x;
fdy2 = p2->y - p0->y;
-
- GLfloat fz = fdx1 * fdy2 - fdx2 * fdy1;//fz first usage
+
+ GLfloat fz = fdx1 * fdy2 - fdx2 * fdy1;
/*
if (fz == 0)
return;
- fz = 1.0 / fz; //value of fz is used (VALUE_FZ_USED)
+ fz = 1.0 / fz;
*/
- if(fz != 0.0) fz = 1.0/fz;
- //for these (VALUE_FZ_USED)
+ if (fz != 0.0)
+ fz = 1.0 / fz;
+
fdx1 *= fz;
fdy1 *= fz;
fdx2 *= fz;
fdy2 *= fz;
- //and then
-{
-GLfloat d1, d2;
+
+ {
+ GLfloat d1, d2;
#ifdef INTERP_Z
-{
- d1 = p1->z - p0->z; //d1 first usage
- d2 = p2->z - p0->z;
- dzdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dzdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
+ {
+ d1 = p1->z - p0->z;
+ d2 = p2->z - p0->z;
+ dzdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ dzdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
#endif
#ifdef INTERP_RGB
-{
- d1 = p1->r - p0->r;
- d2 = p2->r - p0->r;
- drdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- drdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{
- d1 = p1->g - p0->g;
- d2 = p2->g - p0->g;
- dgdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dgdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{
- d1 = p1->b - p0->b;
- d2 = p2->b - p0->b;
- dbdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dbdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
+ {
+ d1 = p1->r - p0->r;
+ d2 = p2->r - p0->r;
+ drdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ drdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
+ {
+ d1 = p1->g - p0->g;
+ d2 = p2->g - p0->g;
+ dgdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ dgdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
+ {
+ d1 = p1->b - p0->b;
+ d2 = p2->b - p0->b;
+ dbdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ dbdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
#endif
#ifdef INTERP_ST
-{
- d1 = p1->s - p0->s;
- d2 = p2->s - p0->s;
- dsdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dsdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{
- d1 = p1->t - p0->t;
- d2 = p2->t - p0->t;
- dtdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dtdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
+ {
+ d1 = p1->s - p0->s;
+ d2 = p2->s - p0->s;
+ dsdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ dsdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
+ {
+ d1 = p1->t - p0->t;
+ d2 = p2->t - p0->t;
+ dtdx = (GLint)(fdy2 * d1 - fdy1 * d2);
+ dtdy = (GLint)(fdx1 * d2 - fdx2 * d1);
+ }
#endif
#ifdef INTERP_STZ
- {
- GLfloat zedzed;
- zedzed = (GLfloat)p0->z;
- p0->sz = (GLfloat)p0->s * zedzed;
- p0->tz = (GLfloat)p0->t * zedzed;
- zedzed = (GLfloat)p1->z;
- p1->sz = (GLfloat)p1->s * zedzed;
- p1->tz = (GLfloat)p1->t * zedzed;
- zedzed = (GLfloat)p2->z;
- p2->sz = (GLfloat)p2->s * zedzed;
- p2->tz = (GLfloat)p2->t * zedzed;
- }
- {
- d1 = p1->sz - p0->sz;
- d2 = p2->sz - p0->sz;
- dszdx = (fdy2 * d1 - fdy1 * d2);
- dszdy = (fdx1 * d2 - fdx2 * d1);
- }
- {
- d1 = p1->tz - p0->tz;
- d2 = p2->tz - p0->tz;
- dtzdx = (fdy2 * d1 - fdy1 * d2);
- dtzdy = (fdx1 * d2 - fdx2 * d1);
- }
+ {
+ GLfloat zedzed;
+ zedzed = (GLfloat)p0->z;
+ p0->sz = (GLfloat)p0->s * zedzed;
+ p0->tz = (GLfloat)p0->t * zedzed;
+ zedzed = (GLfloat)p1->z;
+ p1->sz = (GLfloat)p1->s * zedzed;
+ p1->tz = (GLfloat)p1->t * zedzed;
+ zedzed = (GLfloat)p2->z;
+ p2->sz = (GLfloat)p2->s * zedzed;
+ p2->tz = (GLfloat)p2->t * zedzed;
+ }
+ {
+ d1 = p1->sz - p0->sz;
+ d2 = p2->sz - p0->sz;
+ dszdx = (fdy2 * d1 - fdy1 * d2);
+ dszdy = (fdx1 * d2 - fdx2 * d1);
+ }
+ {
+ d1 = p1->tz - p0->tz;
+ d2 = p2->tz - p0->tz;
+ dtzdx = (fdy2 * d1 - fdy1 * d2);
+ dtzdy = (fdx1 * d2 - fdx2 * d1);
+ }
#endif
-} //EOF d1, d2 lifetimes.
+ }
/* screen coordinates */
- pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y; //pp1 first usage
+ pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y;
#if TGL_FEATURE_POLYGON_STIPPLE == 1
the_y = p0->y;
#endif
@@ -173,26 +173,28 @@
pz1 = zb->zbuf + p0->y * zb->xsize;
DRAW_INIT();
-//part used here and down.
-//TODO: #pragma omp parallel for private(a, b, c)
-//Required reading:
-//http://jakascorner.com/blog/2016/06/omp-data-sharing-attributes.html
-//I'd also like to figure out if the main while() loop over raster lines can be OMP parallelized, but I suspect it isn't worth it.
- ZBufferPoint *pr1, *pr2, *l1, *l2; //BEGINNING OF LIFETIME FOR ZBUFFERPOINT VARS!!!
- for (GLint part = 0; part < 2; part++) {
+ /*
+ part used here and down.
+ TODO: #pragma omp parallel for private(a, b, c)
+ Required reading:
+ jakascorner.com/blog/2016/06/omp-data-sharing-attributes.html
+ I'd also like to figure out if the main while() loop over raster lines can be OMP parallelized, but I suspect it isn't worth it.
+ */
+ ZBufferPoint *pr1, *pr2, *l1, *l2;
+ for (part = 0; part < 2; part++) {
GLint nb_lines;
{
- register GLint update_left, update_right; //update_left decl
+ register GLint update_left, update_right;
if (part == 0) {
- if (fz > 0) { //Here! (VALUE_FZ_USED)
- update_left = 1; //update_left first usage.
+ if (fz > 0) {
+ update_left = 1;
update_right = 1;
- l1 = p0; //MARK l1 first usage
- l2 = p2; //MARK l2 first usage
- pr1 = p0; //MARK first usage of pr1
- pr2 = p1; //MARK first usage pf pr2
+ l1 = p0;
+ l2 = p2;
+ pr1 = p0;
+ pr2 = p1;
} else {
- update_left = 1; //update_left second usage.
+ update_left = 1;
update_right = 1;
l1 = p0;
l2 = p1;
@@ -200,31 +202,30 @@
pr2 = p2;
}
nb_lines = p1->y - p0->y;
- } else { //SECOND PART~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ } else {
/* second part */
- if (fz > 0) { //fz last usage (VALUE_FZ_USED)
- update_left = 0; //update left third usage.
+ if (fz > 0) {
+ update_left = 0;
update_right = 1;
pr1 = p1;
pr2 = p2;
} else {
- update_left = 1; //4th
+ update_left = 1;
update_right = 0;
l1 = p1;
l2 = p2;
}
nb_lines = p2->y - p1->y + 1;
- } //EOF SECOND PART
-
+ }
/* compute the values for the left edge */
- //pr1 and pr2 are not used inside this area.
- if (update_left) { //5th usage
+ /*pr1 and pr2 are not used inside this area.*/
+ if (update_left) {
{
register GLint tmp;
dy1 = l2->y - l1->y;
dx1 = l2->x - l1->x;
if (dy1 > 0)
- tmp = (dx1 << 16) / dy1;
+ tmp = (dx1 << 16) / dy1;
else
tmp = 0;
x1 = l1->x;
@@ -265,20 +266,19 @@
dtzdl_min = (dtzdy + dtzdx * dxdy_min);
dtzdl_max = dtzdl_min + dtzdx;
#endif
- } //EOF update left
- //Is l1 used after update_left?
+ }
/* compute values for the right edge */
- if (update_right) { //Update right tested
+ if (update_right) { /*Update right tested*/
dx2 = (pr2->x - pr1->x);
- dy2 = (pr2->y - pr1->y); //LAST USAGE OF PR2
+ dy2 = (pr2->y - pr1->y); /*LAST USAGE OF PR2*/
if (dy2 > 0)
dx2dy2 = (dx2 << 16) / dy2;
else
dx2dy2 = 0;
- x2 = pr1->x << 16; //LAST USAGE OF PR1
- } //EOF update right
- } //End of lifetime for ZBufferpoints
+ x2 = pr1->x << 16; /*LAST USAGE OF PR1*/
+ } /*EOF update right*/
+ } /*End of lifetime for ZBufferpoints*/
/* we draw all the scan line of the part */
while (nb_lines > 0) {
@@ -299,11 +299,11 @@
register GLuint s, t;
#endif
#ifdef INTERP_STZ
- //GLfloat sz, tz; //These variables go unused in this draw line function.
+
#endif
n = (x2 >> 16) - x1;
- //pp = (PIXEL*)((GLbyte*)pp1 + x1 * PS_ZB);
+
pp = (PIXEL*)pp1 + x1;
#ifdef INTERP_Z
pz = pz1 + x1;
@@ -319,8 +319,8 @@
t = t1;
#endif
#ifdef INTERP_STZ
-// sz = sz1; //What is SZ used for?
-// tz = tz1; //What is TZ used for?
+
+
#endif
while (n >= 3) {
PUT_PIXEL(0); /*the_x++;*/
@@ -330,7 +330,7 @@
#ifdef INTERP_Z
pz += 4;
#endif
-// pp = (PIXEL*)((GLbyte*)pp + 4 * PS_ZB);
+
pp += 4;
n -= 4;
}
@@ -337,7 +337,7 @@
while (n >= 0) {
PUT_PIXEL(0); /*the_x++;*/
#ifdef INTERP_Z
- //pz += 1;
+
pz++;
#endif
/*pp = (PIXEL*)((GLbyte*)pp + PS_ZB);*/
@@ -346,7 +346,7 @@
}
}
#else
- DRAW_LINE();
+ DRAW_LINE();
#endif
/* left edge */
@@ -394,7 +394,7 @@
x2 += dx2dy2;
/* screen coordinates */
- //pp1 = (PIXEL*)((GLbyte*)pp1 + zb->linesize);
+
pp1 += zb->xsize;
#if TGL_FEATURE_POLYGON_STIPPLE == 1
the_y++;
--- a/src/ztriangle.h.backup
+++ /dev/null
@@ -1,398 +1,0 @@
-/*
- * An eXtReMeLy complicated, delicate, tuned triangle rasterizer
- * Aight, so basically this is the most complicated code you'll ever read in your life.
- * The lifetime of variables has been... SUPER Optimized, that's why there's so many random ass curly braces everywhere.
- * Yes, it is necessary to do that. This code is extremely delicate
- * and even a minor fuck-up is gonna tank the framerate
-
-Before committing any changes, run gears, model, and texture on your changed code to make sure you didn't
-fuck up!
-
-Things to keep in mind:
- 1) Tight control of the lifetimes of variables lets us use registers more often and memory less
- 2) Doing the same operation on multiple items is faster than doing different things on different items, generally, because
- they will be able to take advantage of any/all applicable SIMD/vector ops on your hardware.
- 3) Divide operations are vastly more expensive than add/sub/bitwise/etc
- 4) Bit shifting is your friend, it's the fast way to multiply or divide by 2.
- 5) Fixed point math is used for the depth "z" buffer
- 6) We're not just using floats for everything because this is still supposed to be fast on platforms without SSE2
- 7)
- */
-
-{
- GLfloat fdx1, fdx2, fdy1, fdy2;
- GLushort* pz1;
- PIXEL* pp1;
- GLint update_left, update_right;
-
- GLint nb_lines, dx1, dy1, dx2, dy2;
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- GLushort the_y;
-#endif
- GLint error, derror;
- GLint x1, dxdy_min, dxdy_max;
- /* warning: x2 is multiplied by 2^16 */
- GLint x2, dx2dy2;
-
-#ifdef INTERP_Z
- GLint z1, dzdx, dzdy, dzdl_min, dzdl_max;
-#endif
-#ifdef INTERP_RGB
- 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
- GLint s1, dsdx, dsdy, dsdl_min, dsdl_max;
- GLint t1, dtdx, dtdy, dtdl_min, dtdl_max;
-#endif
-#ifdef INTERP_STZ
- GLfloat sz1, dszdx, dszdy, dszdl_min, dszdl_max;
- GLfloat tz1, dtzdx, dtzdy, dtzdl_min, dtzdl_max;
-#endif
-
- /* we sort the vertex with increasing y */
- if (p1->y < p0->y) {
- ZBufferPoint *t = p0;
- p0 = p1;
- p1 = t;
- }
- if (p2->y < p0->y) {
- ZBufferPoint *t = p2;
- p2 = p1;
- p1 = p0;
- p0 = t;
- } else if (p2->y < p1->y) {
- ZBufferPoint *t = p1;
- p1 = p2;
- p2 = t;
- }
-
-
- /* we compute dXdx and dXdy for all GLinterpolated values */
- fdx1 = p1->x - p0->x;//fdx1 first usage (VALUE_FDX1_USED)
- fdy1 = p1->y - p0->y;//fdy1 first usage (VALUE_FDY1_USED)
-
- fdx2 = p2->x - p0->x;
- fdy2 = p2->y - p0->y;
-
- GLfloat fz = fdx1 * fdy2 - fdx2 * fdy1;//fz first usage
- if (fz == 0)
- return;
- fz = 1.0 / fz; //value of fz is used (VALUE_FZ_USED)
- //for these (VALUE_FZ_USED)
- fdx1 *= fz;
- fdy1 *= fz;
- fdx2 *= fz;
- fdy2 *= fz;
- //and then
-#ifdef INTERP_Z
-{
- GLfloat d1 = p1->z - p0->z; //d1 first usage
- GLfloat d2 = p2->z - p0->z;
- dzdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dzdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-#endif
-
-#ifdef INTERP_RGB
-{GLfloat d1, d2;
- d1 = p1->r - p0->r;
- d2 = p2->r - p0->r;
- drdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- drdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{GLfloat d1, d2;
- d1 = p1->g - p0->g;
- d2 = p2->g - p0->g;
- dgdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dgdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{GLfloat d1, d2;
- d1 = p1->b - p0->b;
- d2 = p2->b - p0->b;
- dbdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dbdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-#endif
-
-#ifdef INTERP_ST
-{GLfloat d1, d2;
- d1 = p1->s - p0->s;
- d2 = p2->s - p0->s;
- dsdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dsdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-{GLfloat d1, d2;
- d1 = p1->t - p0->t;
- d2 = p2->t - p0->t;
- dtdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dtdy = (GLint)(fdx1 * d2 - fdx2 * d1);
-}
-#endif
-
-#ifdef INTERP_STZ
- {
- GLfloat zedzed;
- zedzed = (GLfloat)p0->z;
- p0->sz = (GLfloat)p0->s * zedzed;
- p0->tz = (GLfloat)p0->t * zedzed;
- zedzed = (GLfloat)p1->z;
- p1->sz = (GLfloat)p1->s * zedzed;
- p1->tz = (GLfloat)p1->t * zedzed;
- zedzed = (GLfloat)p2->z;
- p2->sz = (GLfloat)p2->s * zedzed;
- p2->tz = (GLfloat)p2->t * zedzed;
- }
- {GLfloat d1, d2;
- d1 = p1->sz - p0->sz;
- d2 = p2->sz - p0->sz;
- dszdx = (fdy2 * d1 - fdy1 * d2);
- dszdy = (fdx1 * d2 - fdx2 * d1);
- }
- {GLfloat d1, d2;
- d1 = p1->tz - p0->tz;
- d2 = p2->tz - p0->tz;
- dtzdx = (fdy2 * d1 - fdy1 * d2);
- dtzdy = (fdx1 * d2 - fdx2 * d1);
- }
-#endif
-
- /* screen coordinates */
-
- pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y; //pp1 first usage
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y = p0->y;
-#endif
- pz1 = zb->zbuf + p0->y * zb->xsize;
-
- DRAW_INIT();
-//part used here and down.
- for (GLint part = 0; part < 2; part++) {
- {ZBufferPoint *pr1, *pr2, *l1, *l2; //BEGINNING OF LIFETIME FOR ZBUFFERPOINT VARS!!!
- if (part == 0) {
- if (fz > 0) { //Here! (VALUE_FZ_USED)
- update_left = 1;
- update_right = 1;
- l1 = p0; //MARK l1 first usage
- l2 = p2; //MARK l2 first usage
- pr1 = p0; //MARK first usage of pr1
- pr2 = p1; //MARK first usage pf pr2
- } else {
- update_left = 1;
- update_right = 1;
- l1 = p0;
- l2 = p1;
- pr1 = p0;
- pr2 = p2;
- }
- nb_lines = p1->y - p0->y;
- } else { //SECOND PART~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- /* second part */
- if (fz > 0) { //fz last usage (VALUE_FZ_USED)
- update_left = 0;
- update_right = 1;
- pr1 = p1;
- pr2 = p2;
- } else {
- update_left = 1;
- update_right = 0;
- l1 = p1;
- l2 = p2;
- }
- nb_lines = p2->y - p1->y + 1;
- } //EOF SECOND PART
-
- /* compute the values for the left edge */
- //pr1 and pr2 are not used inside this area.
- if (update_left) {
- {
- register GLint tmp;
- dy1 = l2->y - l1->y;
- dx1 = l2->x - l1->x;
- if (dy1 > 0)
- tmp = (dx1 << 16) / dy1;
- else
- tmp = 0;
- x1 = l1->x;
- error = 0;
- derror = tmp & 0x0000ffff;
- dxdy_min = tmp >> 16;
- }
- dxdy_max = dxdy_min + 1;
-#ifdef INTERP_Z
- z1 = l1->z;
- dzdl_min = (dzdy + dzdx * dxdy_min);
- dzdl_max = dzdl_min + dzdx;
-#endif
-#ifdef INTERP_RGB
- r1 = l1->r;
- drdl_min = (drdy + drdx * dxdy_min);
- drdl_max = drdl_min + drdx;
- g1 = l1->g;
- dgdl_min = (dgdy + dgdx * dxdy_min);
- dgdl_max = dgdl_min + dgdx;
- b1 = l1->b;
- dbdl_min = (dbdy + dbdx * dxdy_min);
- dbdl_max = dbdl_min + dbdx;
-#endif
-#ifdef INTERP_ST
- s1 = l1->s;
- dsdl_min = (dsdy + dsdx * dxdy_min);
- dsdl_max = dsdl_min + dsdx;
- t1 = l1->t;
- dtdl_min = (dtdy + dtdx * dxdy_min);
- dtdl_max = dtdl_min + dtdx;
-#endif
-#ifdef INTERP_STZ
- sz1 = l1->sz;
- dszdl_min = (dszdy + dszdx * dxdy_min);
- dszdl_max = dszdl_min + dszdx;
- tz1 = l1->tz;
- dtzdl_min = (dtzdy + dtzdx * dxdy_min);
- dtzdl_max = dtzdl_min + dtzdx;
-#endif
- } //EOF update left
- //Is l1 used after update_left?
- /* compute values for the right edge */
-
- if (update_right) {
- dx2 = (pr2->x - pr1->x);
- dy2 = (pr2->y - pr1->y); //LAST USAGE OF PR2
- if (dy2 > 0)
- dx2dy2 = (dx2 << 16) / dy2;
- else
- dx2dy2 = 0;
- x2 = pr1->x << 16; //LAST USAGE OF PR1
- } //EOF update right
- } //End of lifetime for ZBufferpoints
- /* we draw all the scan line of the part */
-
- while (nb_lines > 0) {
- nb_lines--;
-#ifndef DRAW_LINE
- /* generic draw line */
- {
- register PIXEL* pp;
- register GLint n;
-#ifdef INTERP_Z
- register GLushort* pz;
- register GLuint z;
-#endif
-#ifdef INTERP_RGB
- register GLuint or1, og1, ob1;
-#endif
-#ifdef INTERP_ST
- register GLuint s, t;
-#endif
-#ifdef INTERP_STZ
- //GLfloat sz, tz; //These variables go unused in this draw line function.
-#endif
-
- n = (x2 >> 16) - x1;
- //pp = (PIXEL*)((GLbyte*)pp1 + x1 * PSZB);
- pp = (PIXEL*)pp1 + x1;
-#ifdef INTERP_Z
- pz = pz1 + x1;
- z = z1;
-#endif
-#ifdef INTERP_RGB
- or1 = r1;
- og1 = g1;
- ob1 = b1;
-#endif
-#ifdef INTERP_ST
- s = s1;
- t = t1;
-#endif
-#ifdef INTERP_STZ
-// sz = sz1; //What is SZ used for?
-// tz = tz1; //What is TZ used for?
-#endif
- while (n >= 3) {
- PUT_PIXEL(0); /*the_x++;*/
- PUT_PIXEL(1); /*the_x++;*/
- PUT_PIXEL(2); /*the_x++;*/
- PUT_PIXEL(3); /*the_x++;*/
-#ifdef INTERP_Z
- pz += 4;
-#endif
-// pp = (PIXEL*)((GLbyte*)pp + 4 * PSZB);
- pp += 4;
- n -= 4;
- }
- while (n >= 0) {
- PUT_PIXEL(0); /*the_x++;*/
-#ifdef INTERP_Z
- pz += 1;
-#endif
- pp = (PIXEL*)((GLbyte*)pp + PSZB);
- n--;
- }
- }
-#else
- DRAW_LINE();
-#endif
-
- /* left edge */
- error += derror;
- if (error > 0) {
- error -= 0x10000;
- x1 += dxdy_max;
-#ifdef INTERP_Z
- z1 += dzdl_max;
-#endif
-#ifdef INTERP_RGB
- r1 += drdl_max;
- g1 += dgdl_max;
- b1 += dbdl_max;
-#endif
-#ifdef INTERP_ST
- s1 += dsdl_max;
- t1 += dtdl_max;
-#endif
-#ifdef INTERP_STZ
- sz1 += dszdl_max;
- tz1 += dtzdl_max;
-#endif
- } else {
- x1 += dxdy_min;
-#ifdef INTERP_Z
- z1 += dzdl_min;
-#endif
-#ifdef INTERP_RGB
- r1 += drdl_min;
- g1 += dgdl_min;
- b1 += dbdl_min;
-#endif
-#ifdef INTERP_ST
- s1 += dsdl_min;
- t1 += dtdl_min;
-#endif
-#ifdef INTERP_STZ
- sz1 += dszdl_min;
- tz1 += dtzdl_min;
-#endif
- }
-
- /* right edge */
- x2 += dx2dy2;
-
- /* screen coordinates */
- pp1 = (PIXEL*)((GLbyte*)pp1 + zb->linesize);
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y++;
-#endif
- pz1 += zb->xsize;
- }
- }
-}
-
-#undef INTERP_Z
-#undef INTERP_RGB
-#undef INTERP_ST
-#undef INTERP_STZ
-
-#undef DRAW_INIT
-#undef DRAW_LINE
-#undef PUT_PIXEL
--- a/src/ztriangle_tried_openmp_backup.h
+++ /dev/null
@@ -1,450 +1,0 @@
-/*
- * An eXtReMeLy complicated, delicate, tuned triangle rasterizer
- * Aight, so basically this is the most complicated code you'll ever read in your life.
- * The lifetime of variables has been... SUPER Optimized, that's why there's so many random ass curly braces everywhere.
- * Yes, it is necessary to do that. This code is extremely delicate
- * and even a minor fuck-up is gonna tank the framerate
-
-Before committing any changes, run gears, model, and texture on your changed code to make sure you didn't
-fuck up!
-
-Things to keep in mind:
- 1) Tight control of the lifetimes, scopes, and usage of variables lets us use registers more often and memory less
- 2) Doing the same operation on multiple items is faster than doing different things on different items, generally, because
- they will be able to take advantage of any/all applicable SIMD/vector ops on your hardware.
- 3) Divide operations are vastly more expensive than add/sub/bitwise/etc
- 4) Bit shifting is your friend, it's the fast way to multiply or divide by 2.
- 5) Fixed point math is used for the depth "z" buffer
- 6) We're not just using floats for everything because this is still supposed to be fast on platforms without SSE2
- 7) Fewer variables is usually better
- 8) All variables that are used inside the rasterizer loop must exist irrespective of feature level at the language level,
- because OpenMP needs to be able to declare them "private". The compiler will of course optimize out the unused ones.
- */
-
-#define BEGIN_SEGMENT
-
-{
- //All these variables are safe to be shared.
-
- //GLint dx1, dy1, dx2, dy2;
- //these VAR VAR_min, and VAR_max must be private.
-
-
-
-//#ifdef INTERP_Z
-
- GLint dzdx, dzdy;
-//#ifdef INTERP_RGB
-
- GLint drdx, drdy;
-
- GLint dgdx, dgdy;
-
- GLint dbdx, dbdy;
-
- GLint dsdx, dsdy;
-
- GLint dtdx, dtdy;
-
- GLfloat dszdx, dszdy;
-
- GLfloat dtzdx, dtzdy; //Not the cause of our problem.
- GLfloat fdzdx, fndzdx, ndszdx, ndtzdx;
-
- /* we sort the vertex with increasing y */
- if (p1->y < p0->y) {
- ZBufferPoint *t = p0;
- p0 = p1;
- p1 = t;
- }
- if (p2->y < p0->y) {
- ZBufferPoint *t = p2;
- p2 = p1;
- p1 = p0;
- p0 = t;
- } else if (p2->y < p1->y) {
- ZBufferPoint *t = p1;
- p1 = p2;
- p2 = t;
- }
-GLfloat fz;
-{GLfloat fdx1, fdx2, fdy1, fdy2;
- /* we compute dXdx and dXdy for all GLinterpolated values */
- fdx1 = p1->x - p0->x;//fdx1 first usage (VALUE_FDX1_USED)
- fdy1 = p1->y - p0->y;//fdy1 first usage (VALUE_FDY1_USED)
-
- fdx2 = p2->x - p0->x;
- fdy2 = p2->y - p0->y;
-
- fz = fdx1 * fdy2 - fdx2 * fdy1;//fz first usage
- if (fz == 0)
- return;
- fz = 1.0 / fz; //value of fz is used (VALUE_FZ_USED)
- //for these (VALUE_FZ_USED)
- fdx1 *= fz;
- fdy1 *= fz;
- fdx2 *= fz;
- fdy2 *= fz;
- //and then
- {
- GLfloat d1, d2;
- #ifdef INTERP_Z
- {
- d1 = p1->z - p0->z; //d1 first usage
- d2 = p2->z - p0->z;
- dzdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dzdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- #endif
-
- #ifdef INTERP_RGB
- {
- d1 = p1->r - p0->r;
- d2 = p2->r - p0->r;
- drdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- drdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- {
- d1 = p1->g - p0->g;
- d2 = p2->g - p0->g;
- dgdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dgdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- {
- d1 = p1->b - p0->b;
- d2 = p2->b - p0->b;
- dbdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dbdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- #endif
-
- #ifdef INTERP_ST
- {
- d1 = p1->s - p0->s;
- d2 = p2->s - p0->s;
- dsdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dsdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- {
- d1 = p1->t - p0->t;
- d2 = p2->t - p0->t;
- dtdx = (GLint)(fdy2 * d1 - fdy1 * d2);
- dtdy = (GLint)(fdx1 * d2 - fdx2 * d1);
- }
- #endif
-
- #ifdef INTERP_STZ
- {
- GLfloat zedzed;
- zedzed = (GLfloat)p0->z;
- p0->sz = (GLfloat)p0->s * zedzed;
- p0->tz = (GLfloat)p0->t * zedzed;
- zedzed = (GLfloat)p1->z;
- p1->sz = (GLfloat)p1->s * zedzed;
- p1->tz = (GLfloat)p1->t * zedzed;
- zedzed = (GLfloat)p2->z;
- p2->sz = (GLfloat)p2->s * zedzed;
- p2->tz = (GLfloat)p2->t * zedzed;
- }
- {
- d1 = p1->sz - p0->sz;
- d2 = p2->sz - p0->sz;
- dszdx = (fdy2 * d1 - fdy1 * d2);
- dszdy = (fdx1 * d2 - fdx2 * d1);
- }
- {
- d1 = p1->tz - p0->tz;
- d2 = p2->tz - p0->tz;
- dtzdx = (fdy2 * d1 - fdy1 * d2);
- dtzdy = (fdx1 * d2 - fdx2 * d1);
- }
- #endif
- }//EOF d1, d2 lifetimes.
-
-}//eof fdx1 fdx2 fdy1 fdy2 lifetimes.
- /* screen coordinates */
-
-/*
- pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y; //pp1 first usage
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y = p0->y;
-#endif
- pz1 = zb->zbuf + p0->y * zb->xsize;
-*/
- DRAW_INIT();
-//Required reading:
-//http://jakascorner.com/blog/2016/06/omp-data-sharing-attributes.html
-//I'd also like to figure out if the main while() loop over raster lines can be OMP parallelized, but I suspect it isn't worth it.
-#pragma omp parallel for num_threads(2)
- for (GLint part = 0; part < 2; part++) {
- //Variables specific to this part of the triangle.
-#define ZEROASSN =0
-//#define ZEROASSN /* a comment*/
-
- GLint x1 ZEROASSN, dxdy_min ZEROASSN, dxdy_max ZEROASSN;
- GLint z1 ZEROASSN, dzdl_min ZEROASSN, dzdl_max ZEROASSN;
- GLint r1 ZEROASSN, drdl_min ZEROASSN, drdl_max ZEROASSN;
- GLint g1 ZEROASSN, dgdl_min ZEROASSN, dgdl_max ZEROASSN;
- GLint b1 ZEROASSN, dbdl_min ZEROASSN, dbdl_max ZEROASSN;
- GLint s1 ZEROASSN, dsdl_min ZEROASSN, dsdl_max ZEROASSN;
- GLint t1 ZEROASSN, dtdl_min ZEROASSN, dtdl_max ZEROASSN;
- GLfloat sz1 ZEROASSN, dszdl_min ZEROASSN, dszdl_max ZEROASSN;
- GLfloat tz1 ZEROASSN, dtzdl_min ZEROASSN, dtzdl_max ZEROASSN;
- GLint nb_lines ZEROASSN;
- GLushort* pz1 ZEROASSN;
- PIXEL* pp1 ZEROASSN;
- GLint error ZEROASSN, derror ZEROASSN;
- GLfloat fzl = fz;
- GLint dx1 ZEROASSN, dy1 ZEROASSN, dx2 ZEROASSN, dy2 ZEROASSN;
- /* warning: x2 is multiplied by 2^16 */
- GLint x2 ZEROASSN, dx2dy2 ZEROASSN;
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- GLushort the_y ZEROASSN;
-#endif
- {ZBufferPoint *pr1, *pr2, *l1, *l2; //BEGINNING OF LIFETIME FOR ZBUFFERPOINT VARS!!!
- register GLint update_left, update_right; //update_left decl
- if (part == 0) {
- update_left = 1; //update_left first usage.
- update_right = 1;
-
- if (fzl > 0) { //Here! (VALUE_FZ_USED)
- l1 = p0; //MARK l1 first usage
- l2 = p2; //MARK l2 first usage
- pr1 = p0; //MARK first usage of pr1
- pr2 = p1; //MARK first usage pf pr2
- } else {
- l1 = p0;
- l2 = p1;
- pr1 = p0;
- pr2 = p2;
- }
- pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y; //pp1 first usage
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y = p0->y;
-#endif
- pz1 = zb->zbuf + p0->y * zb->xsize;
- nb_lines = p1->y - p0->y;
- } else { //SECOND PART~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- /* second part */
- if (fzl > 0) { //fzl last usage (VALUE_FZ_USED)
- update_left = 0;
- update_right = 1;
- pr1 = p1;
- pr2 = p2;
- } else {
- update_left = 1;
- update_right = 0;
- l1 = p1;
- l2 = p2;
- }
- pp1 = (PIXEL*)(zb->pbuf) + zb->xsize * p0->y + (zb->xsize * (p1->y - p0->y)); //pp1 update to second part.
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y = p1->y;
-#endif
- pz1 = zb->zbuf + p0->y * zb->xsize + (zb->xsize * (p1->y - p0->y));
- nb_lines = p2->y - p1->y + 1;
- } //EOF SECOND PART
-
- /* compute the values for the left edge */
- //pr1 and pr2 are not used inside this area.
- if (update_left)
- //if (1)
- {
- {
- register GLint tmp;
- dy1 = l2->y - l1->y;
- dx1 = l2->x - l1->x;
- if (dy1 > 0)
- tmp = (dx1 << 16) / dy1;
- else
- tmp = 0;
- x1 = l1->x;
- error = 0;
- derror = tmp & 0x0000ffff;
- dxdy_min = tmp >> 16;
- }
- dxdy_max = dxdy_min + 1;
-#ifdef INTERP_Z
- z1 = l1->z;
- dzdl_min = (dzdy + dzdx * dxdy_min);
- dzdl_max = dzdl_min + dzdx;
-#endif
-#ifdef INTERP_RGB
- r1 = l1->r;
- drdl_min = (drdy + drdx * dxdy_min);
- drdl_max = drdl_min + drdx;
- g1 = l1->g;
- dgdl_min = (dgdy + dgdx * dxdy_min);
- dgdl_max = dgdl_min + dgdx;
- b1 = l1->b;
- dbdl_min = (dbdy + dbdx * dxdy_min);
- dbdl_max = dbdl_min + dbdx;
-#endif
-#ifdef INTERP_ST
- s1 = l1->s;
- dsdl_min = (dsdy + dsdx * dxdy_min);
- dsdl_max = dsdl_min + dsdx;
- t1 = l1->t;
- dtdl_min = (dtdy + dtdx * dxdy_min);
- dtdl_max = dtdl_min + dtdx;
-#endif
-#ifdef INTERP_STZ
- sz1 = l1->sz;
- dszdl_min = (dszdy + dszdx * dxdy_min);
- dszdl_max = dszdl_min + dszdx;
- tz1 = l1->tz;
- dtzdl_min = (dtzdy + dtzdx * dxdy_min);
- dtzdl_max = dtzdl_min + dtzdx;
-#endif
- } //EOF update left
- //Is l1 used after update_left?
- /* compute values for the right edge */
-
- if (update_right)
- //if (1)
- { //Update right tested
- dx2 = (pr2->x - pr1->x);
- dy2 = (pr2->y - pr1->y); //LAST USAGE OF PR2
- if (dy2 > 0)
- dx2dy2 = (dx2 << 16) / dy2;
- else
- dx2dy2 = 0;
- x2 = pr1->x << 16; //LAST USAGE OF PR1
- } //EOF update right
- } //End of lifetime for ZBufferpoints
- /* we draw all the scan line of the part */
-
- //TODO: omp parallel for
- //for(GLint q = 0; q < nb_lines; q++)
- //for(; nb_lines > 0; nb_lines--) //Replaces the while.
- while(nb_lines>0)
- { nb_lines--; //Effectively matching the while.
-#ifndef DRAW_LINE
- /* generic draw line */
- {
- register PIXEL* pp;
- register GLint n;
-#ifdef INTERP_Z
- register GLushort* pz;
- register GLuint z;
-#endif
-#ifdef INTERP_RGB
- register GLint or1, og1, ob1;
-#endif
-#ifdef INTERP_ST
- register GLuint s, t;
-#endif
-#ifdef INTERP_STZ
- //GLfloat sz, tz; //These variables go unused in this draw line function.
-#endif
-
- n = (x2 >> 16) - x1;
- //pp = (PIXEL*)((GLbyte*)pp1 + x1 * PS_ZB);
- pp = (PIXEL*)pp1 + x1;
-#ifdef INTERP_Z
- pz = pz1 + x1;
- z = z1;
-#endif
-#ifdef INTERP_RGB
- or1 = r1;
- og1 = g1;
- ob1 = b1;
-#endif
-#ifdef INTERP_ST
- s = s1;
- t = t1;
-#endif
-#ifdef INTERP_STZ
-// sz = sz1; //What is SZ used for?
-// tz = tz1; //What is TZ used for?
-#endif
- while (n >= 3) {
- PUT_PIXEL(0); /*the_x++;*/
- PUT_PIXEL(1); /*the_x++;*/
- PUT_PIXEL(2); /*the_x++;*/
- PUT_PIXEL(3); /*the_x++;*/
-#ifdef INTERP_Z
- pz += 4;
-#endif
-// pp = (PIXEL*)((GLbyte*)pp + 4 * PS_ZB);
- pp += 4;
- n -= 4;
- }
- while (n >= 0) {
- PUT_PIXEL(0); /*the_x++;*/
-#ifdef INTERP_Z
- //pz += 1;
- pz++;
-#endif
- /*pp = (PIXEL*)((GLbyte*)pp + PS_ZB);*/
- pp++;
- n--;
- }
- }
-#else
- DRAW_LINE();
-#endif
-
- /* left edge */
- error += derror;
- if (error > 0) {
- error -= 0x10000;
- x1 += dxdy_max;
-#ifdef INTERP_Z
- z1 += dzdl_max;
-#endif
-#ifdef INTERP_RGB
- r1 += drdl_max;
- g1 += dgdl_max;
- b1 += dbdl_max;
-#endif
-#ifdef INTERP_ST
- s1 += dsdl_max;
- t1 += dtdl_max;
-#endif
-#ifdef INTERP_STZ
- sz1 += dszdl_max;
- tz1 += dtzdl_max;
-#endif
- } else {
- x1 += dxdy_min;
-#ifdef INTERP_Z
- z1 += dzdl_min;
-#endif
-#ifdef INTERP_RGB
- r1 += drdl_min;
- g1 += dgdl_min;
- b1 += dbdl_min;
-#endif
-#ifdef INTERP_ST
- s1 += dsdl_min;
- t1 += dtdl_min;
-#endif
-#ifdef INTERP_STZ
- sz1 += dszdl_min;
- tz1 += dtzdl_min;
-#endif
- }
-
- /* right edge */
- x2 += dx2dy2;
-
- /* screen coordinates */
- //pp1 = (PIXEL*)((GLbyte*)pp1 + zb->linesize);
- pp1 += zb->xsize;
-#if TGL_FEATURE_POLYGON_STIPPLE == 1
- the_y++;
-#endif
- pz1 += zb->xsize;
- }
- }
-}
-
-#undef INTERP_Z
-#undef INTERP_RGB
-#undef INTERP_ST
-#undef INTERP_STZ
-
-#undef DRAW_INIT
-#undef DRAW_LINE
-#undef PUT_PIXEL