X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fblocktube.c;h=69605e7e3c48fc3c843103340e155f38a02d2c20;hb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;hp=b38668b22ac2672e3f9b7515c0c59f34fe9dc30f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/blocktube.c b/hacks/glx/blocktube.c index b38668b2..69605e7e 100644 --- a/hacks/glx/blocktube.c +++ b/hacks/glx/blocktube.c @@ -71,6 +71,7 @@ typedef struct { GLfloat tunnelLength; GLfloat tunnelWidth; + int polys; } blocktube_configuration; @@ -132,8 +133,10 @@ static Bool LoadGLTextures(ModeInfo *mi) GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, lp->texti->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +# ifndef HAVE_JWZGLES /* #### Sphere maps unimplemented */ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); +# endif } return status; } @@ -197,7 +200,7 @@ static void tick(blocktube_configuration *lp) } } -static void cube_vertices(float x, float y, float z, int wire); +static int cube_vertices(float x, float y, float z, int wire); ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height); @@ -215,7 +218,6 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) fprintf(stderr, "%s: out of memory\n", progname); exit(1); } - lp = &lps[MI_SCREEN(mi)]; } lp = &lps[MI_SCREEN(mi)]; @@ -234,7 +236,7 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) lp->block_dlist = glGenLists (1); glNewList (lp->block_dlist, GL_COMPILE); - cube_vertices(0.15, 1.2, 5.25, wire); + lp->polys = cube_vertices(0.15, 1.2, 5.25, wire); glEndList (); #if defined( I_HAVE_XPM ) @@ -260,7 +262,6 @@ ENTRYPOINT void init_blocktube (ModeInfo *mi) glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); if (!do_texture && !wire) { @@ -322,8 +323,9 @@ ENTRYPOINT void reshape_blocktube (ModeInfo *mi, int width, int height) glMatrixMode(GL_MODELVIEW); } -static void cube_vertices(float x, float y, float z, int wire) +static int cube_vertices(float x, float y, float z, int wire) { + int polygon_count = 0; float x2, y2, z2, nv = 0.7; x2 = x/2; y2 = y/2; @@ -337,6 +339,7 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(1.0, 0.0); glVertex3f( x2, y2, z2); glTexCoord2f(1.0, 1.0); glVertex3f( x2, -y2, z2); glTexCoord2f(0.0, 1.0); glVertex3f(-x2, -y2, z2); + polygon_count++; glEnd(); glNormal3f(0, 0, -nv); @@ -345,6 +348,7 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(1.0, 1.0); glVertex3f( x2, -y2, -z2); glTexCoord2f(0.0, 1.0); glVertex3f( x2, y2, -z2); glTexCoord2f(0.0, 0.0); glVertex3f(-x2, y2, -z2); + polygon_count++; glEnd(); glNormal3f(0, nv, 0); @@ -353,6 +357,7 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(0.0, 0.0); glVertex3f( x2, y2, -z2); glTexCoord2f(1.0, 0.0); glVertex3f( x2, y2, z2); glTexCoord2f(1.0, 1.0); glVertex3f(-x2, y2, z2); + polygon_count++; glEnd(); glNormal3f(0, -nv, 0); @@ -361,9 +366,10 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(0.0, 1.0); glVertex3f(-x2, -y2, z2); glTexCoord2f(0.0, 0.0); glVertex3f( x2, -y2, z2); glTexCoord2f(1.0, 0.0); glVertex3f( x2, -y2, -z2); + polygon_count++; glEnd(); - if (wire) return; + if (wire) return polygon_count; glNormal3f(nv, 0, 0); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); @@ -371,6 +377,7 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(1.0, 1.0); glVertex3f( x2, -y2, z2); glTexCoord2f(0.0, 1.0); glVertex3f( x2, y2, z2); glTexCoord2f(0.0, 0.0); glVertex3f( x2, y2, -z2); + polygon_count++; glEnd(); glNormal3f(-nv, 0, 0); @@ -379,13 +386,17 @@ static void cube_vertices(float x, float y, float z, int wire) glTexCoord2f(1.0, 0.0); glVertex3f(-x2, y2, -z2); glTexCoord2f(1.0, 1.0); glVertex3f(-x2, y2, z2); glTexCoord2f(0.0, 1.0); glVertex3f(-x2, -y2, z2); + polygon_count++; glEnd(); + + return polygon_count; } static void draw_block(ModeInfo *mi, entity *ent) { blocktube_configuration *lp = &lps[MI_SCREEN(mi)]; glCallList (lp->block_dlist); + mi->polygon_count += lp->polys; } ENTRYPOINT void @@ -400,6 +411,8 @@ draw_blocktube (ModeInfo *mi) if (!lp->glx_context) return; + mi->polygon_count = 0; + glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(lp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);