http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / hacks / glx / pipes.c
1 /* -*- Mode: C; tab-width: 4 -*- */
2 /* pipes --- 3D selfbuiding pipe system */
3
4 #if 0
5 static const char sccsid[] = "@(#)pipes.c       4.07 97/11/24 xlockmore";
6 #endif
7
8 /*-
9  * Permission to use, copy, modify, and distribute this software and its
10  * documentation for any purpose and without fee is hereby granted,
11  * provided that the above copyright notice appear in all copies and that
12  * both that copyright notice and this permission notice appear in
13  * supporting documentation.
14  *
15  * This file is provided AS IS with no warranties of any kind.  The author
16  * shall have no liability with respect to the infringement of copyrights,
17  * trade secrets or any patents by this file or any part thereof.  In no
18  * event will the author be liable for any lost revenue or profits or
19  * other special, indirect and consequential damages.
20  *
21  * This program was inspired on a WindowsNT(R)'s screen saver. It was written 
22  * from scratch and it was not based on any other source code.
23  *
24  * ==========================================================================
25  * The routine myElbow is derivated from the doughnut routine from the MesaGL
26  * library (more especifically the Mesaaux library) written by Brian Paul.
27  * ==========================================================================
28  *
29  * Thanks goes to Brian Paul for making it possible and inexpensive to use
30  * OpenGL at home.
31  *
32  * Since I'm not a native English speaker, my apologies for any grammatical
33  * mistake.
34  *
35  * My e-mail address is
36  * m-vianna@usa.net
37  * Marcelo F. Vianna (Apr-09-1997)
38  *
39  * Revision History:
40  * 29-Apr-97: Factory equipment by Ed Mackey.  Productive day today, eh?
41  * 29-Apr-97: Less tight turns Jeff Epler <jepler@inetnebr.com>
42  * 29-Apr-97: Efficiency speed-ups by Marcelo F. Vianna
43  */
44
45 #ifdef STANDALONE
46 # define DEFAULTS       "*delay:                10000   \n"                     \
47                                         "*count:                2       \n"                     \
48                                         "*cycles:               5       \n"                     \
49                                         "*size:                 500     \n"                     \
50                         "*showFPS:      False   \n"                 \
51                         "*fpsSolid:     True    \n"
52
53 # define refresh_pipes 0
54 # define pipes_handle_event 0
55 # include "xlockmore.h"                         /* from the xscreensaver distribution */
56 #else  /* !STANDALONE */
57 # include "xlock.h"                                     /* from the xlockmore distribution */
58 #endif /* !STANDALONE */
59
60 #ifdef USE_GL
61
62 #include "buildlwo.h"
63 #include "teapot.h"
64
65 #define DEF_FACTORY     "2"
66 #define DEF_FISHEYE     "True"
67 #define DEF_TIGHTTURNS  "False"
68 #define DEF_ROTATEPIPES "True"
69 #define DEF_DBUF        "False"
70 #define NofSysTypes     3
71
72 static int  factory;
73 static Bool fisheye, tightturns, rotatepipes;
74 static Bool dbuf_p;
75
76 static XrmOptionDescRec opts[] =
77 {
78         {"-factory", ".pipes.factory", XrmoptionSepArg, 0},
79         {"-fisheye", ".pipes.fisheye", XrmoptionNoArg, "on"},
80         {"+fisheye", ".pipes.fisheye", XrmoptionNoArg, "off"},
81         {"-tightturns", ".pipes.tightturns", XrmoptionNoArg, "on"},
82         {"+tightturns", ".pipes.tightturns", XrmoptionNoArg, "off"},
83       {"-rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, "on"},
84       {"+rotatepipes", ".pipes.rotatepipes", XrmoptionNoArg, "off"},
85       {"-db", ".pipes.doubleBuffer", XrmoptionNoArg, "on"},
86       {"+db", ".pipes.doubleBuffer", XrmoptionNoArg, "off"},
87 };
88 static argtype vars[] =
89 {
90         {&factory, "factory", "Factory", DEF_FACTORY, t_Int},
91         {&fisheye, "fisheye", "Fisheye", DEF_FISHEYE, t_Bool},
92         {&tightturns, "tightturns", "Tightturns", DEF_TIGHTTURNS, t_Bool},
93         {&rotatepipes, "rotatepipes", "Rotatepipes", DEF_ROTATEPIPES, t_Bool},
94         {&dbuf_p, "doubleBuffer", "DoubleBuffer", DEF_DBUF, t_Bool}
95 };
96 static OptionStruct desc[] =
97 {
98         {"-factory num", "how much extra equipment in pipes (0 for none)"},
99         {"-/+fisheye", "turn on/off zoomed-in view of pipes"},
100         {"-/+tightturns", "turn on/off tight turns"},
101         {"-/+rotatepipes", "turn on/off pipe system rotation per screenful"},
102         {"-/+db", "turn on/off double buffering"}
103 };
104
105 ENTRYPOINT ModeSpecOpt pipes_opts =
106 {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
107
108 #ifdef USE_MODULES
109 ModStruct   pipes_description =
110 {"pipes", "init_pipes", "draw_pipes", "release_pipes",
111  "draw_pipes",
112  "change_pipes", NULL, &pipes_opts,
113  1000, 2, 5, 500, 4, 1.0, "",
114  "Shows a selfbuilding pipe system", 0, NULL};
115
116 #endif
117
118 #define Scale4Window               0.1
119 #define Scale4Iconic               0.07
120
121 #define one_third                  0.3333333333333333333
122
123 #define dirNone -1
124 #define dirUP 0
125 #define dirDOWN 1
126 #define dirLEFT 2
127 #define dirRIGHT 3
128 #define dirNEAR 4
129 #define dirFAR 5
130
131 #define HCELLS 33
132 #define VCELLS 25
133 #define DEFINEDCOLORS 7
134 #define elbowradius 0.5
135
136 /*************************************************************************/
137
138 typedef struct {
139         int         flip;
140
141         GLint       WindH, WindW;
142         int         Cells[HCELLS][VCELLS][HCELLS];
143         int         usedcolors[DEFINEDCOLORS];
144         int         directions[6];
145         int         ndirections;
146         int         nowdir, olddir;
147         int         system_number;
148         int         counter;
149         int         PX, PY, PZ;
150         int         number_of_systems;
151         int         system_type;
152         int         system_length;
153         int         turncounter;
154         Window      window;
155         const float *system_color;
156         GLfloat     initial_rotation;
157         GLuint      valve, bolts, betweenbolts, elbowbolts, elbowcoins;
158         GLuint      guagehead, guageface, guagedial, guageconnector, teapot;
159     int         teapot_polys;
160     int         reset;
161         GLXContext *glx_context;
162 } pipesstruct;
163
164 extern struct lwo LWO_BigValve, LWO_PipeBetweenBolts, LWO_Bolts3D;
165 extern struct lwo LWO_GuageHead, LWO_GuageFace, LWO_GuageDial, LWO_GuageConnector;
166 extern struct lwo LWO_ElbowBolts, LWO_ElbowCoins;
167
168 static const float front_shininess[] = {60.0};
169 static const float front_specular[] = {0.7, 0.7, 0.7, 1.0};
170 static const float ambient0[] = {0.4, 0.4, 0.4, 1.0};
171 static const float diffuse0[] = {1.0, 1.0, 1.0, 1.0};
172 static const float ambient1[] = {0.2, 0.2, 0.2, 1.0};
173 static const float diffuse1[] = {0.5, 0.5, 0.5, 1.0};
174 static const float position0[] = {1.0, 1.0, 1.0, 0.0};
175 static const float position1[] = {-1.0, -1.0, 1.0, 0.0};
176 static const float lmodel_ambient[] = {0.5, 0.5, 0.5, 1.0};
177 static const float lmodel_twoside[] = {GL_TRUE};
178
179 static const float MaterialRed[] = {0.7, 0.0, 0.0, 1.0};
180 static const float MaterialGreen[] = {0.1, 0.5, 0.2, 1.0};
181 static const float MaterialBlue[] = {0.0, 0.0, 0.7, 1.0};
182 static const float MaterialCyan[] = {0.2, 0.5, 0.7, 1.0};
183 static const float MaterialYellow[] = {0.7, 0.7, 0.0, 1.0};
184 static const float MaterialMagenta[] = {0.6, 0.2, 0.5, 1.0};
185 static const float MaterialWhite[] = {0.7, 0.7, 0.7, 1.0};
186 static const float MaterialGray[] = {0.2, 0.2, 0.2, 1.0};
187
188 static pipesstruct *pipes = NULL;
189
190
191 static void
192 MakeTube(ModeInfo *mi, int direction)
193 {
194         float       an;
195         float       SINan_3, COSan_3;
196
197         /*dirUP    = 00000000 */
198         /*dirDOWN  = 00000001 */
199         /*dirLEFT  = 00000010 */
200         /*dirRIGHT = 00000011 */
201         /*dirNEAR  = 00000100 */
202         /*dirFAR   = 00000101 */
203
204         if (!(direction & 4)) {
205                 glRotatef(90.0, (direction & 2) ? 0.0 : 1.0,
206                           (direction & 2) ? 1.0 : 0.0, 0.0);
207         }
208         glBegin(GL_QUAD_STRIP);
209         for (an = 0.0; an <= 2.0 * M_PI; an += M_PI / 12.0) {
210                 glNormal3f((COSan_3 = cos(an) / 3.0), (SINan_3 = sin(an) / 3.0), 0.0);
211                 glVertex3f(COSan_3, SINan_3, one_third);
212                 glVertex3f(COSan_3, SINan_3, -one_third);
213         mi->polygon_count++;
214         }
215         glEnd();
216 }
217
218 static void
219 mySphere(float radius)
220 {
221         GLUquadricObj *quadObj;
222
223         quadObj = gluNewQuadric();
224         gluQuadricDrawStyle(quadObj, (GLenum) GLU_FILL);
225         gluSphere(quadObj, radius, 16, 16);
226         gluDeleteQuadric(quadObj);
227 }
228
229 static void
230 myElbow(ModeInfo * mi, int bolted)
231 {
232 #define nsides 25
233 #define rings 25
234 #define r one_third
235 #define R one_third
236
237         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
238
239         int         i, j;
240         GLfloat     p0[3], p1[3], p2[3], p3[3];
241         GLfloat     n0[3], n1[3], n2[3], n3[3];
242         GLfloat     COSphi, COSphi1, COStheta, COStheta1;
243         GLfloat     _SINtheta, _SINtheta1;
244
245         for (i = 0; i <= rings / 4; i++) {
246                 GLfloat     theta, theta1;
247
248                 theta = (GLfloat) i *2.0 * M_PI / rings;
249
250                 theta1 = (GLfloat) (i + 1) * 2.0 * M_PI / rings;
251                 for (j = 0; j < nsides; j++) {
252                         GLfloat     phi, phi1;
253
254                         phi = (GLfloat) j *2.0 * M_PI / nsides;
255
256                         phi1 = (GLfloat) (j + 1) * 2.0 * M_PI / nsides;
257
258                         p0[0] = (COStheta = cos(theta)) * (R + r * (COSphi = cos(phi)));
259                         p0[1] = (_SINtheta = -sin(theta)) * (R + r * COSphi);
260
261                         p1[0] = (COStheta1 = cos(theta1)) * (R + r * COSphi);
262                         p1[1] = (_SINtheta1 = -sin(theta1)) * (R + r * COSphi);
263
264                         p2[0] = COStheta1 * (R + r * (COSphi1 = cos(phi1)));
265                         p2[1] = _SINtheta1 * (R + r * COSphi1);
266
267                         p3[0] = COStheta * (R + r * COSphi1);
268                         p3[1] = _SINtheta * (R + r * COSphi1);
269
270                         n0[0] = COStheta * COSphi;
271                         n0[1] = _SINtheta * COSphi;
272
273                         n1[0] = COStheta1 * COSphi;
274                         n1[1] = _SINtheta1 * COSphi;
275
276                         n2[0] = COStheta1 * COSphi1;
277                         n2[1] = _SINtheta1 * COSphi1;
278
279                         n3[0] = COStheta * COSphi1;
280                         n3[1] = _SINtheta * COSphi1;
281
282                         p0[2] = p1[2] = r * (n0[2] = n1[2] = sin(phi));
283                         p2[2] = p3[2] = r * (n2[2] = n3[2] = sin(phi1));
284
285                         glBegin(GL_QUADS);
286                         glNormal3fv(n3);
287                         glVertex3fv(p3);
288                         glNormal3fv(n2);
289                         glVertex3fv(p2);
290                         glNormal3fv(n1);
291                         glVertex3fv(p1);
292                         glNormal3fv(n0);
293                         glVertex3fv(p0);
294             mi->polygon_count++;
295                         glEnd();
296                 }
297         }
298
299         if (factory > 0 && bolted) {
300                 /* Bolt the elbow onto the pipe system */
301                 glFrontFace(GL_CW);
302                 glPushMatrix();
303                 glRotatef(90.0, 0.0, 0.0, -1.0);
304                 glRotatef(90.0, 0.0, 1.0, 0.0);
305                 glTranslatef(0.0, one_third, one_third);
306                 glCallList(pp->elbowcoins);
307         mi->polygon_count += LWO_ElbowCoins.num_pnts/3;
308                 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
309                 glCallList(pp->elbowbolts);
310         mi->polygon_count += LWO_ElbowBolts.num_pnts/3;
311                 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
312                 glPopMatrix();
313                 glFrontFace(GL_CCW);
314         }
315 #undef r
316 #undef R
317 #undef nsides
318 #undef rings
319 }
320
321 static void
322 FindNeighbors(ModeInfo * mi)
323 {
324         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
325
326         pp->ndirections = 0;
327         pp->directions[dirUP] = (!pp->Cells[pp->PX][pp->PY + 1][pp->PZ]) ? 1 : 0;
328         pp->ndirections += pp->directions[dirUP];
329         pp->directions[dirDOWN] = (!pp->Cells[pp->PX][pp->PY - 1][pp->PZ]) ? 1 : 0;
330         pp->ndirections += pp->directions[dirDOWN];
331         pp->directions[dirLEFT] = (!pp->Cells[pp->PX - 1][pp->PY][pp->PZ]) ? 1 : 0;
332         pp->ndirections += pp->directions[dirLEFT];
333         pp->directions[dirRIGHT] = (!pp->Cells[pp->PX + 1][pp->PY][pp->PZ]) ? 1 : 0;
334         pp->ndirections += pp->directions[dirRIGHT];
335         pp->directions[dirFAR] = (!pp->Cells[pp->PX][pp->PY][pp->PZ - 1]) ? 1 : 0;
336         pp->ndirections += pp->directions[dirFAR];
337         pp->directions[dirNEAR] = (!pp->Cells[pp->PX][pp->PY][pp->PZ + 1]) ? 1 : 0;
338         pp->ndirections += pp->directions[dirNEAR];
339 }
340
341 static int
342 SelectNeighbor(ModeInfo * mi)
343 {
344         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
345         int         dirlist[6];
346         int         i, j;
347
348         for (i = 0, j = 0; i < 6; i++) {
349                 if (pp->directions[i]) {
350                         dirlist[j] = i;
351                         j++;
352                 }
353         }
354
355         return dirlist[NRAND(pp->ndirections)];
356 }
357
358 static void
359 MakeValve(ModeInfo * mi, int newdir)
360 {
361         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
362
363         /* There is a glPopMatrix() right after this subroutine returns. */
364         switch (newdir) {
365                 case dirUP:
366                 case dirDOWN:
367                         glRotatef(90.0, 1.0, 0.0, 0.0);
368                         glRotatef(NRAND(3) * 90.0, 0.0, 0.0, 1.0);
369                         break;
370                 case dirLEFT:
371                 case dirRIGHT:
372                         glRotatef(90.0, 0.0, -1.0, 0.0);
373                         glRotatef((NRAND(3) * 90.0) - 90.0, 0.0, 0.0, 1.0);
374                         break;
375                 case dirNEAR:
376                 case dirFAR:
377                         glRotatef(NRAND(4) * 90.0, 0.0, 0.0, 1.0);
378                         break;
379         }
380         glFrontFace(GL_CW);
381         glCallList(pp->betweenbolts);
382     mi->polygon_count += LWO_PipeBetweenBolts.num_pnts/3;
383         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
384         glCallList(pp->bolts);
385     mi->polygon_count += LWO_Bolts3D.num_pnts/3;
386         if (!MI_IS_MONO(mi)) {
387                 if (pp->system_color == MaterialRed) {
388                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialYellow : MaterialBlue);
389                 } else if (pp->system_color == MaterialBlue) {
390                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialRed : MaterialYellow);
391                 } else if (pp->system_color == MaterialYellow) {
392                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, NRAND(2) ? MaterialBlue : MaterialRed);
393                 } else {
394                         switch ((NRAND(3))) {
395                                 case 0:
396                                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed);
397                                         break;
398                                 case 1:
399                                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialBlue);
400                                         break;
401                                 case 2:
402                                         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialYellow);
403                         }
404                 }
405         }
406         glRotatef((GLfloat) (NRAND(90)), 1.0, 0.0, 0.0);
407         glCallList(pp->valve);
408     mi->polygon_count += LWO_BigValve.num_pnts/3;
409         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
410         glFrontFace(GL_CCW);
411 }
412
413 static int
414 MakeGuage(ModeInfo * mi, int newdir)
415 {
416         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
417
418         /* Can't have a guage on a vertical pipe. */
419         if ((newdir == dirUP) || (newdir == dirDOWN))
420                 return (0);
421
422         /* Is there space above this pipe for a guage? */
423         if (!pp->directions[dirUP])
424                 return (0);
425
426         /* Yes!  Mark the space as used. */
427         pp->Cells[pp->PX][pp->PY + 1][pp->PZ] = 1;
428
429         glFrontFace(GL_CW);
430         glPushMatrix();
431         if ((newdir == dirLEFT) || (newdir == dirRIGHT))
432                 glRotatef(90.0, 0.0, 1.0, 0.0);
433         glCallList(pp->betweenbolts);
434     mi->polygon_count += LWO_PipeBetweenBolts.num_pnts/3;
435         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
436         glCallList(pp->bolts);
437     mi->polygon_count += LWO_Bolts3D.num_pnts/3;
438         glPopMatrix();
439
440         glCallList(pp->guageconnector);
441     mi->polygon_count += LWO_GuageConnector.num_pnts/3;
442         glPushMatrix();
443         glTranslatef(0.0, 1.33333, 0.0);
444         /* Do not change the above to 1 + ONE_THIRD, because */
445         /* the object really is centered on 1.3333300000. */
446         glRotatef(NRAND(270) + 45.0, 0.0, 0.0, -1.0);
447         /* Random rotation for the dial.  I love it. */
448         glCallList(pp->guagedial);
449     mi->polygon_count += LWO_GuageDial.num_pnts/3;
450         glPopMatrix();
451
452         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
453         glCallList(pp->guagehead);
454     mi->polygon_count += LWO_GuageHead.num_pnts/3;
455
456         /* GuageFace is drawn last, in case of low-res depth buffers. */
457         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialWhite);
458         glCallList(pp->guageface);
459     mi->polygon_count += LWO_GuageFace.num_pnts/3;
460
461         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
462         glFrontFace(GL_CCW);
463
464         return (1);
465 }
466
467
468 static GLuint
469 build_teapot(ModeInfo *mi)
470 {
471   pipesstruct *pp = &pipes[MI_SCREEN(mi)];
472   GLuint list = glGenLists(1);
473   if (!list) return 0;
474   glNewList(list, GL_COMPILE);
475   pp->teapot_polys = unit_teapot (12, MI_IS_WIREFRAME(mi));
476   glEndList();
477   return list;
478 }
479
480
481 static void
482 MakeTeapot(ModeInfo * mi, int newdir)
483 {
484   pipesstruct *pp = &pipes[MI_SCREEN(mi)];
485
486   switch (newdir) {
487   case dirUP:
488   case dirDOWN:
489     glRotatef(90.0, 1.0, 0.0, 0.0);
490     glRotatef(NRAND(3) * 90.0, 0.0, 0.0, 1.0);
491     break;
492   case dirLEFT:
493   case dirRIGHT:
494     glRotatef(90.0, 0.0, -1.0, 0.0);
495     glRotatef((NRAND(3) * 90.0) - 90.0, 0.0, 0.0, 1.0);
496     break;
497   case dirNEAR:
498   case dirFAR:
499     glRotatef(NRAND(4) * 90.0, 0.0, 0.0, 1.0);
500     break;
501   }
502
503   glCallList(pp->teapot);
504   mi->polygon_count += pp->teapot_polys;
505   glFrontFace(GL_CCW);
506 }
507
508
509 static void
510 MakeShape(ModeInfo * mi, int newdir)
511 {
512   int n = NRAND(100);
513   if (n < 50) {
514     if (!MakeGuage(mi, newdir))
515       MakeTube(mi, newdir);
516   } else if (n < 98) {
517     MakeValve(mi, newdir);
518   } else {
519     MakeTeapot(mi,newdir);
520   }
521 }
522
523 static void
524 pinit(ModeInfo * mi, int zera)
525 {
526         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
527         int         X, Y, Z;
528
529     if (zera)
530       mi->polygon_count = 0;
531
532         glClearDepth(1.0);
533         glColor3f(1.0, 1.0, 1.0);
534
535         glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);
536         glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);
537         glLightfv(GL_LIGHT0, GL_POSITION, position0);
538         glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);
539         glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);
540         glLightfv(GL_LIGHT1, GL_POSITION, position1);
541         glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
542         glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
543         glEnable(GL_LIGHTING);
544         glEnable(GL_LIGHT0);
545         glEnable(GL_LIGHT1);
546         glEnable(GL_DEPTH_TEST);
547         glEnable(GL_NORMALIZE);
548         glEnable(GL_CULL_FACE);
549
550         glShadeModel(GL_SMOOTH);
551         glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess);
552         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular);
553
554         if (zera) {
555                 pp->system_number = 1;
556                 glDrawBuffer(dbuf_p ? GL_BACK : GL_FRONT);
557                 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
558                 (void) memset(pp->Cells, 0, sizeof (pp->Cells));
559                 for (X = 0; X < HCELLS; X++) {
560                         for (Y = 0; Y < VCELLS; Y++) {
561                                 pp->Cells[X][Y][0] = 1;
562                                 pp->Cells[X][Y][HCELLS - 1] = 1;
563                                 pp->Cells[0][Y][X] = 1;
564                                 pp->Cells[HCELLS - 1][Y][X] = 1;
565                         }
566                 }
567                 for (X = 0; X < HCELLS; X++) {
568                         for (Z = 0; Z < HCELLS; Z++) {
569                                 pp->Cells[X][0][Z] = 1;
570                                 pp->Cells[X][VCELLS - 1][Z] = 1;
571                         }
572                 }
573                 (void) memset(pp->usedcolors, 0, sizeof (pp->usedcolors));
574                 if ((pp->initial_rotation += 10.0) > 45.0) {
575                         pp->initial_rotation -= 90.0;
576                 }
577         }
578         pp->counter = 0;
579         pp->turncounter = 0;
580
581         if (!MI_IS_MONO(mi)) {
582                 int         collist[DEFINEDCOLORS];
583                 int         i, j, lower = 1000;
584
585                 /* Avoid repeating colors on the same screen unless necessary */
586                 for (i = 0; i < DEFINEDCOLORS; i++) {
587                         if (lower > pp->usedcolors[i])
588                                 lower = pp->usedcolors[i];
589                 }
590                 for (i = 0, j = 0; i < DEFINEDCOLORS; i++) {
591                         if (pp->usedcolors[i] == lower) {
592                                 collist[j] = i;
593                                 j++;
594                         }
595                 }
596                 i = collist[NRAND(j)];
597                 pp->usedcolors[i]++;
598                 switch (i) {
599                         case 0:
600                                 pp->system_color = MaterialRed;
601                                 break;
602                         case 1:
603                                 pp->system_color = MaterialGreen;
604                                 break;
605                         case 2:
606                                 pp->system_color = MaterialBlue;
607                                 break;
608                         case 3:
609                                 pp->system_color = MaterialCyan;
610                                 break;
611                         case 4:
612                                 pp->system_color = MaterialYellow;
613                                 break;
614                         case 5:
615                                 pp->system_color = MaterialMagenta;
616                                 break;
617                         case 6:
618                                 pp->system_color = MaterialWhite;
619                                 break;
620                 }
621         } else {
622                 pp->system_color = MaterialGray;
623         }
624
625         do {
626                 pp->PX = NRAND((HCELLS - 1)) + 1;
627                 pp->PY = NRAND((VCELLS - 1)) + 1;
628                 pp->PZ = NRAND((HCELLS - 1)) + 1;
629         } while (pp->Cells[pp->PX][pp->PY][pp->PZ] ||
630                  (pp->Cells[pp->PX + 1][pp->PY][pp->PZ] && pp->Cells[pp->PX - 1][pp->PY][pp->PZ] &&
631                   pp->Cells[pp->PX][pp->PY + 1][pp->PZ] && pp->Cells[pp->PX][pp->PY - 1][pp->PZ] &&
632                   pp->Cells[pp->PX][pp->PY][pp->PZ + 1] && pp->Cells[pp->PX][pp->PY][pp->PZ - 1]));
633         pp->Cells[pp->PX][pp->PY][pp->PZ] = 1;
634         pp->olddir = dirNone;
635
636         FindNeighbors(mi);
637
638         pp->nowdir = SelectNeighbor(mi);
639 }
640
641 ENTRYPOINT void
642 reshape_pipes(ModeInfo * mi, int width, int height)
643 {
644         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
645     pinit(mi, 1);
646
647         glViewport(0, 0, pp->WindW = (GLint) width, pp->WindH = (GLint) height);
648         glMatrixMode(GL_PROJECTION);
649         glLoadIdentity();
650         /*glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 15.0); */
651         gluPerspective(65.0, (GLfloat) width / (GLfloat) height, 0.1, 20.0);
652         glMatrixMode(GL_MODELVIEW);
653
654   glClear(GL_COLOR_BUFFER_BIT);
655 }
656
657 ENTRYPOINT void
658 init_pipes (ModeInfo * mi)
659 {
660         int         screen = MI_SCREEN(mi);
661         pipesstruct *pp;
662
663         if (pipes == NULL) {
664                 if ((pipes = (pipesstruct *) calloc(MI_NUM_SCREENS(mi),
665                                               sizeof (pipesstruct))) == NULL)
666                         return;
667         }
668         pp = &pipes[screen];
669
670         pp->window = MI_WINDOW(mi);
671         if ((pp->glx_context = init_GL(mi)) != NULL) {
672
673                 reshape_pipes(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
674                 if (rotatepipes)
675                   pp->initial_rotation = NRAND(180); /* jwz */
676                 else
677                   pp->initial_rotation = -10.0;
678                 pinit(mi, 1);
679
680                 if (factory > 0) {
681                         pp->valve = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_BigValve);
682                         pp->bolts = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_Bolts3D);
683                         pp->betweenbolts = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_PipeBetweenBolts);
684
685                         pp->elbowbolts = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_ElbowBolts);
686                         pp->elbowcoins = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_ElbowCoins);
687
688                         pp->guagehead = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_GuageHead);
689                         pp->guageface = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_GuageFace);
690                         pp->guagedial = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_GuageDial);
691                         pp->guageconnector = BuildLWO(MI_IS_WIREFRAME(mi), &LWO_GuageConnector);
692                         pp->teapot = build_teapot(mi);
693                 }
694                 /* else they are all 0, thanks to calloc(). */
695
696                 if (MI_COUNT(mi) < 1 || MI_COUNT(mi) > NofSysTypes + 1) {
697                         pp->system_type = NRAND(NofSysTypes) + 1;
698                 } else {
699                         pp->system_type = MI_COUNT(mi);
700                 }
701
702                 if (MI_CYCLES(mi) > 0 && MI_CYCLES(mi) < 11) {
703                         pp->number_of_systems = MI_CYCLES(mi);
704                 } else {
705                         pp->number_of_systems = 5;
706                 }
707
708                 if (MI_SIZE(mi) < 10) {
709                         pp->system_length = 10;
710                 } else if (MI_SIZE(mi) > 1000) {
711                         pp->system_length = 1000;
712                 } else {
713                         pp->system_length = MI_SIZE(mi);
714                 }
715         } else {
716                 MI_CLEARWINDOW(mi);
717         }
718 }
719
720 ENTRYPOINT void
721 draw_pipes (ModeInfo * mi)
722 {
723         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
724
725         Display    *display = MI_DISPLAY(mi);
726         Window      window = MI_WINDOW(mi);
727
728         int         newdir;
729         int         OPX, OPY, OPZ;
730
731         if (!pp->glx_context)
732                 return;
733
734         glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(pp->glx_context));
735
736     if (pp->reset) {
737       if (--pp->reset) {
738         /* Would be nice to fade to black here, by drawing successive quads
739            over the whole scene with gamma. */
740         return;
741       }
742       pinit(mi, 1);
743     }
744
745         glPushMatrix();
746
747         glTranslatef(0.0, 0.0, fisheye ? -3.8 : -4.8);
748         if (rotatepipes)
749                 glRotatef(pp->initial_rotation, 0.0, 1.0, 0.0);
750
751         if (!MI_IS_ICONIC(mi)) {
752                 /* Width/height ratio handled by gluPerspective() now. */
753                 glScalef(Scale4Window, Scale4Window, Scale4Window);
754         } else {
755                 glScalef(Scale4Iconic, Scale4Iconic, Scale4Iconic);
756         }
757
758         FindNeighbors(mi);
759
760         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pp->system_color);
761
762         /* If it's the begining of a system, draw a sphere */
763         if (pp->olddir == dirNone) {
764                 glPushMatrix();
765                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0);
766                 mySphere(0.6);
767                 glPopMatrix();
768         }
769         /* Check for stop conditions */
770         if (pp->ndirections == 0 || pp->counter > pp->system_length) {
771                 glPushMatrix();
772                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0);
773                 /* Finish the system with another sphere */
774                 mySphere(0.6);
775
776                 glPopMatrix();
777
778                 /* If the maximum number of system was drawn, restart (clearing the screen), */
779                 /* else start a new system. */
780                 if (++pp->system_number > pp->number_of_systems) {
781           /* pause doing nothing for N seconds before clearing the screen. */
782           int secs = 3;
783           pp->reset = secs * 1000000 / (MI_PAUSE(mi) ? MI_PAUSE(mi) : 100);
784                 } else {
785                         pinit(mi, 0);
786                 }
787
788                 glPopMatrix();
789                 return;
790         }
791         pp->counter++;
792         pp->turncounter++;
793
794         /* Do will the direction change? if so, determine the new one */
795         newdir = pp->nowdir;
796         if (!pp->directions[newdir]) {  /* cannot proceed in the current direction */
797                 newdir = SelectNeighbor(mi);
798         } else {
799                 if (tightturns) {
800                         /* random change (20% chance) */
801                         if ((pp->counter > 1) && (NRAND(100) < 20)) {
802                                 newdir = SelectNeighbor(mi);
803                         }
804                 } else {
805                         /* Chance to turn increases after each length of pipe drawn */
806                         if ((pp->counter > 1) && NRAND(50) < NRAND(pp->turncounter + 1)) {
807                                 newdir = SelectNeighbor(mi);
808                                 pp->turncounter = 0;
809                         }
810                 }
811         }
812
813         /* Has the direction changed? */
814         if (newdir == pp->nowdir) {
815                 /* If not, draw the cell's center pipe */
816                 glPushMatrix();
817                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0);
818                 /* Chance of factory shape here, if enabled. */
819                 if ((pp->counter > 1) && (NRAND(100) < factory)) {
820                         MakeShape(mi, newdir);
821                 } else {
822                         MakeTube(mi, newdir);
823                 }
824                 glPopMatrix();
825         } else {
826                 /* If so, draw the cell's center elbow/sphere */
827                 int         sysT = pp->system_type;
828
829                 if (sysT == NofSysTypes + 1) {
830                         sysT = ((pp->system_number - 1) % NofSysTypes) + 1;
831                 }
832                 glPushMatrix();
833
834                 switch (sysT) {
835                         case 1:
836                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0);
837                                 mySphere(elbowradius);
838                                 break;
839                         case 2:
840                         case 3:
841                                 switch (pp->nowdir) {
842                                         case dirUP:
843                                                 switch (newdir) {
844                                                         case dirLEFT:
845                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0);
846                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
847                                                                 break;
848                                                         case dirRIGHT:
849                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0);
850                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
851                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
852                                                                 break;
853                                                         case dirFAR:
854                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
855                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
856                                                                 glRotatef(180.0, 0.0, 0.0, 1.0);
857                                                                 break;
858                                                         case dirNEAR:
859                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
860                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
861                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
862                                                                 break;
863                                                 }
864                                                 break;
865                                         case dirDOWN:
866                                                 switch (newdir) {
867                                                         case dirLEFT:
868                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0);
869                                                                 break;
870                                                         case dirRIGHT:
871                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0);
872                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
873                                                                 break;
874                                                         case dirFAR:
875                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
876                                                                 glRotatef(270.0, 0.0, 1.0, 0.0);
877                                                                 break;
878                                                         case dirNEAR:
879                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
880                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
881                                                                 break;
882                                                 }
883                                                 break;
884                                         case dirLEFT:
885                                                 switch (newdir) {
886                                                         case dirUP:
887                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0);
888                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
889                                                                 break;
890                                                         case dirDOWN:
891                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0);
892                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
893                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
894                                                                 break;
895                                                         case dirFAR:
896                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
897                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
898                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
899                                                                 break;
900                                                         case dirNEAR:
901                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
902                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
903                                                                 glRotatef(180.0, 0.0, 0.0, 1.0);
904                                                                 break;
905                                                 }
906                                                 break;
907                                         case dirRIGHT:
908                                                 switch (newdir) {
909                                                         case dirUP:
910                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0);
911                                                                 break;
912                                                         case dirDOWN:
913                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0);
914                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
915                                                                 break;
916                                                         case dirFAR:
917                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
918                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
919                                                                 break;
920                                                         case dirNEAR:
921                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
922                                                                 glRotatef(90.0, 1.0, 0.0, 0.0);
923                                                                 break;
924                                                 }
925                                                 break;
926                                         case dirNEAR:
927                                                 switch (newdir) {
928                                                         case dirLEFT:
929                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
930                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
931                                                                 break;
932                                                         case dirRIGHT:
933                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
934                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
935                                                                 glRotatef(180.0, 0.0, 1.0, 0.0);
936                                                                 break;
937                                                         case dirUP:
938                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
939                                                                 glRotatef(270.0, 0.0, 1.0, 0.0);
940                                                                 break;
941                                                         case dirDOWN:
942                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0 - (one_third));
943                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
944                                                                 glRotatef(180.0, 0.0, 0.0, 1.0);
945                                                                 break;
946                                                 }
947                                                 break;
948                                         case dirFAR:
949                                                 switch (newdir) {
950                                                         case dirUP:
951                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 + (one_third), (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
952                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
953                                                                 break;
954                                                         case dirDOWN:
955                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0, (pp->PY - 12) / 3.0 * 4.0 - (one_third), (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
956                                                                 glRotatef(90.0, 0.0, 1.0, 0.0);
957                                                                 glRotatef(180.0, 1.0, 0.0, 0.0);
958                                                                 break;
959                                                         case dirLEFT:
960                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 - (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
961                                                                 glRotatef(90.0, 1.0, 0.0, 0.0);
962                                                                 break;
963                                                         case dirRIGHT:
964                                                                 glTranslatef((pp->PX - 16) / 3.0 * 4.0 + (one_third), (pp->PY - 12) / 3.0 * 4.0, (pp->PZ - 16) / 3.0 * 4.0 + (one_third));
965                                                                 glRotatef(270.0, 1.0, 0.0, 0.0);
966                                                                 glRotatef(180.0, 0.0, 0.0, 1.0);
967                                                                 break;
968                                                 }
969                                                 break;
970                                 }
971                                 myElbow(mi, (sysT == 2));
972                                 break;
973                 }
974                 glPopMatrix();
975         }
976
977         OPX = pp->PX;
978         OPY = pp->PY;
979         OPZ = pp->PZ;
980         pp->olddir = pp->nowdir;
981         pp->nowdir = newdir;
982         switch (pp->nowdir) {
983                 case dirUP:
984                         pp->PY++;
985                         break;
986                 case dirDOWN:
987                         pp->PY--;
988                         break;
989                 case dirLEFT:
990                         pp->PX--;
991                         break;
992                 case dirRIGHT:
993                         pp->PX++;
994                         break;
995                 case dirNEAR:
996                         pp->PZ++;
997                         break;
998                 case dirFAR:
999                         pp->PZ--;
1000                         break;
1001         }
1002         pp->Cells[pp->PX][pp->PY][pp->PZ] = 1;
1003
1004         /* Cells'face pipe */
1005         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);
1006         MakeTube(mi, newdir);
1007
1008         glPopMatrix();
1009
1010         glFlush();
1011
1012     if (mi->fps_p) do_fps (mi);
1013
1014     if (dbuf_p)
1015       glXSwapBuffers(display, window);
1016 }
1017
1018 #ifndef STANDALONE
1019 ENTRYPOINT void
1020 change_pipes (ModeInfo * mi)
1021 {
1022         pipesstruct *pp = &pipes[MI_SCREEN(mi)];
1023
1024         if (!pp->glx_context)
1025                 return;
1026
1027         glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(pp->glx_context));
1028         pinit(mi, 1);
1029 }
1030 #endif /* !STANDALONE */
1031
1032
1033 ENTRYPOINT void
1034 release_pipes (ModeInfo * mi)
1035 {
1036         if (pipes != NULL) {
1037                 int         screen;
1038
1039                 for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
1040                         pipesstruct *pp = &pipes[screen];
1041
1042                         if (pp->glx_context) {
1043
1044                                 /* Display lists MUST be freed while their glXContext is current. */
1045                                 glXMakeCurrent(MI_DISPLAY(mi), pp->window, *(pp->glx_context));
1046
1047                                 if (pp->valve)
1048                                         glDeleteLists(pp->valve, 1);
1049                                 if (pp->bolts)
1050                                         glDeleteLists(pp->bolts, 1);
1051                                 if (pp->betweenbolts)
1052                                         glDeleteLists(pp->betweenbolts, 1);
1053
1054                                 if (pp->elbowbolts)
1055                                         glDeleteLists(pp->elbowbolts, 1);
1056                                 if (pp->elbowcoins)
1057                                         glDeleteLists(pp->elbowcoins, 1);
1058
1059                                 if (pp->guagehead)
1060                                         glDeleteLists(pp->guagehead, 1);
1061                                 if (pp->guageface)
1062                                         glDeleteLists(pp->guageface, 1);
1063                                 if (pp->guagedial)
1064                                         glDeleteLists(pp->guagedial, 1);
1065                                 if (pp->guageconnector)
1066                                         glDeleteLists(pp->guageconnector, 1);
1067                                 if (pp->teapot)
1068                                         glDeleteLists(pp->teapot, 1);
1069                         }
1070                 }
1071
1072                 (void) free((void *) pipes);
1073                 pipes = NULL;
1074         }
1075         FreeAllGL(mi);
1076 }
1077
1078 XSCREENSAVER_MODULE ("Pipes", pipes)
1079
1080 #endif