1 /* -*- Mode: C; tab-width: 4 -*- emacs friendly */
2 /* gflux - creates a fluctuating 3D grid
3 * requires OpenGL or MesaGL
5 * Copyright (c) Josiah Pease, 2000, 2003
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation. No representations are made about the suitability of this
11 * software for any purpose. It is provided "as is" without express or
14 * Thanks go to all those who worked on...
15 * MesaGL, OpenGL, UtahGLX, XFree86, gcc, vim, rxvt, the PNM (anymap) format
16 * xscreensaver and the thousands of other tools, apps and daemons that make
18 * Personal thanks to Kevin Moss, Paul Sheahee and Jamie Zawinski
20 * some xscreensaver code lifted from superquadrics. Most other glx hacks
21 * used as reference at some time.
23 * This hack and others can cause UtahGLX to crash my X server
24 * wireframe looks good with software only rendering anyway
25 * If anyone can work out why and supply a fix I'd love to hear from them
27 * Josiah Pease <gfluxcode@jpease.force9.co.uk> 21 July 2000
30 * 10 June 2000 : wireframe rippling grid standalone written
31 * 18 June 2000 : xscreensaver code added
32 * 25 June 2000 : solid and light added
33 * 04 July 2000 : majour bug hunt, xscreensaver code rewritten
34 * 08 July 2000 : texture mapping, rotation and zoom added
35 * 21 July 2000 : cleaned up code from bug hunts, manpage written
36 * 24 November 2000 : fixed x co-ord calculation in solid - textured
37 * 05 March 2001 : put back non pnmlib code with #ifdefs
38 * 11 May 2002 : fixed image problems with large images
43 #define DEFAULTS "*delay: 20000\n" \
49 # define refresh_gflux 0
50 # include "xlockmore.h" /* from the xscreensaver distribution */
51 #else /* !STANDALONE */
52 # include "xlock.h" /* from the xlockmore distribution */
53 #endif /* !STANDALONE */
55 #ifdef USE_GL /* whole file */
59 # include <X11/Xmu/Drawing.h>
61 # include <Xmu/Drawing.h>
66 #define countof(x) (sizeof((x))/sizeof((*x)))
73 #include "grab-ximage.h"
74 #include "gltrackball.h"
77 static enum {wire=0,solid,light,checker,grab} _draw;
79 static int _squares; /* grid size */
80 static int _resolution; /* wireframe resolution */
84 static float _rotationx;
85 static float _rotationy;
86 static float _rotationz;
90 static int _waveChange;
91 static float _waveHeight;
92 static float _waveFreq;
98 static XrmOptionDescRec opts[] = {
99 {"-squares", ".gflux.squares", XrmoptionSepArg, 0},
100 {"-resolution", ".gflux.resolution", XrmoptionSepArg, 0},
101 /* {"-draw", ".gflux.draw", XrmoptionSepArg, 0},*/
102 {"-mode", ".gflux.mode", XrmoptionSepArg, 0},
103 {"-wireframe", ".gflux.mode", XrmoptionNoArg, "wire"},
104 {"-flat", ".gflux.flat", XrmoptionSepArg, 0},
105 {"-speed", ".gflux.speed", XrmoptionSepArg, 0},
106 {"-rotationx", ".gflux.rotationx", XrmoptionSepArg, 0},
107 {"-rotationy", ".gflux.rotationy", XrmoptionSepArg, 0},
108 {"-rotationz", ".gflux.rotationz", XrmoptionSepArg, 0},
109 {"-waves", ".gflux.waves", XrmoptionSepArg, 0},
110 {"-waveChange", ".gflux.waveChange", XrmoptionSepArg, 0},
111 {"-waveHeight", ".gflux.waveHeight", XrmoptionSepArg, 0},
112 {"-waveFreq", ".gflux.waveFreq", XrmoptionSepArg, 0},
113 {"-zoom", ".gflux.zoom", XrmoptionSepArg, 0},
117 static argtype vars[] = {
118 {&_squares, "squares", "Squares", "19", t_Int},
119 {&_resolution, "resolution", "Resolution", "4", t_Int},
120 /* {&_draw, "draw", "Draw", "2", t_Int},*/
121 {&_flat, "flat", "Flat", "0", t_Int},
122 {&_speed, "speed", "Speed", "0.05", t_Float},
123 {&_rotationx, "rotationx", "Rotationx", "0.01", t_Float},
124 {&_rotationy, "rotationy", "Rotationy", "0.0", t_Float},
125 {&_rotationz, "rotationz", "Rotationz", "0.1", t_Float},
126 {&_waves, "waves", "Waves", "3", t_Int},
127 {&_waveChange, "waveChange", "WaveChange", "50", t_Int},
128 {&_waveHeight, "waveHeight", "WaveHeight", "1.0", t_Float},
129 {&_waveFreq, "waveFreq", "WaveFreq", "3.0", t_Float},
130 {&_zoom, "zoom", "Zoom", "1.0", t_Float},
134 static OptionStruct desc[] =
136 {"-squares num", "size of grid in squares (19)"},
137 {"-resolution num", "detail of lines making grid, wireframe only (4)"},
138 /* {"-draw num", "draw method to use: 0=wireframe 1=solid 2=lit (0)"},*/
139 {"-flat num", "shading method, not wireframe: 0=smooth 1=flat (0)"},
140 {"-speed num", "speed of waves (0.05)"},
141 {"-rotationx num", "speed of xrotation (0.01)"},
142 {"-rotationy num", "speed of yrotation (0.00)"},
143 {"-rotationz num", "speed of zrotation (0.10)"},
144 {"-waves num", "number of simultanious waves (3)"},
145 {"-waveChange num", "number of cyles for a wave to change (50)"},
146 {"-waveHeight num", "height of waves (1.0)"},
147 {"-waveFreq num", "max frequency of a wave (3.0)"},
148 {"-zoom num", "camera control (1.0)"},
151 ENTRYPOINT ModeSpecOpt gflux_opts = {countof(opts), opts, countof(vars), vars, desc};
154 ModStruct gflux_description =
155 {"gflux", "init_gflux", "draw_gflux", "release_gflux",
156 "draw_gflux", "init_gflux", NULL, &gflux_opts,
157 1000, 1, 2, 1, 4, 1.0, "",
158 "Gflux: an OpenGL gflux", 0, NULL};
161 /* structure for holding the gflux data */
162 typedef struct gfluxstruct {
164 int screen_width, screen_height;
165 GLXContext *glx_context;
168 #define MAXWAVES 10 /* should be dynamic */
170 double freq[MAXWAVES];
171 double dispy[MAXWAVES];
172 double dispx[MAXWAVES];
178 int img_width, img_height;
179 void (*drawFunc)(struct gfluxstruct *);
181 trackball_state *trackball;
193 Bool waiting_for_image_p;
196 static gfluxstruct *gfluxes = NULL;
199 static void initLighting(void);
200 static void grabTexture(gfluxstruct *);
201 static void createTexture(gfluxstruct *);
202 static void displaySolid(gfluxstruct *); /* drawFunc implementations */
203 static void displayLight(gfluxstruct *);
204 static void displayTexture(gfluxstruct *);
205 static void displayWire(gfluxstruct *);
206 static void calcGrid(gfluxstruct *);
207 static double getGrid(gfluxstruct *,double,double,double);
209 /* as macro for speed */
210 /* could do with colour cycling here */
211 /* void genColour(double);*/
212 #define genColour(X) \
214 gp->colour[0] = 0.0;\
215 gp->colour[1] = 0.5+0.5*(X);\
216 gp->colour[2] = 0.5-0.5*(X);\
219 /* BEGINNING OF FUNCTIONS */
223 gflux_handle_event (ModeInfo *mi, XEvent *event)
225 gfluxstruct *gp = &gfluxes[MI_SCREEN(mi)];
227 if (event->xany.type == ButtonPress &&
228 event->xbutton.button == Button1)
230 gp->button_down_p = True;
231 gltrackball_start (gp->trackball,
232 event->xbutton.x, event->xbutton.y,
233 MI_WIDTH (mi), MI_HEIGHT (mi));
236 else if (event->xany.type == ButtonRelease &&
237 event->xbutton.button == Button1)
239 gp->button_down_p = False;
242 else if (event->xany.type == ButtonPress &&
243 (event->xbutton.button == Button4 ||
244 event->xbutton.button == Button5))
246 gltrackball_mousewheel (gp->trackball, event->xbutton.button, 10,
247 !!event->xbutton.state);
250 else if (event->xany.type == MotionNotify &&
253 gltrackball_track (gp->trackball,
254 event->xmotion.x, event->xmotion.y,
255 MI_WIDTH (mi), MI_HEIGHT (mi));
264 userRot(gfluxstruct *gp)
266 gltrackball_rotate (gp->trackball);
269 /* draw the gflux once */
270 ENTRYPOINT void draw_gflux(ModeInfo * mi)
272 gfluxstruct *gp = &gfluxes[MI_SCREEN(mi)];
273 Display *display = MI_DISPLAY(mi);
274 Window window = MI_WINDOW(mi);
276 if (!gp->glx_context) return;
278 /* Just keep running before the texture has come in. */
279 /* if (gp->waiting_for_image_p) return; */
281 glXMakeCurrent(display, window, *(gp->glx_context));
285 if (mi->fps_p) do_fps (mi);
286 glXSwapBuffers(display, window);
290 /* reset the projection matrix */
291 static void resetProjection(void)
293 glMatrixMode(GL_PROJECTION);
295 glFrustum(-_zoom,_zoom,-0.8*_zoom,0.8*_zoom,2,6);
296 glTranslatef(0.0,0.0,-4.0);
297 glMatrixMode(GL_MODELVIEW);
301 /* Standard reshape function */
303 reshape_gflux(ModeInfo *mi, int width, int height)
305 glViewport( 0, 0, width, height );
310 /* main OpenGL initialization routine */
311 static void initializeGL(ModeInfo *mi, GLsizei width, GLsizei height)
313 gfluxstruct *gp = &gfluxes[MI_SCREEN(mi)];
315 reshape_gflux(mi, width, height);
316 glViewport( 0, 0, width, height );
318 gp->tex_xscale = 1.0; /* maybe changed later */
319 gp->tex_yscale = 1.0;
323 gp->drawFunc = (displaySolid);
324 glEnable(GL_DEPTH_TEST);
327 gp->drawFunc = (displayLight);
328 glEnable(GL_DEPTH_TEST);
332 gp->drawFunc = (displayTexture);
333 glEnable(GL_DEPTH_TEST);
338 gp->drawFunc = (displayTexture);
339 glEnable(GL_DEPTH_TEST);
345 gp->drawFunc = (displayWire);
346 glDisable(GL_DEPTH_TEST);
350 if(_flat) glShadeModel(GL_FLAT);
351 else glShadeModel(GL_SMOOTH);
356 /* xgflux initialization routine */
357 ENTRYPOINT void init_gflux(ModeInfo * mi)
359 int screen = MI_SCREEN(mi);
362 if (gfluxes == NULL) {
363 if ((gfluxes = (gfluxstruct *)
364 calloc(MI_NUM_SCREENS(mi), sizeof (gfluxstruct))) == NULL)
367 gp = &gfluxes[screen];
369 gp->trackball = gltrackball_init ();
371 gp->time = frand(1000.0); /* don't run two screens in lockstep */
374 char *s = get_string_resource (mi->dpy, "mode", "Mode");
375 if (!s || !*s) _draw = wire;
376 else if (!strcasecmp (s, "wire")) _draw = wire;
377 else if (!strcasecmp (s, "solid")) _draw = solid;
378 else if (!strcasecmp (s, "light")) _draw = light;
379 else if (!strcasecmp (s, "checker")) _draw = checker;
380 else if (!strcasecmp (s, "grab")) _draw = grab;
384 "%s: mode must be one of: wire, solid, "
385 "light, checker, or grab; not \"%s\"\n",
392 gp->window = MI_WINDOW(mi);
393 if ((gp->glx_context = init_GL(mi)) != NULL) {
394 reshape_gflux(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
395 initializeGL(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
402 ENTRYPOINT void release_gflux(ModeInfo * mi)
404 if (gfluxes != NULL) {
405 free((void *) gfluxes);
412 static void createTexture(gfluxstruct *gp)
415 unsigned int data[] = { 0xFFFFFFFF, 0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA,
416 0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 0xFFFFFFFF,
417 0xFFFFFFFF, 0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA,
418 0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 0xFFFFFFFF };
420 gp->tex_xscale = size;
421 gp->tex_yscale = size;
423 glGenTextures (1, &gp->texName);
424 glBindTexture (GL_TEXTURE_2D, gp->texName);
426 glTexImage2D (GL_TEXTURE_2D, 0, 3, size, size, 0,
427 GL_RGBA, GL_UNSIGNED_BYTE, data);
429 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
430 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
432 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
433 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
438 image_loaded_cb (const char *filename, XRectangle *geometry,
439 int image_width, int image_height,
440 int texture_width, int texture_height,
443 gfluxstruct *gp = (gfluxstruct *) closure;
444 gp->img_geom = *geometry;
446 gp->tex_xscale = (GLfloat) image_width / texture_width;
447 gp->tex_yscale = -(GLfloat) image_height / texture_height;
448 gp->img_width = image_width;
449 gp->img_height = image_height;
451 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
452 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
453 (gp->mipmap_p ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR));
455 gp->waiting_for_image_p = False;
459 grabTexture(gfluxstruct *gp)
461 if (MI_IS_WIREFRAME(gp->modeinfo))
464 gp->waiting_for_image_p = True;
466 load_texture_async (gp->modeinfo->xgwa.screen, gp->modeinfo->window,
467 *gp->glx_context, 0, 0, gp->mipmap_p, gp->texName,
468 image_loaded_cb, gp);
472 static void initLighting(void)
474 static const float ambientA[] = {0.0, 0.0, 0.0, 1.0};
475 static const float diffuseA[] = {1.0, 1.0, 1.0, 1.0};
476 static const float positionA[] = {5.0, 5.0, 15.0, 1.0};
478 static const float front_mat_shininess[] = {30.0};
479 static const float front_mat_specular[] = {0.5, 0.5, 0.5, 1.0};
481 static const float mat_diffuse[] = {0.5, 0.5, 0.5, 1.0};
483 glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
484 glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
486 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
488 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientA);
489 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseA);
490 glLightfv(GL_LIGHT0, GL_POSITION, positionA);
491 glEnable(GL_LIGHTING);
493 glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,1);
495 glEnable(GL_NORMALIZE); /* would it be faster ... */
496 glEnable(GL_COLOR_MATERIAL);
497 glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
500 /************************************/
501 /* draw implementations */
502 /* somewhat inefficient since they */
503 /* all calculate previously */
504 /* calculated values again */
505 /* storing the values in an array */
506 /* is a posibility */
507 /************************************/
508 static void displayTexture(gfluxstruct *gp)
512 double dx = 2.0/((double)_squares);
513 double dy = 2.0/((double)_squares);
515 double du = 2.0/((double)_squares);
516 double dv = 2.0/((double)_squares);
518 double xs = gp->tex_xscale;
519 double ys = gp->tex_yscale;
521 double minx, miny, maxx, maxy;
525 minx = (GLfloat) gp->img_geom.x / gp->img_width;
526 miny = (GLfloat) gp->img_geom.y / gp->img_height;
527 maxx = ((GLfloat) (gp->img_geom.x + gp->img_geom.width) /
529 maxy = ((GLfloat) (gp->img_geom.y + gp->img_geom.height) /
533 minx = (minx * 2) - 1;
534 miny = (miny * 2) - 1;
535 maxx = (maxx * 2) - 1;
536 maxy = (maxy * 2) - 1;
546 glMatrixMode (GL_TEXTURE);
548 glTranslatef(-1,-1,0);
550 glMatrixMode (GL_MODELVIEW);
554 glRotatef(gp->anglex,1,0,0);
555 glRotatef(gp->angley,0,1,0);
556 glRotatef(gp->anglez,0,0,1);
557 glScalef(1,1,(GLfloat)_waveHeight);
558 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
559 glEnable(GL_TEXTURE_2D);
562 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
563 glBindTexture(GL_TEXTURE_2D, gp->texName);
564 check_gl_error("texture binding");
566 glColor3f(0.5,0.5,0.5);
568 for(x = minx, u = minu; x < maxx - 0.01; x += dx, u += du) {
569 glBegin(GL_QUAD_STRIP);
570 for (y = miny, v = minv; y <= maxy + 0.01; y += dy, v += dv) {
571 z = getGrid(gp,x,y,gp->time);
572 glTexCoord2f(u*xs,v*ys);
574 getGrid(gp,x+dx,y,gp->time)-getGrid(gp, x-dx,y,gp->time),
575 getGrid(gp,x,y+dy,gp->time)-getGrid(gp, x,y-dy,gp->time),
580 z = getGrid(gp,x+dx,y,gp->time);
581 glTexCoord2f((u+du)*xs,v*ys);
583 getGrid(gp,x+dx+dx,y,gp->time)-getGrid(gp, x,y,gp->time),
584 getGrid(gp,x+dx,y+dy,gp->time)-getGrid(gp, x+dx,y-dy,gp->time),
587 glVertex3f(x+dx,y,z);
592 /* Draw a border around the grid.
594 glColor3f(0.4, 0.4, 0.4);
595 glDisable(GL_TEXTURE_2D);
596 glEnable (GL_LINE_SMOOTH);
598 glBegin(GL_LINE_LOOP);
600 for (x = minx; x <= maxx; x += dx)
601 glVertex3f (x, y, getGrid (gp, x, y, gp->time));
603 for (y = miny; y <= maxy; y += dy)
604 glVertex3f (x, y, getGrid (gp, x, y, gp->time));
606 for (x = maxx; x >= minx; x -= dx)
607 glVertex3f (x, y, getGrid (gp, x, y, gp->time));
609 for (y = maxy; y >= miny; y -= dy)
610 glVertex3f (x, y, getGrid (gp, x, y, gp->time));
613 glEnable(GL_TEXTURE_2D);
615 if (! gp->button_down_p) {
617 gp->anglex -= _rotationx;
618 gp->angley -= _rotationy;
619 gp->anglez -= _rotationz;
622 static void displaySolid(gfluxstruct *gp)
626 double dx = 2.0/((double)_squares);
627 double dy = 2.0/((double)_squares);
630 glRotatef(gp->anglex,1,0,0);
631 glRotatef(gp->angley,0,1,0);
632 glRotatef(gp->anglez,0,0,1);
634 glScalef(1,1,(GLfloat)_waveHeight);
635 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
637 for(x=-1;x<0.9999;x+=dx) {
638 glBegin(GL_QUAD_STRIP);
639 for(y=-1;y<=1;y+=dy) {
640 z = getGrid(gp, x,y,gp->time);
642 glColor3fv(gp->colour);
645 z = getGrid(gp, x+dx,y,gp->time);
647 glColor3fv(gp->colour);
648 glVertex3f(x+dx,y,z);
653 if (! gp->button_down_p) {
655 gp->anglex -= _rotationx;
656 gp->angley -= _rotationy;
657 gp->anglez -= _rotationz;
662 static void displayLight(gfluxstruct *gp)
666 double dx = 2.0/((double)_squares);
667 double dy = 2.0/((double)_squares);
670 glRotatef(gp->anglex,1,0,0);
671 glRotatef(gp->angley,0,1,0);
672 glRotatef(gp->anglez,0,0,1);
674 glScalef(1,1,(GLfloat)_waveHeight);
675 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
677 for(x=-1;x<0.9999;x+=dx) {
678 glBegin(GL_QUAD_STRIP);
679 for(y=-1;y<=1;y+=dy) {
680 z = getGrid(gp, x,y,gp->time);
682 glColor3fv(gp->colour);
684 getGrid(gp, x+dx,y,gp->time)-getGrid(gp, x-dx,y,gp->time),
685 getGrid(gp, x,y+dy,gp->time)-getGrid(gp, x,y-dy,gp->time),
690 z = getGrid(gp, x+dx,y,gp->time);
692 glColor3fv(gp->colour);
694 getGrid(gp, x+dx+dx,y,gp->time)-getGrid(gp, x,y,gp->time),
695 getGrid(gp, x+dx,y+dy,gp->time)-getGrid(gp, x+dx,y-dy,gp->time),
698 glVertex3f(x+dx,y,z);
703 if (! gp->button_down_p) {
705 gp->anglex -= _rotationx;
706 gp->angley -= _rotationy;
707 gp->anglez -= _rotationz;
711 static void displayWire(gfluxstruct *gp)
715 double dx1 = 2.0/((double)(_squares*_resolution)) - 0.00001;
716 double dy1 = 2.0/((double)(_squares*_resolution)) - 0.00001;
717 double dx2 = 2.0/((double)_squares) - 0.00001;
718 double dy2 = 2.0/((double)_squares) - 0.00001;
721 glRotatef(gp->anglex,1,0,0);
722 glRotatef(gp->angley,0,1,0);
723 glRotatef(gp->anglez,0,0,1);
725 glScalef(1,1,(GLfloat)_waveHeight);
726 glClear(GL_COLOR_BUFFER_BIT);
728 for(x=-1;x<=1;x+=dx2) {
729 glBegin(GL_LINE_STRIP);
730 for(y=-1;y<=1;y+=dy1) {
731 z = getGrid(gp, x,y,gp->time);
733 glColor3fv(gp->colour);
738 for(y=-1;y<=1;y+=dy2) {
739 glBegin(GL_LINE_STRIP);
740 for(x=-1;x<=1;x+=dx1) {
741 z = getGrid(gp, x,y,gp->time);
743 glColor3fv(gp->colour);
749 if (! gp->button_down_p) {
751 gp->anglex -= _rotationx;
752 gp->angley -= _rotationy;
753 gp->anglez -= _rotationz;
757 /* generates new ripples */
758 static void calcGrid(gfluxstruct *gp)
762 if (gp->button_down_p) return;
764 tmp = 1.0/((double)_waveChange);
765 if(!(gp->counter%_waveChange)) {
766 gp->newWave = ((int)(gp->counter*tmp))%_waves;
767 gp->dispx[gp->newWave] = -frand(1.0);
768 gp->dispy[gp->newWave] = -frand(1.0);
769 gp->freq[gp->newWave] = _waveFreq * frand(1.0);
770 gp->wa[gp->newWave] = 0.0;
773 gp->wa[gp->newWave] += tmp;
774 gp->wa[(gp->newWave+1)%_waves] -= tmp;
777 /* returns a height for the grid given time and x,y space co-ords */
778 static double getGrid(gfluxstruct *gp, double x, double y, double a)
784 tmp = 1.0/((float)_waves);
785 for(i=0;i<_waves;i++) {
786 retval += gp->wa[i] * tmp * sin( gp->freq[i]
787 * ( (x+gp->dispx[i]) * (x+gp->dispx[i])
788 + (y+gp->dispy[i]) * (y+gp->dispy[i]) +a ) );
794 XSCREENSAVER_MODULE ("Gflux", gflux)