ref: e2e12c60ee18888709eaccaa8fc55b7c9fb3cf45
parent: c99b80721b808a9475068a8eafde9b7c3cac679e
author: David <gek@katherine>
date: Mon Feb 15 14:16:34 EST 2021
Perf improvement update
--- a/SDL_Examples/helloworld.c
+++ b/SDL_Examples/helloworld.c
@@ -230,7 +230,7 @@
// draw scene:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- draw2();
+ draw();
glDrawText((unsigned char*)"Hello World!\nFrom TinyGL", 0, 0, 0x00FFFFFF);
// swap buffers:
if ( SDL_MUSTLOCK(screen) && (SDL_LockSurface(screen)<0) ) {
--- a/include/zbuffer.h
+++ b/include/zbuffer.h
@@ -68,14 +68,17 @@
unsigned short *zbuf;
PIXEL *pbuf;
int frame_buffer_allocated;
- /* opengl polygon stipple*/
- int dostipple;
- unsigned char stipplepattern[TGL_POLYGON_STIPPLE_BYTES]; //32 bits wide, 32 bits tall. 32 * 4 bytes.
+
int nb_colors;
unsigned char *dctable;
int *ctable;
PIXEL *current_texture;
+ /* opengl polygon stipple*/
+ int dostipple;
+#if TGL_FEATURE_POLYGON_STIPPLE == 1
+ unsigned char stipplepattern[TGL_POLYGON_STIPPLE_BYTES];
+#endif
} ZBuffer;
typedef struct {
--- a/src/init.c
+++ b/src/init.c
@@ -131,8 +131,10 @@
c->current_shade_model=GL_SMOOTH;
c->cull_face_enabled=0;
c->zb->dostipple = 0;
+#if TGL_FEATURE_POLYGON_STIPPLE == 1
for(GLint i = 0; i < 128; i++)
c->zb->stipplepattern[i] = 0xFF;
+#endif
/* clear */
c->clear_color.v[0]=0;
c->clear_color.v[1]=0;
--- a/src/zbuffer.c
+++ b/src/zbuffer.c
@@ -138,15 +138,9 @@
GLubyte *p1;
PIXEL *q;
GLint y;
- #if !TGL_FEATURE_NO_COPY_COLOR
- //GLint n;
- #endif
q = zb->pbuf;
p1 = buf;
- #if !TGL_FEATURE_NO_COPY_COLOR
- //n = zb->xsize * PSZB;
- #endif
for (y = 0; y < zb->ysize; y++) {
#if TGL_FEATURE_NO_COPY_COLOR == 1
for(GLint i = 0; i < zb->xsize; i++)
@@ -157,8 +151,8 @@
#else
memcpy(p1, q, linesize);
#endif
- p1 += linesize; //TODO make this a predictable behavior.
- q = (PIXEL *) ((GLbyte *) q + zb->linesize);
+ p1 += linesize;
+ q = (PIXEL *) ((GLbyte *) q + zb->linesize);
}
}
@@ -536,9 +530,9 @@
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
- GLint color;
-#endif
+//#if TGL_FEATURE_RENDER_BITS != 24
+ GLuint color;
+//#endif
GLint y;
PIXEL *pp;