From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / hypertorus.c
index 7e1cc3e7651839b2fbefb45f6ae3ce64ee57257d..3ae6aadfc1676be19ae2e2a209d8ae313c8184d6 100644 (file)
@@ -89,7 +89,7 @@ static const char sccsid[] = "@(#)hypertorus.c  1.2 05/09/28 xlockmore";
                             "*showFPS:    False \n" \
                            "*suppressRotationAnimation: True\n" \
 
-# define refresh_hypertorus 0
+# define free_hypertorus 0
 # define release_hypertorus 0
 # include "xlockmore.h"         /* from the xscreensaver distribution */
 #else  /* !STANDALONE */
@@ -744,11 +744,19 @@ static void display_hypertorus(ModeInfo *mi)
 ENTRYPOINT void reshape_hypertorus(ModeInfo *mi, int width, int height)
 {
   hypertorusstruct *hp = &hyper[MI_SCREEN(mi)];
+  double h = (GLfloat) height / (GLfloat) width;  
+  int y = 0;
+
+  if (width > height * 5) {   /* tiny window: show middle */
+    height = width * 9/16;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
 
   hp->WindW = (GLint)width;
   hp->WindH = (GLint)height;
-  glViewport(0,0,width,height);
-  hp->aspect = (GLfloat)width/(GLfloat)height;
+  glViewport(0,y,width,height);
+  hp->aspect = h;
 }
 
 
@@ -830,7 +838,7 @@ ENTRYPOINT void init_hypertorus(ModeInfo *mi)
 {
   hypertorusstruct *hp;
 
-  MI_INIT(mi, hyper, NULL);
+  MI_INIT(mi, hyper);
   hp = &hyper[MI_SCREEN(mi)];