From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / unknownpleasures.c
index 640fd3d74482be86e37934e159a386a0d48d846d..98025663cb2c5ef699d3dc582339cd3f7a22b77b 100644 (file)
@@ -13,7 +13,7 @@
  *
  * Interestingly, the original image is copyright-free:
  * http://adamcap.com/2011/05/19/history-of-joy-division-unknown-pleasures-album-art/
- * http://en.wikipedia.org/wiki/Unknown_Pleasures
+ * https://en.wikipedia.org/wiki/Unknown_Pleasures
  *
  * TODO:
  *
@@ -41,7 +41,7 @@
                        "*wireframe:    False       \n" \
                        "*geometry:    =800x800"   "\n" \
 
-# define refresh_unk 0
+# define free_unk 0
 # define release_unk 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
@@ -92,8 +92,15 @@ reshape_unk (ModeInfo *mi, int width, int height)
 {
   unk_configuration *bp = &bps[MI_SCREEN(mi)];
   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*1.5;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
+
+  glViewport (0, y, (GLint) width, (GLint) height);
 
   if (bp->orthop)
     {
@@ -175,14 +182,7 @@ init_unk (ModeInfo *mi)
 {
   unk_configuration *bp;
 
-  if (!bps) {
-    bps = (unk_configuration *)
-      calloc (MI_NUM_SCREENS(mi), sizeof (unk_configuration));
-    if (!bps) {
-      fprintf(stderr, "%s: out of memory\n", progname);
-      exit(1);
-    }
-  }
+  MI_INIT (mi, bps);
 
   bp = &bps[MI_SCREEN(mi)];
 
@@ -365,7 +365,7 @@ draw_unk (ModeInfo *mi)
       xinc *= 3;
     }
 
-# ifdef USE_IPHONE
+# ifdef HAVE_MOBILE
   /* Lower it even further for iPhone 3 */
   if (mi->xgwa.width <= 480 || mi->xgwa.height <= 480)
     {
@@ -379,7 +379,7 @@ draw_unk (ModeInfo *mi)
     xinc *= 2;
 */
 
-# endif /* USE_IPHONE */
+# endif /* HAVE_MOBILE */
 
 
   /* Make the image fill the screen a little more fully */