From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / glblur.c
1 /* glblur --- radial blur using GL textures
2  * Copyright (c) 2002-2014 Jamie Zawinski <jwz@jwz.org>
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation.  No representations are made about the suitability of this
9  * software for any purpose.  It is provided "as is" without express or 
10  * implied warranty.
11  *
12  * This program draws a box and a few line segments, and generates a flowing
13  * radial blur outward from it -- this causes flowing field effects.
14  * It does this by rendering the scene into a small texture, then repeatedly
15  * rendering increasingly-enlarged and increasingly-transparent versions of
16  * that texture onto the frame buffer.
17  *
18  * As such, it's quite graphics intensive -- don't bother trying to run this
19  * if you don't have hardware-accelerated texture support.
20  *
21  * Inspired by Dario Corno's Radial Blur tutorial:
22  *    http://nehe.gamedev.net/tutorials/lesson.asp?l=36
23  */
24
25 #define DEFAULTS        "*delay:    10000 \n" \
26                         "*showFPS:  False \n" \
27                         "*fpsSolid: True  \n"
28
29 # define refresh_glblur 0
30 # define release_glblur 0
31 #undef countof
32 #define countof(x) (sizeof((x))/sizeof((*x)))
33
34 #undef ABS
35 #define ABS(n) ((n)<0?-(n):(n))
36 #undef SIGNOF
37 #define SIGNOF(n) ((n)<0?-1:1)
38
39 #include "xlockmore.h"
40 #include "colors.h"
41 #include "rotator.h"
42 #include "gltrackball.h"
43 #include <ctype.h>
44
45 #ifdef USE_GL /* whole file */
46
47 #define DEF_SPIN        "XYZ"
48 #define DEF_WANDER      "True"
49 #define DEF_BLUR_SIZE   "15"
50
51 typedef struct metaball metaball;
52
53
54 typedef struct {
55   GLXContext *glx_context;
56   rotator *rot;
57   trackball_state *trackball;
58   Bool button_down_p;
59
60   GLuint obj_dlist0;    /* east-west cube faces */
61   GLuint obj_dlist1;    /* north-south cube faces */
62   GLuint obj_dlist2;    /* up-down cube faces */
63   GLuint obj_dlist3;    /* spikes coming out of the cube's corners */
64   GLuint scene_dlist1;  /* the cube, rotated and translated */
65   GLuint scene_dlist2;  /* the spikes, rotated and translated */
66   int scene_polys1;     /* polygons in scene, not counting texture overlay */
67   int scene_polys2;     /* polygons in scene, not counting texture overlay */
68
69   GLuint texture;
70   unsigned int *tex_data;
71   int tex_w, tex_h;
72
73   int ncolors;
74   XColor *colors0;
75   XColor *colors1;
76   XColor *colors2;
77   XColor *colors3;
78   int ccolor;
79
80   Bool show_cube_p;
81   Bool show_spikes_p;
82
83 } glblur_configuration;
84
85 static glblur_configuration *bps = NULL;
86
87 static char *do_spin;
88 static Bool do_wander;
89 static int blursize;
90
91 static XrmOptionDescRec opts[] = {
92   { "-spin",   ".spin",   XrmoptionSepArg, 0 },
93   { "+spin",   ".spin",   XrmoptionNoArg, "" },
94   { "-blursize", ".blurSize", XrmoptionSepArg, 0 },
95   { "-wander", ".wander", XrmoptionNoArg, "True" },
96   { "+wander", ".wander", XrmoptionNoArg, "False" },
97 };
98
99 static argtype vars[] = {
100   {&do_spin,   "spin",   "Spin",   DEF_SPIN,   t_String},
101   {&do_wander, "wander", "Wander", DEF_WANDER, t_Bool},
102   {&blursize,  "blurSize","BlurSize", DEF_BLUR_SIZE,  t_Int},
103 };
104
105 ENTRYPOINT ModeSpecOpt glblur_opts = {countof(opts), opts, countof(vars), vars, NULL};
106
107
108 /* Window management, etc
109  */
110 ENTRYPOINT void
111 reshape_glblur (ModeInfo *mi, int width, int height)
112 {
113   GLfloat h = (GLfloat) height / (GLfloat) width;
114
115   glViewport (0, 0, (GLint) width, (GLint) height);
116
117   glMatrixMode(GL_PROJECTION);
118   glLoadIdentity();
119   gluPerspective (30.0, 1/h, 1.0, 100.0);
120
121   glMatrixMode(GL_MODELVIEW);
122   glLoadIdentity();
123   gluLookAt( 0.0, 0.0, 8.0,
124              0.0, 0.0, 0.0,
125              0.0, 1.0, 0.0);
126
127   glClear(GL_COLOR_BUFFER_BIT);
128 }
129
130
131 \f
132 /* Objects in the scene 
133  */
134
135 static void
136 generate_object (ModeInfo *mi)
137 {
138   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
139   Bool wire = MI_IS_WIREFRAME (mi);
140   int s = 10;
141
142   bp->scene_polys1 = 0;
143   bp->scene_polys2 = 0;
144
145   glNewList (bp->obj_dlist0, GL_COMPILE);
146   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* front */
147   glNormal3f (0, 0, 1);
148   glTexCoord2f(1, 0); glVertex3f ( 0.5, -0.5,  0.5);
149   glTexCoord2f(0, 0); glVertex3f ( 0.5,  0.5,  0.5);
150   glTexCoord2f(0, 1); glVertex3f (-0.5,  0.5,  0.5);
151   glTexCoord2f(1, 1); glVertex3f (-0.5, -0.5,  0.5);
152   bp->scene_polys1++;
153   glEnd();
154
155   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* back */
156   glNormal3f (0, 0, -1);
157   glTexCoord2f(0, 0); glVertex3f (-0.5, -0.5, -0.5);
158   glTexCoord2f(0, 1); glVertex3f (-0.5,  0.5, -0.5);
159   glTexCoord2f(1, 1); glVertex3f ( 0.5,  0.5, -0.5);
160   glTexCoord2f(1, 0); glVertex3f ( 0.5, -0.5, -0.5);
161   bp->scene_polys1++;
162   glEnd();
163   glEndList();
164
165   glNewList (bp->obj_dlist1, GL_COMPILE);
166   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* left */
167   glNormal3f (-1, 0, 0);
168   glTexCoord2f(1, 1); glVertex3f (-0.5,  0.5,  0.5);
169   glTexCoord2f(1, 0); glVertex3f (-0.5,  0.5, -0.5);
170   glTexCoord2f(0, 0); glVertex3f (-0.5, -0.5, -0.5);
171   glTexCoord2f(0, 1); glVertex3f (-0.5, -0.5,  0.5);
172   bp->scene_polys1++;
173   glEnd();
174
175   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* right */
176   glNormal3f (1, 0, 0);
177   glTexCoord2f(1, 1); glVertex3f ( 0.5, -0.5, -0.5);
178   glTexCoord2f(1, 0); glVertex3f ( 0.5,  0.5, -0.5);
179   glTexCoord2f(0, 0); glVertex3f ( 0.5,  0.5,  0.5);
180   glTexCoord2f(0, 1); glVertex3f ( 0.5, -0.5,  0.5);
181   bp->scene_polys1++;
182   glEnd();
183   glEndList();
184
185   glNewList (bp->obj_dlist2, GL_COMPILE);
186   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* top */
187   glNormal3f (0, 1, 0);
188   glTexCoord2f(0, 0); glVertex3f ( 0.5,  0.5,  0.5);
189   glTexCoord2f(0, 1); glVertex3f ( 0.5,  0.5, -0.5);
190   glTexCoord2f(1, 1); glVertex3f (-0.5,  0.5, -0.5);
191   glTexCoord2f(1, 0); glVertex3f (-0.5,  0.5,  0.5);
192   bp->scene_polys1++;
193   glEnd();
194
195   glBegin (wire ? GL_LINE_LOOP : GL_QUADS);     /* bottom */
196   glNormal3f (0, -1, 0);
197   glTexCoord2f(1, 0); glVertex3f (-0.5, -0.5,  0.5);
198   glTexCoord2f(0, 0); glVertex3f (-0.5, -0.5, -0.5);
199   glTexCoord2f(0, 1); glVertex3f ( 0.5, -0.5, -0.5);
200   glTexCoord2f(1, 1); glVertex3f ( 0.5, -0.5,  0.5);
201   bp->scene_polys1++;
202   glEnd();
203   glEndList();
204
205   glNewList (bp->obj_dlist3, GL_COMPILE);
206   glLineWidth (1);
207   glBegin(GL_LINES);
208   glVertex3f(-s, 0, 0); glVertex3f(s, 0, 0);    /* face spikes */
209   glVertex3f(0, -s, 0); glVertex3f(0, s, 0);
210   glVertex3f(0, 0, -s); glVertex3f(0, 0, s);
211   bp->scene_polys2 += 3;
212   glEnd();
213
214   glLineWidth (8);
215   glBegin(GL_LINES);
216   glVertex3f(-s, -s, -s); glVertex3f( s,  s,  s);  /* corner spikes */
217   glVertex3f(-s, -s,  s); glVertex3f( s,  s, -s);
218   glVertex3f(-s,  s, -s); glVertex3f( s, -s,  s);
219   glVertex3f( s, -s, -s); glVertex3f(-s,  s,  s);
220   bp->scene_polys2 += 4;
221   glEnd();
222   glEndList ();
223
224   check_gl_error ("object generation");
225 }
226
227
228 static void
229 init_texture (ModeInfo *mi)
230 {
231   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
232
233   if (bp->tex_data) free (bp->tex_data);
234
235   bp->tex_w = 128;
236   bp->tex_h = 128;
237   bp->tex_data = (unsigned int *)
238     malloc (bp->tex_w * bp->tex_h * 4 * sizeof (unsigned int));
239
240   glGenTextures (1, &bp->texture);
241   glBindTexture (GL_TEXTURE_2D, bp->texture);
242   glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
243                 bp->tex_w, bp->tex_h, 0,
244                 GL_RGBA,
245                 /* GL_UNSIGNED_BYTE, */
246                 GL_UNSIGNED_INT_8_8_8_8_REV,
247                 bp->tex_data);
248   check_gl_error ("texture generation");
249   glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
250   glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
251 }
252
253
254 static void
255 render_scene_to_texture (ModeInfo *mi)
256 {
257   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
258
259   glViewport (0, 0, bp->tex_w, bp->tex_h);
260
261   glCallList (bp->scene_dlist1);
262   glCallList (bp->scene_dlist2);
263
264   glBindTexture (GL_TEXTURE_2D, bp->texture);
265   glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0,
266                     bp->tex_w, bp->tex_h, 0);
267   check_gl_error ("texture2D");
268
269   glViewport (0, 0, MI_WIDTH(mi), MI_HEIGHT(mi));
270 }
271
272 static void
273 overlay_blur_texture (ModeInfo *mi)
274 {
275   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
276   int w = MI_WIDTH (mi);
277   int h = MI_HEIGHT (mi);
278   int times = blursize;
279   int i;
280   GLfloat inc = 0.02 * (25.0 / times);
281
282   GLfloat spost = 0;                /* starting texture coordinate offset */
283   GLfloat alpha_inc;                /* transparency fade factor */
284   GLfloat alpha = 0.2;              /* initial transparency */
285
286   glEnable (GL_TEXTURE_2D);
287   glDisable (GL_DEPTH_TEST);
288   glBlendFunc (GL_SRC_ALPHA,GL_ONE);
289   glEnable (GL_BLEND);
290   glBindTexture (GL_TEXTURE_2D, bp->texture);
291
292
293   /* switch to orthographic projection, saving both previous matrixes
294      on their respective stacks.
295    */
296   glMatrixMode (GL_PROJECTION);
297   glPushMatrix();
298   glLoadIdentity();
299   glOrtho (0, w, h, 0, -1, 1);
300   glMatrixMode (GL_MODELVIEW);
301   glPushMatrix();
302   glLoadIdentity();     
303
304
305   alpha_inc = alpha / times;
306
307   mi->polygon_count = bp->scene_polys1 + bp->scene_polys2;
308
309   glBegin (GL_QUADS);
310   for (i = 0; i < times; i++)
311     {
312       glColor4f (1, 1, 1, alpha);
313       glTexCoord2f (0+spost, 1-spost); glVertex2f (0, 0);
314       glTexCoord2f (0+spost, 0+spost); glVertex2f (0, h);
315       glTexCoord2f (1-spost, 0+spost); glVertex2f (w, h);
316       glTexCoord2f (1-spost, 1-spost); glVertex2f (w, 0);
317       spost += inc;
318       alpha -= alpha_inc;
319       mi->polygon_count++;
320     }
321   glEnd();
322
323   /* Switch back to perspective projection, restoring the saved matrixes
324    */
325   glMatrixMode (GL_PROJECTION);
326   glPopMatrix();
327   glMatrixMode (GL_MODELVIEW);
328   glPopMatrix();                
329
330   glEnable (GL_DEPTH_TEST);
331   glDisable (GL_BLEND);
332   glDisable (GL_TEXTURE_2D);
333   glBindTexture (GL_TEXTURE_2D, 0);
334 }
335
336
337 \f
338 /* Startup initialization
339  */
340
341 ENTRYPOINT Bool
342 glblur_handle_event (ModeInfo *mi, XEvent *event)
343 {
344   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
345
346   if (gltrackball_event_handler (event, bp->trackball,
347                                  MI_WIDTH (mi), MI_HEIGHT (mi),
348                                  &bp->button_down_p))
349     return True;
350
351   return False;
352 }
353
354
355 ENTRYPOINT void 
356 init_glblur (ModeInfo *mi)
357 {
358   glblur_configuration *bp;
359   int wire = MI_IS_WIREFRAME(mi);
360
361   if (!bps) {
362     bps = (glblur_configuration *)
363       calloc (MI_NUM_SCREENS(mi), sizeof (glblur_configuration));
364     if (!bps) {
365       fprintf(stderr, "%s: out of memory\n", progname);
366       exit(1);
367     }
368   }
369
370   bp = &bps[MI_SCREEN(mi)];
371
372   bp->glx_context = init_GL(mi);
373
374   reshape_glblur (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
375   clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
376
377   if (!wire)
378     {
379       GLfloat gamb[4]= {0.2, 0.2,  0.2, 1.0};
380       GLfloat pos[4] = {0.0, 5.0, 10.0, 1.0};
381       GLfloat amb[4] = {0.2, 0.2,  0.2, 1.0};
382       GLfloat dif[4] = {0.3, 0.3,  0.3, 1.0};
383       GLfloat spc[4] = {0.8, 0.8,  0.8, 1.0};
384       GLfloat shiny = 128;
385
386       glEnable(GL_LIGHTING);
387       glEnable(GL_LIGHT0);
388
389       glEnable(GL_DEPTH_TEST);
390       glEnable(GL_CULL_FACE);
391       glEnable(GL_NORMALIZE);
392       glShadeModel(GL_SMOOTH);
393
394       glLightModelfv (GL_LIGHT_MODEL_AMBIENT, gamb);
395
396       glLightfv(GL_LIGHT0, GL_POSITION, pos);
397       glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
398       glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
399       glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
400
401       glEnable(GL_LIGHTING);
402       glEnable(GL_LIGHT0);
403
404       glMaterialf(GL_FRONT, GL_SHININESS, shiny);
405     }
406
407   {
408     Bool spinx=False, spiny=False, spinz=False;
409     double spin_speed   = 0.9;
410     double wander_speed = 0.06;
411
412     char *s = do_spin;
413     while (*s)
414       {
415         if      (*s == 'x' || *s == 'X') spinx = True;
416         else if (*s == 'y' || *s == 'Y') spiny = True;
417         else if (*s == 'z' || *s == 'Z') spinz = True;
418         else if (*s == '0') ;
419         else
420           {
421             fprintf (stderr,
422          "%s: spin must contain only the characters X, Y, or Z (not \"%s\")\n",
423                      progname, do_spin);
424             exit (1);
425           }
426         s++;
427       }
428
429     bp->rot = make_rotator (spinx ? spin_speed : 0,
430                             spiny ? spin_speed : 0,
431                             spinz ? spin_speed : 0,
432                             1.0,
433                             do_wander ? wander_speed : 0,
434                             False);
435     bp->trackball = gltrackball_init (True);
436   }
437
438   if (blursize < 0) blursize = 0;
439   if (blursize > 200) blursize = 200;
440
441   bp->ncolors = 128;
442   bp->colors0 = (XColor *) calloc(bp->ncolors, sizeof(XColor));
443   bp->colors1 = (XColor *) calloc(bp->ncolors, sizeof(XColor));
444   bp->colors2 = (XColor *) calloc(bp->ncolors, sizeof(XColor));
445   bp->colors3 = (XColor *) calloc(bp->ncolors, sizeof(XColor));
446   make_smooth_colormap (0, 0, 0, bp->colors0, &bp->ncolors, False, 0, False);
447   make_smooth_colormap (0, 0, 0, bp->colors1, &bp->ncolors, False, 0, False);
448   make_smooth_colormap (0, 0, 0, bp->colors2, &bp->ncolors, False, 0, False);
449   make_smooth_colormap (0, 0, 0, bp->colors3, &bp->ncolors, False, 0, False);
450   bp->ccolor = 0;
451
452   bp->obj_dlist0   = glGenLists (1);
453   bp->obj_dlist1   = glGenLists (1);
454   bp->obj_dlist2   = glGenLists (1);
455   bp->obj_dlist3   = glGenLists (1);
456   bp->scene_dlist1 = glGenLists (1);
457   bp->scene_dlist2 = glGenLists (1);
458
459   init_texture (mi);
460
461   generate_object (mi);
462 }
463
464
465 /* Render one frame
466  */
467 ENTRYPOINT void
468 draw_glblur (ModeInfo *mi)
469 {
470   glblur_configuration *bp = &bps[MI_SCREEN(mi)];
471   Display *dpy = MI_DISPLAY(mi);
472   Window window = MI_WINDOW(mi);
473
474   GLfloat color0[4] = {0.0, 0.0, 0.0, 1.0};
475   GLfloat color1[4] = {0.0, 0.0, 0.0, 1.0};
476   GLfloat color2[4] = {0.0, 0.0, 0.0, 1.0};
477   GLfloat color3[4] = {0.0, 0.0, 0.0, 1.0};
478   GLfloat spec[4]   = {1.0, 1.0, 1.0, 1.0};
479
480   double rx, ry, rz;
481   double px, py, pz;
482   int extra_polys = 0;
483
484   if (!bp->glx_context)
485     return;
486
487   glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
488
489   /* Decide what we're drawing
490    */
491   if (0 == (random() % 30))
492     {
493       bp->show_cube_p   = (0 == (random() % 10));
494       bp->show_spikes_p = (0 == (random() % 20));
495     }
496
497   /* Select new colors for the various objects
498    */
499   color0[0] = bp->colors0[bp->ccolor].red   / 65536.0;
500   color0[1] = bp->colors0[bp->ccolor].green / 65536.0;
501   color0[2] = bp->colors0[bp->ccolor].blue  / 65536.0;
502
503   color1[0] = bp->colors1[bp->ccolor].red   / 65536.0;
504   color1[1] = bp->colors1[bp->ccolor].green / 65536.0;
505   color1[2] = bp->colors1[bp->ccolor].blue  / 65536.0;
506
507   color2[0] = bp->colors2[bp->ccolor].red   / 65536.0;
508   color2[1] = bp->colors2[bp->ccolor].green / 65536.0;
509   color2[2] = bp->colors2[bp->ccolor].blue  / 65536.0;
510
511   color3[0] = bp->colors3[bp->ccolor].red   / 65536.0;
512   color3[1] = bp->colors3[bp->ccolor].green / 65536.0;
513   color3[2] = bp->colors3[bp->ccolor].blue  / 65536.0;
514
515   bp->ccolor++;
516   if (bp->ccolor >= bp->ncolors) bp->ccolor = 0;
517
518
519   get_position (bp->rot, &px, &py, &pz, !bp->button_down_p);
520   get_rotation (bp->rot, &rx, &ry, &rz, !bp->button_down_p);
521
522   px = (px - 0.5) * 2;
523   py = (py - 0.5) * 2;
524   pz = (pz - 0.5) * 8;
525   rx *= 360;
526   ry *= 360;
527   rz *= 360;
528
529   /* Generate scene_dlist1, which contains the box (not spikes),
530      rotated into position.
531    */
532   glNewList (bp->scene_dlist1, GL_COMPILE);
533   {
534     glMatrixMode (GL_MODELVIEW);
535     glPushMatrix ();
536     glTranslatef (px, py, pz);
537     gltrackball_rotate (bp->trackball);
538     glRotatef (rx, 1.0, 0.0, 0.0);
539     glRotatef (ry, 0.0, 1.0, 0.0);
540     glRotatef (rz, 0.0, 0.0, 1.0);
541
542     glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec);
543
544     glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color0);
545     glCallList (bp->obj_dlist0);
546
547     glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color1);
548     glCallList (bp->obj_dlist1);
549
550     glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color2);
551     glCallList (bp->obj_dlist2);
552
553     glMatrixMode (GL_MODELVIEW);
554     glPopMatrix ();
555   }
556   glEndList ();
557
558
559   /* Generate scene_dlist2, which contains the spikes (not box),
560      rotated into position.
561    */
562   glNewList (bp->scene_dlist2, GL_COMPILE);
563   {
564     glMatrixMode (GL_MODELVIEW);
565     glPushMatrix ();
566     glTranslatef (px, py, pz);
567     gltrackball_rotate (bp->trackball);
568     glRotatef (rx, 1.0, 0.0, 0.0);
569     glRotatef (ry, 0.0, 1.0, 0.0);
570     glRotatef (rz, 0.0, 0.0, 1.0);
571
572     glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color3);
573     glCallList (bp->obj_dlist3);
574
575     glMatrixMode (GL_MODELVIEW);
576     glPopMatrix ();
577   }
578   glEndList ();
579
580
581   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
582
583   render_scene_to_texture (mi);
584
585   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
586
587   if (bp->show_cube_p || bp->button_down_p)
588     {
589       glCallList (bp->scene_dlist1);
590       extra_polys += bp->scene_polys1;
591     }
592   if (bp->show_spikes_p || bp->button_down_p)
593     {
594       glCallList (bp->scene_dlist2);
595       extra_polys += bp->scene_polys2;
596     }
597
598   overlay_blur_texture (mi);
599   mi->polygon_count += extra_polys;
600
601   glFlush ();
602
603   if (mi->fps_p) do_fps (mi);
604   glFinish();
605
606   glXSwapBuffers(dpy, window);
607 }
608
609 XSCREENSAVER_MODULE ("GLBlur", glblur)
610
611 #endif /* USE_GL */