From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / sproingies.c
index e5446f700716e7b62c9e1aa31901f51c97c40815..4752d41d79a59a0c00ff58636d7d062e85169be5 100644 (file)
@@ -36,9 +36,7 @@ static const char sccsid[] = "@(#)sproingies.c        4.04 97/07/28 xlockmore";
 
 #ifdef USE_GL
 
-#ifdef HAVE_COCOA
-# include <OpenGL/glu.h>
-#else
+#if !defined(HAVE_JWZGLES) && !defined(HAVE_COCOA)
 # include <GL/glu.h>
 #endif
 
@@ -510,8 +508,10 @@ RenderSproingie(int t, sp_instance * si)
 {
        GLfloat     scale, pointsize, mat_color[4] =
        {0.0, 0.0, 0.0, 1.0};
+#ifndef HAVE_JWZGLES
        GLdouble    clipplane[4] =
        {0.0, 1.0, 0.0, 0.0};
+#endif
        struct sPosColor *thisSproingie = &(si->positions[t]);
 
        if (thisSproingie->life < 1)
@@ -536,9 +536,14 @@ RenderSproingie(int t, sp_instance * si)
                             (GLfloat) (thisSproingie->y) +
                             ((GLfloat) (thisSproingie->frame) / 9.0),
                             (GLfloat) (thisSproingie->z));
+
+#ifndef HAVE_JWZGLES
+        /* OpenGLES doesn't have this but it doesn't seem to matter */
                clipplane[3] = ((GLdouble) (thisSproingie->frame) / 9.0) +
                        (si->wireframe ? 0.0 : 0.1);
                glClipPlane(GL_CLIP_PLANE0, clipplane);
+#endif
+
 /**            glCallList(si->sproingies[0]);*/
 /**/   renderList(si->sproingies[0], si->wireframe);
                glDisable(GL_CLIP_PLANE0);
@@ -546,7 +551,11 @@ RenderSproingie(int t, sp_instance * si)
                glTranslatef((GLfloat) (thisSproingie->x) + 0.5,
                             (GLfloat) (thisSproingie->y) + 0.5,
                             (GLfloat) (thisSproingie->z) - 0.5);
-               scale = (GLfloat) (1 << (thisSproingie->frame - BOOM_FRAME));
+               {
+                       int boom_scale = thisSproingie->frame - BOOM_FRAME;
+                       if (boom_scale >= 31) boom_scale = 31;
+                       scale = (GLfloat) (1 << boom_scale);
+               }
                glScalef(scale, scale, scale);
                if (!si->wireframe) {
                        if (!si->mono)
@@ -755,6 +764,9 @@ void
 CleanupSproingies(int screen)
 {
        sp_instance *si = &si_list[screen];
+
+    if (! si) return;
+
 /*
        int         t;
        if (si->SproingieBoom) {
@@ -799,6 +811,9 @@ InitSproingies(int wfmode, int grnd, int mspr, int smrtspr,
        sp_instance *si;
        int         t;
 
+       active_screens++;
+       CleanupSproingies(screen);
+
        if (si_list == NULL) {
                if ((si_list = (sp_instance *) calloc(numscreens,
                                              sizeof (sp_instance))) == NULL)
@@ -806,9 +821,6 @@ InitSproingies(int wfmode, int grnd, int mspr, int smrtspr,
        }
        si = &si_list[screen];
 
-       active_screens++;
-       CleanupSproingies(screen);
-
        if (mspr < 0)
                mspr = 0;
        if (mspr >= MAXSPROING)