From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / menger.c
index e26e2d31de4afe182d9ac34861c034a7c802f0c0..249d224013f6e5d6611580587fe3040b93b45542 100644 (file)
@@ -56,7 +56,7 @@
                        "*suppressRotationAnimation: True\n" \
 
 
-# define refresh_sponge 0
+# define free_sponge 0
 # define release_sponge 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
@@ -128,8 +128,15 @@ ENTRYPOINT void
 reshape_sponge (ModeInfo *mi, int width, int height)
 {
   GLfloat h = (GLfloat) height / (GLfloat) width;
+  int y = 0;
 
-  glViewport (0, 0, (GLint) width, (GLint) height);
+  if (width > height * 5) {   /* tiny window: show middle */
+    height = width * 9/16;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
+
+  glViewport (0, y, (GLint) width, (GLint) height);
 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
@@ -401,14 +408,7 @@ init_sponge (ModeInfo *mi)
   sponge_configuration *sp;
   int wire = MI_IS_WIREFRAME(mi);
 
-  if (!sps) {
-    sps = (sponge_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (sponge_configuration));
-    if (!sps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, sps);
 
   sp = &sps[MI_SCREEN(mi)];