From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / superquadrics.c
index 9293218f2f56c5ba11da0802896707fcf019dbc6..3c0833543deedcefd181a6f37b100540316a65cb 100644 (file)
@@ -78,6 +78,8 @@ static const char sccsid[] = "@(#)superquadrics.c     4.07 97/11/24 xlockmore";
                                        "*wireframe:    False   \n"                     \
                                        "*suppressRotationAnimation: True\n" \
 
+# define free_superquadrics 0
+# define release_superquadrics 0
 # define superquadrics_handle_event 0
 # include "xlockmore.h"                                /* from the xscreensaver distribution */
 #else  /* !STANDALONE */
@@ -115,7 +117,7 @@ ENTRYPOINT ModeSpecOpt superquadrics_opts =
 
 #ifdef USE_MODULES
 ModStruct   superquadrics_description =
-{"superquadrics", "init_superquadrics", "draw_superquadrics", "release_superquadrics",
+{"superquadrics", "init_superquadrics", "draw_superquadrics", NULL,
  "refresh_superquadrics", "init_superquadrics", NULL, &superquadrics_opts,
  1000, 25, 40, 1, 4, 1.0, "",
  "Shows 3D mathematical shapes", 0, NULL};
@@ -617,7 +619,14 @@ ReshapeSuperquadrics(int w, int h)
                glViewport(0, 0, w, h);
        }
 #else
-    glViewport(0, 0, w, h);
+    int y = 0;
+
+    if (w > h * 5) {   /* tiny window: show middle */
+      h = w;
+      y = -h/2;
+    }
+
+    glViewport(0, y, w, h);
 #endif
 
        glMatrixMode(GL_PROJECTION);
@@ -726,11 +735,7 @@ init_superquadrics(ModeInfo * mi)
 
        superquadricsstruct *sp;
 
-       if (superquadrics == NULL) {
-               if ((superquadrics = (superquadricsstruct *) calloc(MI_NUM_SCREENS(mi),
-                                     sizeof (superquadricsstruct))) == NULL)
-                       return;
-       }
+       MI_INIT (mi, superquadrics);
        sp = &superquadrics[screen];
        sp->mono = (MI_IS_MONO(mi) ? 1 : 0);
 
@@ -780,11 +785,13 @@ draw_superquadrics(ModeInfo * mi)
        glXSwapBuffers(display, window);
 }
 
+#ifndef STANDALONE
 ENTRYPOINT void
 refresh_superquadrics(ModeInfo * mi)
 {
        /* Nothing happens here */
 }
+#endif
 
 ENTRYPOINT void
 reshape_superquadrics(ModeInfo * mi, int width, int height)
@@ -792,16 +799,6 @@ reshape_superquadrics(ModeInfo * mi, int width, int height)
   ReshapeSuperquadrics(MI_WIDTH(mi), MI_HEIGHT(mi));
 }
 
-ENTRYPOINT void
-release_superquadrics(ModeInfo * mi)
-{
-       if (superquadrics != NULL) {
-               (void) free((void *) superquadrics);
-               superquadrics = NULL;
-       }
-       FreeAllGL(mi);
-}
-
 
 #endif