From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver] / hacks / glx / tunnel_draw.c
index c87fea9dd57a875f4989df065180b2c6144d21aa..54132fbee12616defe3ff295b12845c7617f8121 100644 (file)
@@ -45,10 +45,7 @@ static const char sccsid[] = "@(#)tunnel_draw.c      5.13 2004/05/25 xlockmore";
 #include <math.h>
 
 #ifdef STANDALONE
-# ifdef HAVE_COCOA
-#  include <OpenGL/gl.h>
-#  include <OpenGL/glu.h>
-# else
+# ifndef HAVE_COCOA
 #  include <GL/gl.h>
 #  include <GL/glu.h>
 # endif
@@ -207,6 +204,7 @@ static void LoadPath(struct tunnel_state *st)
                }
                else
                {
+                       if (!path1) path1 = st->path;
                        path2 = (tnPath *)malloc(sizeof(tnPath));
                        path1->next = path2;
                        path1 = path2;
@@ -249,7 +247,9 @@ void DrawTunnel(struct tunnel_state *st,
        
        cmpos = st->cam_pos;
        /* Get current curve */
-       if (st->cam_pos->next->next->next)
+       if (st->cam_pos->next &&
+            st->cam_pos->next->next &&
+            st->cam_pos->next->next->next)
        {
                p1 = st->cam_pos;
                for (i=0; i<4; i++)
@@ -342,6 +342,7 @@ void DrawTunnel(struct tunnel_state *st,
                        /*  End of tunnel */
                        st->ModeX = 1.0;
                        st->ModeXFlag = 0;
+            glEnd();
                        return;
                }
                cvCatmullRom(p4, t, &op);
@@ -374,6 +375,7 @@ void DrawTunnel(struct tunnel_state *st,
                        /*  End of tunnel */
                        st->ModeX = 1.0;
                        st->ModeXFlag = 0;
+            glEnd();
                        return;
                }