X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fblocktube.c;h=486db6ff2ca547b188997c66d9df6ae90b7dd05f;hb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;hp=b38668b22ac2672e3f9b7515c0c59f34fe9dc30f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/blocktube.c b/hacks/glx/blocktube.c index b38668b2..486db6ff 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; @@ -197,7 +198,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 +216,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 +234,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 +260,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 +321,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 +337,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 +346,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 +355,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 +364,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 +375,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 +384,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 +409,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);