From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / atlantis.c
index 85bd4a59cb5c00bd10f5c7948bfe73e05ac93bd5..c310a69a770a803be4660df2e9ce0062e9131251 100644 (file)
@@ -112,6 +112,7 @@ static const char sccsid[] = "@(#)atlantis.c        5.08 2003/04/09 xlockmore";
                         "*cycles:       100 \n" \
                         "*size:        6000 \n" \
                         "*wireframe:  False \n"
+# define release_atlantis 0
 # define atlantis_handle_event 0
 # include "xlockmore.h"                /* from the xscreensaver distribution */
 #else  /* !STANDALONE */
@@ -155,7 +156,7 @@ ENTRYPOINT ModeSpecOpt atlantis_opts =
 
 #ifdef USE_MODULES
 ModStruct   atlantis_description =
-{"atlantis", "init_atlantis", "draw_atlantis", "release_atlantis",
+{"atlantis", "init_atlantis", "draw_atlantis", NULL,
  "refresh_atlantis", "change_atlantis", NULL, &atlantis_opts,
  1000, NUM_SHARKS, SHARKSPEED, SHARKSIZE, 64, 1.0, "",
  "Shows moving sharks/whales/dolphin", 0, NULL};
@@ -271,8 +272,6 @@ Init(ModeInfo *mi)
           }
         else
           {
-            GLfloat s_plane[] = { 1, 0, 0, 0 };
-            GLfloat t_plane[] = { 0, 0, 1, 0 };
             GLfloat scale = 0.0005;
 
             if (!ap->texture)
@@ -292,14 +291,17 @@ Init(ModeInfo *mi)
 
             glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
-            glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
-            glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
-            glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
-            glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
-
 # ifndef HAVE_JWZGLES
-            glEnable(GL_TEXTURE_GEN_S);
-            glEnable(GL_TEXTURE_GEN_T);
+            {
+              GLfloat s_plane[] = { 1, 0, 0, 0 };
+              GLfloat t_plane[] = { 0, 0, 1, 0 };
+              glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+              glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+              glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
+              glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
+              glEnable(GL_TEXTURE_GEN_S);
+              glEnable(GL_TEXTURE_GEN_T);
+            }
 # endif
             glEnable(GL_TEXTURE_2D);
 
@@ -353,7 +355,7 @@ clear_tank (atlantisstruct * ap)
         glPushMatrix();
         {
           glLoadIdentity();
-          glRotatef(current_device_rotation(), 0, 0, 1);
+          /* glRotatef(current_device_rotation(), 0, 0, 1); */
 
 # ifndef HAVE_JWZGLES
           glShadeModel (GL_SMOOTH);
@@ -433,6 +435,8 @@ AllDisplay(atlantisstruct * ap)
  *-----------------------------------------------------------------------------
  */
 
+static void free_atlantis(ModeInfo * mi);
+
 /*
  *-----------------------------------------------------------------------------
  *    Initialize atlantis.  Called each time the window changes.
@@ -447,11 +451,7 @@ init_atlantis(ModeInfo * mi)
        Display    *display = MI_DISPLAY(mi);
        Window      window = MI_WINDOW(mi);
 
-       if (atlantis == NULL) {
-               if ((atlantis = (atlantisstruct *) calloc(MI_NUM_SCREENS(mi),
-                                          sizeof (atlantisstruct))) == NULL)
-                       return;
-       }
+       MI_INIT(mi, atlantis, free_atlantis);
        ap = &atlantis[screen];
        ap->num_sharks = MI_COUNT(mi);
        if (ap->sharks == NULL) {
@@ -530,28 +530,18 @@ draw_atlantis(ModeInfo * mi)
 /*
  *-----------------------------------------------------------------------------
  *    The display is being taken away from us.  Free up malloc'ed 
- *      memory and X resources that we've alloc'ed.  Only called
- *      once, we must zap everything for every screen.
+ *      memory and X resources that we've alloc'ed.
  *-----------------------------------------------------------------------------
  */
 
-ENTRYPOINT void
-release_atlantis(ModeInfo * mi)
+static void
+free_atlantis(ModeInfo * mi)
 {
 #if 0
-       int         screen;
-
-       if (atlantis != NULL) {
-               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
-                       atlantisstruct *ap = &atlantis[screen];
+       atlantisstruct *ap = &atlantis[screen];
 
-                       if (ap->sharks)
-                               (void) free((void *) ap->sharks);
-               }
-               (void) free((void *) atlantis);
-               atlantis = NULL;
-       }
-       FreeAllGL(mi);
+       if (ap->sharks)
+               (void) free((void *) ap->sharks);
 #endif
 }