From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / quasicrystal.c
index 75b35d807e1c5304e184d0b3f7e8d0412452a907..2e761e358e2cc4f4663c9fd7c5b6c0da685bbed6 100644 (file)
@@ -22,6 +22,7 @@
                        "*contrast:     30          \n" \
                        "*showFPS:      False       \n" \
                        "*wireframe:    False       \n" \
+                       "*suppressRotationAnimation: True\n" \
 
 # define refresh_quasicrystal 0
 # define release_quasicrystal 0
@@ -121,6 +122,24 @@ quasicrystal_handle_event (ModeInfo *mi, XEvent *event)
       bp->button_down_p = False;
       return True;
     }
+  else if (event->xany.type == ButtonPress &&  /* wheel up or right */
+           (event->xbutton.button == Button4 ||
+            event->xbutton.button == Button7))
+    {
+    UP:
+      if (bp->contrast <= 0) return False;
+      bp->contrast--;
+      return True;
+    }
+  else if (event->xany.type == ButtonPress &&  /* wheel down or left */
+           (event->xbutton.button == Button5 ||
+            event->xbutton.button == Button6))
+    {
+    DOWN:
+      if (bp->contrast >= 100) return False;
+      bp->contrast++;
+      return True;
+    }
   else if (event->xany.type == MotionNotify &&
            bp->button_down_p)
     {
@@ -140,6 +159,24 @@ quasicrystal_handle_event (ModeInfo *mi, XEvent *event)
       bp->mousey = event->xmotion.y;
       return True;
     }
+  else
+    {
+      if (event->xany.type == KeyPress)
+        {
+          KeySym keysym;
+          char c = 0;
+          XLookupString (&event->xkey, &c, 1, &keysym, 0);
+          if (c == '<' || c == ',' || c == '-' || c == '_' ||
+              keysym == XK_Left || keysym == XK_Up || keysym == XK_Prior)
+            goto UP;
+          else if (c == '>' || c == '.' || c == '=' || c == '+' ||
+                   keysym == XK_Right || keysym == XK_Down ||
+                   keysym == XK_Next)
+            goto DOWN;
+        }
+
+      return screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event);
+    }
 
   return False;
 }
@@ -155,14 +192,7 @@ init_quasicrystal (ModeInfo *mi)
   int tex_width;
   int i;
 
-  if (!bps) {
-    bps = (quasicrystal_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (quasicrystal_configuration));
-    if (!bps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, bps, NULL);
 
   bp = &bps[MI_SCREEN(mi)];
 
@@ -273,7 +303,7 @@ draw_quasicrystal (ModeInfo *mi)
   Display *dpy = MI_DISPLAY(mi);
   Window window = MI_WINDOW(mi);
   int wire = MI_IS_WIREFRAME(mi);
-  double r, ps;
+  double r=0, ps=0;
   int i;
 
   if (!bp->glx_context)
@@ -289,6 +319,13 @@ draw_quasicrystal (ModeInfo *mi)
   glDisable(GL_DEPTH_TEST);
   glDisable(GL_CULL_FACE);
   glDisable (GL_LIGHTING);
+  if (!wire)
+    {
+      glEnable (GL_TEXTURE_1D);
+# ifdef HAVE_JWZGLES
+      glEnable (GL_TEXTURE_2D);  /* jwzgles needs this, bleh. */
+# endif
+    }
 
   glEnable (GL_BLEND);
   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -346,10 +383,7 @@ draw_quasicrystal (ModeInfo *mi)
       glColor4f (1, 1, 1, (wire ? 0.5 : 1.0 / bp->count));
 
       if (!wire)
-        {
-          glEnable (GL_TEXTURE_1D);
-          glBindTexture (GL_TEXTURE_1D, p->texid);
-        }
+        glBindTexture (GL_TEXTURE_1D, p->texid);
 
       glBegin (wire ? GL_LINE_LOOP : GL_QUADS);
       glNormal3f (0, 0, 1);