From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / glmatrix.c
index 1975182bb336871a7cf5a8149f5ce9b191ff0c11..7683c39ffe614331adce6e5f4922259a18fc418a 100644 (file)
@@ -20,7 +20,7 @@
                        "*showFPS:      False         \n" \
                        "*wireframe:    False         \n" \
 
-# define refresh_matrix 0
+# define free_matrix 0
 # define release_matrix 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
@@ -572,8 +572,15 @@ ENTRYPOINT void
 reshape_matrix (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();
@@ -632,6 +639,10 @@ bigendian (void)
 
    If this hack ever grows into something that displays full Latin1 text,
    well then, Something Else Will Need To Be Done.
+
+   Since currently GLMatrix does not run textclient / xscreensaver-text,
+   it's not an issue.  (XMatrix does that.)
+
  */
 static void
 spank_image (matrix_configuration *mp, XImage *xi)
@@ -818,14 +829,7 @@ init_matrix (ModeInfo *mi)
   if (wire)
     do_texture = False;
 
-  if (!mps) {
-    mps = (matrix_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (matrix_configuration));
-    if (!mps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, mps);
 
   mp = &mps[MI_SCREEN(mi)];
   mp->glx_context = init_GL(mi);