From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / glx / atunnel.c
index ee244ea5c137b38fe7bdd95d488ef9258c2cb090..04391a13e19cde28b46761204a320d29b0d99e81 100644 (file)
@@ -41,8 +41,9 @@ static const char sccsid[] = "@(#)atunnel.c   5.13 2004/05/25 xlockmore";
 #ifdef STANDALONE              /* xscreensaver mode */
 #define        DEFAULTS                "*delay:        10000   \n" \
                                 "*showFPS:  False   \n" \
+                                                               "*suppressRotationAnimation: True\n" \
 
-# define refresh_atunnel 0
+# define release_atunnel 0
 # define atunnel_handle_event 0
 #define MODE_atunnel
 # include "xlockmore.h"                /* from the xscreensaver distribution */
@@ -117,8 +118,8 @@ ENTRYPOINT ModeSpecOpt atunnel_opts = {countof(opts), opts, countof(vars), vars,
 
 #ifdef USE_MODULES
 ModStruct   atunnel_description =
-{"atunnel", "init_atunnel", "draw_atunnel", "release_atunnel",
- "draw_atunnel", "init_atunnel", NULL, &atunnel_opts,
+{"atunnel", "init_atunnel", "draw_atunnel", NULL,
+ "draw_atunnel", "init_atunnel", "free_atunnel", &atunnel_opts,
  1000, 1, 2, 1, 4, 1.0, "",
  "OpenGL advanced tunnel screensaver", 0, NULL};
 #endif
@@ -196,7 +197,7 @@ static void Init(ModeInfo * mi)
                LoadTexture(mi, texture5,5);
                glEnable(GL_TEXTURE_2D);
        }
-       sa->ts = InitTunnel();
+       sa->ts = atunnel_InitTunnel();
        
        /* Set lighting parameters */
        if (do_light)
@@ -212,6 +213,11 @@ static void Init(ModeInfo * mi)
        
                glEnable(GL_LIGHTING);
        }
+
+# ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
+    do_wire = 0;
+# endif
+
        if (do_wire) {
                glDisable(GL_NORMALIZE);
                glDisable(GL_CULL_FACE);
@@ -244,14 +250,20 @@ static void Init(ModeInfo * mi)
 ENTRYPOINT void
 reshape_atunnel(ModeInfo *mi, int width, int height)
 {
-       float a;
+  double h = (GLfloat) height / (GLfloat) width;  
+  int y = 0;
 
-       glViewport(0, 0, width, height);
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity();
-       a = (float)width/(float)height;
-       glFrustum(-0.1*a, 0.1*a, -0.1, 0.1, 0.1, 10);
-       glMatrixMode(GL_MODELVIEW);
+  if (width > height * 2) {   /* tiny window: show middle */
+    height = width;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
+
+  glViewport(0, y, width, height);
+  glMatrixMode(GL_PROJECTION);
+  glLoadIdentity();
+  glFrustum(-0.1*(1/h), 0.1*(1/h), -0.1, 0.1, 0.1, 10);
+  glMatrixMode(GL_MODELVIEW);
 }
 
 /* draw the screensaver once */
@@ -270,8 +282,8 @@ ENTRYPOINT void draw_atunnel(ModeInfo * mi)
 
        glLoadIdentity();
 
-       DrawTunnel(sa->ts, do_texture, do_light, sa->texture);
-       SplashScreen(sa->ts, do_wire, do_texture, do_light);
+       atunnel_DrawTunnel(sa->ts, do_texture, do_light, sa->texture);
+       atunnel_SplashScreen(sa->ts, do_wire, do_texture, do_light);
 
        glFlush();  
        /* manage framerate display */
@@ -287,10 +299,7 @@ ENTRYPOINT void init_atunnel(ModeInfo * mi)
   int screen = MI_SCREEN(mi);
   atunnelstruct *sa;
 
-  if (Atunnel == NULL) {
-       if ((Atunnel = (atunnelstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (atunnelstruct))) == NULL)
-         return;
-  }
+  MI_INIT(mi, Atunnel);
   sa = &Atunnel[screen];
 
   sa->window = MI_WINDOW(mi);
@@ -304,19 +313,11 @@ ENTRYPOINT void init_atunnel(ModeInfo * mi)
 }
 
 /* all sorts of nice cleanup code should go here! */
-ENTRYPOINT void release_atunnel(ModeInfo * mi)
+ENTRYPOINT void free_atunnel(ModeInfo * mi)
 {
 #if 0
-  int screen;
-  if (Atunnel != NULL) {
-       for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
-      atunnelstruct *sa = &Atunnel[screen];
-      FreeTunnel(sa->ts);
-       }
-       (void) free((void *) Atunnel);
-       Atunnel = NULL;
-  }
-  FreeAllGL(mi);
+  atunnelstruct *sa = &Atunnel[MI_SCREEN(mi)];
+  FreeTunnel(sa->ts);
 #endif
 }