http://www.tienza.es/crux/src/www.jwz.org/xscreensaver/xscreensaver-5.05.tar.gz
[xscreensaver] / hacks / glx / boing.c
1 /* boing, Copyright (c) 2005-2008 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  *
11  * A clone of the Amiga 1000 "Boing" demo.  This was the first graphics demo
12  * for the Amiga, written by Dale Luck and RJ Mical during a break at the 1984
13  * Consumer Electronics Show (or so the legend goes.)  The boing ball was
14  * briefly the official logo of Amiga Inc., until they were bought by
15  * Commodore later that year.
16  *
17  * With no arguments, this program looks a lot like the original Amiga demo.
18  * With "-smooth -lighting", it looks... less old.
19  *
20  * The amiga version made noise when the ball hit the walls.  This version
21  * does not, obviously.
22  */
23
24 #define DEFAULTS        "*delay:        30000            \n" \
25                         "*showFPS:      False            \n" \
26                         "*wireframe:    False            \n" \
27
28 # define refresh_boing 0
29 # define release_boing 0
30 #undef countof
31 #define countof(x) (sizeof((x))/sizeof((*x)))
32
33 #include "xlockmore.h"
34 #include "gltrackball.h"
35 #include <ctype.h>
36
37 #ifdef USE_GL /* whole file */
38
39
40 #define DEF_SPIN        "True"
41 #define DEF_LIGHTING    "False"
42 #define DEF_SMOOTH      "False"
43 #define DEF_SCANLINES   "True"
44 #define DEF_SPEED       "1.0"
45 #define DEF_SIZE        "0.5"
46 #define DEF_ANGLE       "15"
47 #define DEF_MERIDIANS   "16"
48 #define DEF_PARALLELS   "8"
49 #define DEF_TILES       "12"
50 #define DEF_THICKNESS   "0.05"
51
52 #define DEF_BALL_COLOR1  "#CC1919"
53 #define DEF_BALL_COLOR2  "#F2F2F2"
54 #define DEF_GRID_COLOR   "#991999"
55 #define DEF_SHADOW_COLOR "#303030"
56 #define DEF_BACKGROUND   "#8C8C8C"
57
58 typedef struct { GLfloat x, y, z; } XYZ;
59
60 typedef struct {
61   GLXContext *glx_context;
62   trackball_state *trackball;
63   Bool button_down_p;
64
65   GLuint ball_list;
66   double ball_x,   ball_y,   ball_z,   ball_th;
67   double ball_dx,  ball_dy,  ball_dz,  ball_dth;
68   double ball_ddx, ball_ddy, ball_ddz;
69
70   GLfloat ball_color1[4], ball_color2[4], grid_color[4];
71   GLfloat bg_color[4], shadow_color[4];
72   GLfloat lightpos[4];
73
74 } boing_configuration;
75
76 static boing_configuration *bps = NULL;
77
78 static Bool spin;
79 static Bool lighting_p;
80 static Bool smooth_p;
81 static Bool scanlines_p;
82 static GLfloat speed;
83 static int angle;
84 static GLfloat ball_size;
85 static unsigned int meridians;
86 static unsigned int parallels;
87 static unsigned int tiles;
88 static GLfloat thickness;
89 static char *ball_color1_str, *ball_color2_str, *grid_color_str,
90   *shadow_str, *bg_str;
91
92 static XrmOptionDescRec opts[] = {
93   { "-spin",       ".spin",      XrmoptionNoArg,  "True"  },
94   { "+spin",       ".spin",      XrmoptionNoArg,  "False" },
95   { "-lighting",   ".lighting",  XrmoptionNoArg,  "True"  },
96   { "+lighting",   ".lighting",  XrmoptionNoArg,  "False" },
97   { "-smooth",     ".smooth",    XrmoptionNoArg,  "True"  },
98   { "+smooth",     ".smooth",    XrmoptionNoArg,  "False" },
99   { "-scanlines",  ".scanlines", XrmoptionNoArg,  "True"  },
100   { "+scanlines",  ".scanlines", XrmoptionNoArg,  "False" },
101   { "-speed",      ".speed",     XrmoptionSepArg, 0 },
102   { "-angle",      ".angle",     XrmoptionSepArg, 0 },
103   { "-size",       ".ballSize",  XrmoptionSepArg, 0 },
104   { "-meridians",  ".meridians", XrmoptionSepArg, 0 },
105   { "-parallels",  ".parallels", XrmoptionSepArg, 0 },
106   { "-tiles",      ".tiles",     XrmoptionSepArg, 0 },
107   { "-thickness",  ".thickness", XrmoptionSepArg, 0 },
108   { "-ball-color1",".ballColor1",XrmoptionSepArg, 0 },
109   { "-ball-color2",".ballColor2",XrmoptionSepArg, 0 },
110   { "-grid-color", ".gridColor", XrmoptionSepArg, 0 },
111   { "-shadow-color",".shadowColor",XrmoptionSepArg, 0 },
112 };
113
114 static argtype vars[] = {
115   {&spin,      "spin",      "Spin",       DEF_SPIN,      t_Bool},
116   {&lighting_p,"lighting",  "Lighting",   DEF_LIGHTING,  t_Bool},
117   {&smooth_p,  "smooth",    "Smooth",     DEF_SMOOTH,    t_Bool},
118   {&scanlines_p,"scanlines","Scanlines",  DEF_SCANLINES, t_Bool},
119   {&speed,     "speed",     "Speed",      DEF_SPEED,     t_Float},
120   {&angle,     "angle",     "Angle",      DEF_ANGLE,     t_Int},
121   {&ball_size, "ballSize",  "BallSize",   DEF_SIZE,      t_Float},
122   {&meridians, "meridians", "meridians",  DEF_MERIDIANS, t_Int},
123   {&parallels, "parallels", "parallels",  DEF_PARALLELS, t_Int},
124   {&tiles,     "tiles",     "Tiles",      DEF_TILES,     t_Int},
125   {&thickness, "thickness", "Thickness",  DEF_THICKNESS, t_Float},
126   {&ball_color1_str, "ballColor1", "BallColor1", DEF_BALL_COLOR1, t_String},
127   {&ball_color2_str, "ballColor2", "BallColor2", DEF_BALL_COLOR2, t_String},
128   {&grid_color_str,  "gridColor",  "GridColor",  DEF_GRID_COLOR,  t_String},
129   {&shadow_str,      "shadowColor","ShadowColor",DEF_SHADOW_COLOR,t_String},
130   /* dammit, -background is too magic... */
131   {&bg_str,        "boingBackground", "Background", DEF_BACKGROUND, t_String},
132 };
133
134 ENTRYPOINT ModeSpecOpt boing_opts = {countof(opts), opts, countof(vars), vars, NULL};
135
136 static void
137 parse_color (ModeInfo *mi, const char *name, const char *s, GLfloat *a)
138 {
139   XColor c;
140   a[3] = 1.0;  /* alpha */
141
142   if (! XParseColor (MI_DISPLAY(mi), MI_COLORMAP(mi), s, &c))
143     {
144       fprintf (stderr, "%s: can't parse %s color %s", progname, name, s);
145       exit (1);
146     }
147   a[0] = c.red   / 65536.0;
148   a[1] = c.green / 65536.0;
149   a[2] = c.blue  / 65536.0;
150 }
151
152
153 static void
154 draw_grid (ModeInfo *mi)
155 {
156   boing_configuration *bp = &bps[MI_SCREEN(mi)];
157   int x, y;
158   GLfloat t2  = (GLfloat) tiles / 2;
159   GLfloat s = 1.0 / (tiles + thickness);
160   GLfloat z = 0;
161
162   GLfloat lw = MI_HEIGHT(mi) * 0.06 * thickness;
163
164   glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, bp->grid_color);
165   glColor3fv (bp->grid_color);
166
167   glPushMatrix();
168   glScalef(s, s, s);
169   glTranslatef (-t2, -t2, 0);
170
171   glLineWidth (lw);
172   glBegin (GL_LINES);
173   for (y = 0; y <= tiles; y++)
174     {
175       glVertex3f (0,     y, z);
176       glVertex3f (tiles, y, z);
177       /*mi->polygon_count++;*/
178     }
179   for (x = 0; x <= tiles; x++)
180     {
181       glVertex3f (x, tiles, z);
182       glVertex3f (x, 0,     z);
183       /*mi->polygon_count++;*/
184     }
185
186   glEnd();
187   glPopMatrix();
188 }
189
190
191 static void
192 draw_box (ModeInfo *mi)
193 {
194   /* boing_configuration *bp = &bps[MI_SCREEN(mi)]; */
195   glPushMatrix();
196   glTranslatef (0, 0, -0.5);
197 /*  glFrontFace (GL_CCW);*/
198   draw_grid (mi);
199   glPopMatrix();
200
201   glPushMatrix();
202   glRotatef (90, 1, 0, 0);
203   glTranslatef (0, 0, 0.5);
204 /*  glFrontFace (GL_CW);*/
205   draw_grid (mi);
206   glPopMatrix();
207 }
208
209
210 static void
211 draw_ball (ModeInfo *mi)
212 {
213   boing_configuration *bp = &bps[MI_SCREEN(mi)];
214   int wire = MI_IS_WIREFRAME(mi);
215   int x, y;
216   int xx = meridians;
217   int yy = parallels;
218   int scale = (smooth_p ? 5 : 1);
219
220   if (lighting_p && !wire)
221     glEnable (GL_LIGHTING);
222
223   if (parallels < 3)
224     scale *= 2;
225
226   xx *= scale;
227   yy *= scale;
228
229   glFrontFace (GL_CW);
230
231   glPushMatrix();
232   glTranslatef (bp->ball_x, bp->ball_y, bp->ball_z);
233   glScalef (ball_size, ball_size, ball_size);
234   glRotatef (-angle,      0, 0, 1);
235   glRotatef (bp->ball_th, 0, 1, 0);
236
237   for (y = 0; y < yy; y++)
238     {
239       GLfloat thy0 = y     * (M_PI * 2) / (yy * 2) + M_PI_2;
240       GLfloat thy1 = (y+1) * (M_PI * 2) / (yy * 2) + M_PI_2;
241
242       for (x = 0; x < xx; x++)
243         {
244           GLfloat thx0 = x     * (M_PI * 2) / xx;
245           GLfloat thx1 = (x+1) * (M_PI * 2) / xx;
246           XYZ p;
247           Bool bgp = ((x/scale) & 1) ^ ((y/scale) & 1);
248
249           if (wire && bgp) continue;
250
251           glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
252                         (bgp ? bp->ball_color2 : bp->ball_color1));
253           glColor3fv (bgp ? bp->ball_color2 : bp->ball_color1);
254
255           glBegin (wire ? GL_LINE_LOOP : GL_QUADS);
256
257           if (!smooth_p)
258             {
259               p.x = cos((thy0+thy1)/2) * cos((thx0+thx1)/2);
260               p.y = sin((thy0+thy1)/2);
261               p.z = cos((thy0+thy1)/2) * sin((thx0+thx1)/2);
262               glNormal3f (-p.x, -p.y, -p.z);
263             }
264
265           p.x = cos(thy0) * cos(thx0) / 2;
266           p.y = sin(thy0)             / 2;
267           p.z = cos(thy0) * sin(thx0) / 2;
268           if (smooth_p)
269             glNormal3f (-p.x, -p.y, -p.z);
270           glVertex3f (p.x, p.y, p.z);
271
272           p.x = cos(thy1) * cos(thx0) / 2;
273           p.y = sin(thy1)             / 2;
274           p.z = cos(thy1) * sin(thx0) / 2;
275           if (smooth_p)
276             glNormal3f (-p.x, -p.y, -p.z);
277           glVertex3f (p.x, p.y, p.z);
278
279           p.x = cos(thy1) * cos(thx1) / 2;
280           p.y = sin(thy1)             / 2;
281           p.z = cos(thy1) * sin(thx1) / 2;
282           if (smooth_p)
283             glNormal3f (-p.x, -p.y, -p.z);
284           glVertex3f (p.x, p.y, p.z);
285
286           p.x = cos(thy0) * cos(thx1) / 2;
287           p.y = sin(thy0)             / 2;
288           p.z = cos(thy0) * sin(thx1) / 2;
289           if (smooth_p)
290             glNormal3f (-p.x, -p.y, -p.z);
291           glVertex3f (p.x, p.y, p.z);
292
293           glEnd ();
294           mi->polygon_count++;
295         }
296     }
297
298   glPopMatrix();
299
300   if (lighting_p && !wire)
301     glDisable(GL_LIGHTING);
302 }
303
304
305 static void
306 draw_shadow (ModeInfo *mi)
307 {
308   boing_configuration *bp = &bps[MI_SCREEN(mi)];
309   int wire = MI_IS_WIREFRAME(mi);
310   GLfloat xoff = 0.14;
311   GLfloat yoff = 0.07;
312   int y;
313   int yy = parallels;
314   int scale = (smooth_p ? 5 : 1);
315
316   if (lighting_p && !wire)
317     glEnable (GL_BLEND);
318
319   if (parallels < 3)
320     scale *= 2;
321
322   yy *= scale;
323
324   glPushMatrix();
325   glTranslatef (bp->ball_x + xoff, bp->ball_y + yoff, -0.49);
326   glScalef (ball_size, ball_size, ball_size);
327   glRotatef (-angle, 0, 0, 1);
328
329   glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, bp->shadow_color);
330   glColor4fv (bp->shadow_color);
331
332   glFrontFace (GL_CCW);
333   glNormal3f (0, 0, 1);
334   glBegin (wire ? GL_LINE_LOOP : GL_TRIANGLE_FAN);
335   if (!wire) glVertex3f (0, 0, 0);
336
337   for (y = 0; y < yy*2+1; y++)
338     {
339       GLfloat thy0 = y * (M_PI * 2) / (yy * 2) + M_PI_2;
340       glVertex3f (cos(thy0) / 2, sin(thy0) / 2, 0);
341       mi->polygon_count++;
342     }
343
344   glEnd ();
345
346   glPopMatrix();
347
348   if (lighting_p && !wire)
349     glDisable (GL_BLEND);
350 }
351
352
353 static void
354 draw_scanlines (ModeInfo *mi)
355 {
356   /* boing_configuration *bp = &bps[MI_SCREEN(mi)]; */
357   int wire = MI_IS_WIREFRAME(mi);
358   int w = MI_WIDTH(mi);
359   int h = MI_HEIGHT(mi);
360
361   if (h <= 300) return;
362
363   if (!wire)
364     {
365       glEnable (GL_BLEND);
366       glDisable (GL_DEPTH_TEST);
367     }
368
369   glMatrixMode(GL_PROJECTION);
370   glPushMatrix();
371   {
372     glLoadIdentity();
373     glMatrixMode(GL_MODELVIEW);
374     glPushMatrix();
375     {
376       int lh, ls;
377       int y;
378       glLoadIdentity();
379       gluOrtho2D (0, w, 0, h);
380
381       if      (h > 500) lh = 4, ls = 4;
382       else if (h > 300) lh = 2, ls = 1;
383       else              lh = 1, ls = 1;
384
385       if (lh == 1)
386         glDisable (GL_BLEND);
387
388       glLineWidth (lh);
389       glColor4f (0, 0, 0, 0.3);
390
391       glBegin(GL_LINES);
392       for (y = 0; y < h; y += lh + ls)
393         {
394           glVertex3f (0, y, 0);
395           glVertex3f (w, y, 0);
396         }
397       glEnd();
398     }
399     glPopMatrix();
400   }
401   glMatrixMode(GL_PROJECTION);
402   glPopMatrix();
403   glMatrixMode(GL_MODELVIEW);
404
405   if (!wire)
406     {
407       glDisable (GL_BLEND);
408       glEnable (GL_DEPTH_TEST);
409     }
410 }
411
412
413
414 static void
415 tick_physics (ModeInfo *mi)
416 {
417   boing_configuration *bp = &bps[MI_SCREEN(mi)];
418   GLfloat s2 = ball_size / 2;
419   GLfloat max = 0.5 - s2;
420   GLfloat min = -max;
421
422   bp->ball_th += bp->ball_dth;
423   while (bp->ball_th > 360) bp->ball_th -= 360;
424   while (bp->ball_th < 0)   bp->ball_th += 360;
425
426   bp->ball_dx += bp->ball_ddx;
427   bp->ball_x  += bp->ball_dx;
428   if      (bp->ball_x < min) bp->ball_x = min, bp->ball_dx = -bp->ball_dx,
429     bp->ball_dth = -bp->ball_dth,
430     bp->ball_dx += (frand(speed/2) - speed);
431   else if (bp->ball_x > max) bp->ball_x = max, bp->ball_dx = -bp->ball_dx,
432     bp->ball_dth = -bp->ball_dth,
433     bp->ball_dx += (frand(speed/2) - speed);
434
435   bp->ball_dy += bp->ball_ddy;
436   bp->ball_y  += bp->ball_dy;
437   if      (bp->ball_y < min) bp->ball_y = min, bp->ball_dy = -bp->ball_dy;
438   else if (bp->ball_y > max) bp->ball_y = max, bp->ball_dy = -bp->ball_dy;
439
440   bp->ball_dz += bp->ball_ddz;
441   bp->ball_z  += bp->ball_dz;
442   if      (bp->ball_z < min) bp->ball_z = min, bp->ball_dz = -bp->ball_dz;
443   else if (bp->ball_z > max) bp->ball_z = max, bp->ball_dz = -bp->ball_dz;
444 }
445
446
447
448 /* Window management, etc
449  */
450 ENTRYPOINT void
451 reshape_boing (ModeInfo *mi, int width, int height)
452 {
453   GLfloat h = (GLfloat) height / (GLfloat) width;
454
455   h *= 4.0 / 3.0;   /* Back in the caveman days we couldn't even afford
456                        square pixels! */
457
458   glViewport (0, 0, (GLint) width, (GLint) height);
459
460   glMatrixMode(GL_PROJECTION);
461   glLoadIdentity();
462   gluPerspective (8.0, 1/h, 1.0, 10.0);
463
464   glMatrixMode(GL_MODELVIEW);
465   glLoadIdentity();
466   gluLookAt (0.0, 0.0, 8.0,
467              0.0, 0.0, 0.0,
468              0.0, 1.0, 0.0);
469
470   glClear(GL_COLOR_BUFFER_BIT);
471 }
472
473
474 ENTRYPOINT Bool
475 boing_handle_event (ModeInfo *mi, XEvent *event)
476 {
477   boing_configuration *bp = &bps[MI_SCREEN(mi)];
478
479   if (event->xany.type == ButtonPress &&
480       event->xbutton.button == Button1)
481     {
482       bp->button_down_p = True;
483       gltrackball_start (bp->trackball,
484                          event->xbutton.x, event->xbutton.y,
485                          MI_WIDTH (mi), MI_HEIGHT (mi));
486       return True;
487     }
488   else if (event->xany.type == ButtonRelease &&
489            event->xbutton.button == Button1)
490     {
491       bp->button_down_p = False;
492       return True;
493     }
494   else if (event->xany.type == ButtonPress &&
495            (event->xbutton.button == Button4 ||
496             event->xbutton.button == Button5 ||
497             event->xbutton.button == Button6 ||
498             event->xbutton.button == Button7))
499     {
500       gltrackball_mousewheel (bp->trackball, event->xbutton.button, 10,
501                               !!event->xbutton.state);
502       return True;
503     }
504   else if (event->xany.type == MotionNotify &&
505            bp->button_down_p)
506     {
507       gltrackball_track (bp->trackball,
508                          event->xmotion.x, event->xmotion.y,
509                          MI_WIDTH (mi), MI_HEIGHT (mi));
510       return True;
511     }
512
513   return False;
514 }
515
516
517 ENTRYPOINT void 
518 init_boing (ModeInfo *mi)
519 {
520   boing_configuration *bp;
521   int wire = MI_IS_WIREFRAME(mi);
522
523   if (!bps) {
524     bps = (boing_configuration *)
525       calloc (MI_NUM_SCREENS(mi), sizeof (boing_configuration));
526     if (!bps) {
527       fprintf(stderr, "%s: out of memory\n", progname);
528       exit(1);
529     }
530
531     bp = &bps[MI_SCREEN(mi)];
532   }
533
534   bp = &bps[MI_SCREEN(mi)];
535
536   bp->glx_context = init_GL(mi);
537
538   if (tiles < 1) tiles = 1;
539
540   if (smooth_p)
541     {
542       if (meridians < 1) meridians = 1;
543       if (parallels < 1) parallels = 1;
544     }
545   else
546     {
547       if (meridians < 3) meridians = 3;
548       if (parallels < 2) parallels = 2;
549     }
550
551   if (meridians > 1 && meridians & 1) meridians++;  /* odd numbers look bad */
552
553
554   if (thickness <= 0) thickness = 0.001;
555   else if (thickness > 1) thickness = 1;
556
557   reshape_boing (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
558
559   parse_color (mi, "ballColor1",  ball_color1_str,  bp->ball_color1);
560   parse_color (mi, "ballColor2",  ball_color2_str,  bp->ball_color2);
561   parse_color (mi, "gridColor",   grid_color_str,   bp->grid_color);
562   parse_color (mi, "shadowColor", shadow_str,       bp->shadow_color);
563   parse_color (mi, "background",  bg_str,           bp->bg_color);
564
565   bp->shadow_color[3] = 0.9;
566
567   glClearColor (bp->bg_color[0], bp->bg_color[1], bp->bg_color[2], 1);
568
569   if (!wire)
570     {
571       glEnable(GL_DEPTH_TEST);
572       glEnable(GL_CULL_FACE);
573     }
574
575   bp->lightpos[0] = 0.5;
576   bp->lightpos[1] = 0.5;
577   bp->lightpos[2] = -1;
578   bp->lightpos[3] = 0;
579
580   if (lighting_p && !wire)
581     {
582       GLfloat amb[4] = {0, 0, 0, 1};
583       GLfloat dif[4] = {1, 1, 1, 1};
584       GLfloat spc[4] = {1, 1, 1, 1};
585       glEnable(GL_LIGHT0);
586       glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
587       glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
588       glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
589     }
590
591   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
592
593   speed = speed / 800.0;
594
595   bp->ball_dth = (spin ? -speed * 7 * 360 : 0);
596
597   bp->ball_x   = 0.5 - ((ball_size/2) + frand(1-ball_size));
598   bp->ball_y   = 0.2;
599   bp->ball_dx  = speed * 6 + frand(speed);
600   bp->ball_ddy = -speed;
601
602   bp->ball_dz  = speed * 6 + frand(speed);
603
604   bp->trackball = gltrackball_init ();
605 }
606
607
608 ENTRYPOINT void
609 draw_boing (ModeInfo *mi)
610 {
611   boing_configuration *bp = &bps[MI_SCREEN(mi)];
612   Display *dpy = MI_DISPLAY(mi);
613   Window window = MI_WINDOW(mi);
614
615   if (!bp->glx_context)
616     return;
617
618   glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
619
620   mi->polygon_count = 0;
621
622   glShadeModel(GL_SMOOTH);
623
624   glEnable(GL_NORMALIZE);
625
626   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
627
628   if (! bp->button_down_p)
629     tick_physics (mi);
630
631   glPushMatrix ();
632   gltrackball_rotate (bp->trackball);
633
634   glLightfv (GL_LIGHT0, GL_POSITION, bp->lightpos);
635
636   glDisable (GL_CULL_FACE);
637   glDisable (GL_DEPTH_TEST);
638
639   glEnable (GL_LINE_SMOOTH);
640   glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
641   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
642   glEnable (GL_BLEND);
643
644   draw_box (mi);
645   draw_shadow (mi);
646
647   glEnable (GL_CULL_FACE);
648   glEnable (GL_DEPTH_TEST);
649
650   draw_ball (mi);
651   if (scanlines_p)
652     draw_scanlines (mi);
653
654   glPopMatrix ();
655
656   if (mi->fps_p) do_fps (mi);
657   glFinish();
658
659   glXSwapBuffers(dpy, window);
660 }
661
662 XSCREENSAVER_MODULE ("Boing", boing)
663
664 #endif /* USE_GL */