X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fpipes.c;h=59c203018b705c4bc7c42a7b5c43cf580b829bf7;hb=2d04c4f22466851aedb6ed0f2919d148f726b889;hp=9d81200967abf0a7daf049bf97a3b14f805d15da;hpb=a445bdd3e3ba4abbee441844b6665b4c3c13d48c;p=xscreensaver diff --git a/hacks/glx/pipes.c b/hacks/glx/pipes.c index 9d812009..59c20301 100644 --- a/hacks/glx/pipes.c +++ b/hacks/glx/pipes.c @@ -1,9 +1,8 @@ /* -*- Mode: C; tab-width: 4 -*- */ /* pipes --- 3D selfbuiding pipe system */ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)pipes.c 4.07 97/11/24 xlockmore"; - #endif /*- @@ -43,26 +42,21 @@ static const char sccsid[] = "@(#)pipes.c 4.07 97/11/24 xlockmore"; * 29-Apr-97: Efficiency speed-ups by Marcelo F. Vianna */ -/*- - * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock. - * otherwise caddr_t is not defined correctly - */ - -#include - #ifdef STANDALONE # define PROGCLASS "Pipes" # define HACK_INIT init_pipes # define HACK_DRAW draw_pipes # define HACK_RESHAPE reshape_pipes # define pipes_opts xlockmore_opts -# define DEFAULTS "*delay: 100 \n" \ +# define DEFAULTS "*delay: 10000 \n" \ "*count: 2 \n" \ "*cycles: 5 \n" \ "*size: 500 \n" \ "*showFPS: False \n" \ + "*fpsSolid: True \n" \ "*fisheye: True \n" \ "*tightturns: False \n" \ + "*doubleBuffer: True \n" \ "*rotatepipes: True \n" # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -78,34 +72,40 @@ static const char sccsid[] = "@(#)pipes.c 4.07 97/11/24 xlockmore"; #define DEF_FISHEYE "True" #define DEF_TIGHTTURNS "False" #define DEF_ROTATEPIPES "True" +#define DEF_DBUF "False" #define NofSysTypes 3 static int factory; static Bool fisheye, tightturns, rotatepipes; +static Bool dbuf_p; static XrmOptionDescRec opts[] = { - {"-factory", ".pipes.factory", XrmoptionSepArg, (caddr_t) NULL}, - {"-fisheye", ".pipes.fisheye", XrmoptionNoArg, (caddr_t) "on"}, - {"+fisheye", ".pipes.fisheye", XrmoptionNoArg, (caddr_t) "off"}, - {"-tightturns", ".pipes.tightturns", XrmoptionNoArg, (caddr_t) "on"}, - {"+tightturns", ".pipes.tightturns", XrmoptionNoArg, (caddr_t) "off"}, - {"-rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, (caddr_t) "on"}, - {"+rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, (caddr_t) "off"} + {"-factory", ".pipes.factory", XrmoptionSepArg, 0}, + {"-fisheye", ".pipes.fisheye", XrmoptionNoArg, "on"}, + {"+fisheye", ".pipes.fisheye", XrmoptionNoArg, "off"}, + {"-tightturns", ".pipes.tightturns", XrmoptionNoArg, "on"}, + {"+tightturns", ".pipes.tightturns", XrmoptionNoArg, "off"}, + {"-rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, "on"}, + {"+rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, "off"}, + {"-db", ".pipes.doubleBuffer", XrmoptionNoArg, "on"}, + {"+db", ".pipes.doubleBuffer", XrmoptionNoArg, "off"}, }; static argtype vars[] = { - {(caddr_t *) & factory, "factory", "Factory", DEF_FACTORY, t_Int}, - {(caddr_t *) & fisheye, "fisheye", "Fisheye", DEF_FISHEYE, t_Bool}, - {(caddr_t *) & tightturns, "tightturns", "Tightturns", DEF_TIGHTTURNS, t_Bool}, - {(caddr_t *) & rotatepipes, "rotatepipes", "Rotatepipes", DEF_ROTATEPIPES, t_Bool} + {&factory, "factory", "Factory", DEF_FACTORY, t_Int}, + {&fisheye, "fisheye", "Fisheye", DEF_FISHEYE, t_Bool}, + {&tightturns, "tightturns", "Tightturns", DEF_TIGHTTURNS, t_Bool}, + {&rotatepipes, "rotatepipes", "Rotatepipes", DEF_ROTATEPIPES, t_Bool}, + {&dbuf_p, "doubleBuffer", "DoubleBuffer", DEF_DBUF, t_Bool} }; static OptionStruct desc[] = { {"-factory num", "how much extra equipment in pipes (0 for none)"}, {"-/+fisheye", "turn on/off zoomed-in view of pipes"}, {"-/+tightturns", "turn on/off tight turns"}, - {"-/+rotatepipes", "turn on/off pipe system rotation per screenful"} + {"-/+rotatepipes", "turn on/off pipe system rotation per screenful"}, + {"-/+db", "turn on/off double buffering"} }; ModeSpecOpt pipes_opts = @@ -211,7 +211,7 @@ static pipesstruct *pipes = NULL; static void -MakeTube(int direction) +MakeTube(ModeInfo *mi, int direction) { float an; float SINan_3, COSan_3; @@ -232,6 +232,7 @@ MakeTube(int direction) glNormal3f((COSan_3 = cos(an) / 3.0), (SINan_3 = sin(an) / 3.0), 0.0); glVertex3f(COSan_3, SINan_3, one_third); glVertex3f(COSan_3, SINan_3, -one_third); + mi->polygon_count++; } glEnd(); } @@ -312,6 +313,7 @@ myElbow(ModeInfo * mi, int bolted) glVertex3fv(p1); glNormal3fv(n0); glVertex3fv(p0); + mi->polygon_count++; glEnd(); } } @@ -324,8 +326,10 @@ myElbow(ModeInfo * mi, int bolted) glRotatef(90.0, 0.0, 1.0, 0.0); glTranslatef(0.0, one_third, one_third); glCallList(pp->elbowcoins); + mi->polygon_count += LWO_ElbowCoins.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray); glCallList(pp->elbowbolts); + mi->polygon_count += LWO_ElbowBolts.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color); glPopMatrix(); glFrontFace(GL_CCW); @@ -397,8 +401,10 @@ MakeValve(ModeInfo * mi, int newdir) } glFrontFace(GL_CW); glCallList(pp->betweenbolts); + mi->polygon_count += LWO_PipeBetweenBolts.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray); glCallList(pp->bolts); + mi->polygon_count += LWO_Bolts3D.num_pnts/3; if (!MI_IS_MONO(mi)) { if (pp->system_color == MaterialRed) { glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialYellow : MaterialBlue); @@ -421,6 +427,7 @@ MakeValve(ModeInfo * mi, int newdir) } glRotatef((GLfloat) (NRAND(90)), 1.0, 0.0, 0.0); glCallList(pp->valve); + mi->polygon_count += LWO_BigValve.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color); glFrontFace(GL_CCW); } @@ -446,11 +453,14 @@ MakeGuage(ModeInfo * mi, int newdir) if ((newdir == dirLEFT) || (newdir == dirRIGHT)) glRotatef(90.0, 0.0, 1.0, 0.0); glCallList(pp->betweenbolts); + mi->polygon_count += LWO_PipeBetweenBolts.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray); glCallList(pp->bolts); + mi->polygon_count += LWO_Bolts3D.num_pnts/3; glPopMatrix(); glCallList(pp->guageconnector); + mi->polygon_count += LWO_GuageConnector.num_pnts/3; glPushMatrix(); glTranslatef(0.0, 1.33333, 0.0); /* Do not change the above to 1 + ONE_THIRD, because */ @@ -458,14 +468,17 @@ MakeGuage(ModeInfo * mi, int newdir) glRotatef(NRAND(270) + 45.0, 0.0, 0.0, -1.0); /* Random rotation for the dial. I love it. */ glCallList(pp->guagedial); + mi->polygon_count += LWO_GuageDial.num_pnts/3; glPopMatrix(); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color); glCallList(pp->guagehead); + mi->polygon_count += LWO_GuageHead.num_pnts/3; /* GuageFace is drawn last, in case of low-res depth buffers. */ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite); glCallList(pp->guageface); + mi->polygon_count += LWO_GuageFace.num_pnts/3; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color); glFrontFace(GL_CCW); @@ -479,7 +492,7 @@ MakeShape(ModeInfo * mi, int newdir) switch (NRAND(2)) { case 1: if (!MakeGuage(mi, newdir)) - MakeTube(newdir); + MakeTube(mi, newdir); break; default: MakeValve(mi, newdir); @@ -508,6 +521,9 @@ pinit(ModeInfo * mi, int zera) pipesstruct *pp = &pipes[MI_SCREEN(mi)]; int X, Y, Z; + if (zera) + mi->polygon_count = 0; + glClearDepth(1.0); glClearColor(0.0, 0.0, 0.0, 1.0); glColor3f(1.0, 1.0, 1.0); @@ -533,7 +549,7 @@ pinit(ModeInfo * mi, int zera) if (zera) { pp->system_number = 1; - glDrawBuffer(GL_FRONT_AND_BACK); + glDrawBuffer(dbuf_p ? GL_BACK : GL_FRONT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); (void) memset(pp->Cells, 0, sizeof (pp->Cells)); for (X = 0; X < HCELLS; X++) { @@ -730,7 +746,8 @@ draw_pipes(ModeInfo * mi) /* If the maximum number of system was drawn, restart (clearing the screen), */ /* else start a new system. */ if (++pp->system_number > pp->number_of_systems) { - (void) sleep(1); + if (!mi->fps_p) + sleep(1); pinit(mi, 1); } else { pinit(mi, 0); @@ -770,7 +787,7 @@ draw_pipes(ModeInfo * mi) if ((pp->counter > 1) && (NRAND(100) < factory)) { MakeShape(mi, newdir); } else { - MakeTube(newdir); + MakeTube(mi, newdir); } glPopMatrix(); } else { @@ -954,13 +971,14 @@ draw_pipes(ModeInfo * mi) /* Cells'face pipe */ glTranslatef(((pp->PX + OPX) / 2.0 - 16) / 3.0 * 4.0, ((pp->PY + OPY) / 2.0 - 12) / 3.0 * 4.0, ((pp->PZ + OPZ) / 2.0 - 16) / 3.0 * 4.0); - MakeTube(newdir); + MakeTube(mi, newdir); glPopMatrix(); glFlush(); - glXSwapBuffers(display, window); + if (dbuf_p) + glXSwapBuffers(display, window); if (mi->fps_p) do_fps (mi); }