Commit of work from Nigel:
authorRichard Rauch <rkr@olib.org>
Tue, 25 Nov 2003 13:53:19 +0000 (13:53 +0000)
committerRichard Rauch <rkr@olib.org>
Tue, 25 Nov 2003 13:53:19 +0000 (13:53 +0000)
Massive rework of the geometric primitive code.  Includes a new
primitive (cylinder; solid and wireframe) and corresponding update
to freeglut_ext.h for the prototype.

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@364 7f0cb862-5218-0410-a997-914c9d46530a

include/GL/freeglut_ext.h
src/freeglut_geometry.c

index 04ec79d..0f5ff00 100644 (file)
@@ -97,6 +97,8 @@ FGAPI void    FGAPIENTRY glutWireRhombicDodecahedron( void );
 FGAPI void    FGAPIENTRY glutSolidRhombicDodecahedron( void );
 FGAPI void    FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ;
 FGAPI void    FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale ) ;
+FGAPI void    FGAPIENTRY glutWireCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks);
+FGAPI void    FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks);
 
 /*
  * Extension functions, see freeglut_ext.c
index 98f2046..36f6a78 100644 (file)
@@ -30,6 +30,8 @@
 #endif
 
 #include "../include/GL/freeglut.h"
+
+
 #include "freeglut_internal.h"
 
 /*
  *
  *      glutWireCube()          -- looks OK
  *      glutSolidCube()         -- OK
- *      glutWireSphere()        -- OK
- *      glutSolidSphere()       -- OK
- *
- * Following functions have been implemented by Pawel and modified by John Fay:
- *
- *      glutWireCone()          -- looks OK
- *      glutSolidCone()         -- looks OK
  *
  * Those functions have been implemented by John Fay.
  *
  *      glutSolidTetrahedron()  -- looks OK
  *      glutWireIcosahedron()   -- looks OK
  *      glutSolidIcosahedron()  -- looks OK
+ *
+ *  The Following functions have been updated by Nigel Stewart, based
+ *  on FreeGLUT 2.0.0 implementations:
+ *
+ *      glutWireSphere()        -- looks OK
+ *      glutSolidSphere()       -- looks OK
+ *      glutWireCone()          -- looks OK
+ *      glutSolidCone()         -- looks OK
  */
 
 
@@ -115,370 +118,471 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize )
 }
 
 /*
- * Draws a wire sphere. Code contributed by Andreas Umbach <marvin@dataway.ch>
+ * Compute lookup table of cos and sin values forming a cirle
+ *
+ * Notes:
+ *    It is the responsibility of the caller to free these tables
+ *    The size of the table is (n+1) to form a connected loop
+ *    The last entry is exactly the same as the first
+ *    The sign of n can be flipped to get the reverse loop
  */
-void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks )
+
+static void circleTable(double **sint,double **cost,const int n)
 {
-    double  radius = dRadius, phi, psi, dpsi, dphi;
-    double *vertex;
-    int    i, j;
-    double cphi, sphi, cpsi, spsi ;
+    int i;
 
-    /*
-     * Allocate the vertices array
-     */
-    vertex = (double *)calloc( sizeof(double), 3 * slices * (stacks - 1) );
+    /* Table size, the sign of n flips the circle direction */
 
-    glPushMatrix();
-    glScaled( radius, radius, radius );
+    const int size = abs(n);
 
-    dpsi = M_PI / (stacks + 1);
-    dphi = 2 * M_PI / slices;
-    psi  = dpsi;
+    /* Determine the angle between samples */
 
-    for( j=0; j<stacks-1; j++ )
-    {
-        cpsi = cos ( psi );
-        spsi = sin ( psi );
-        phi = 0.0;
+    const double angle = 2*M_PI/(double)n;
 
-        for( i=0; i<slices; i++ )
-        {
-          int offset = 3 * ( j * slices + i );
-          cphi = cos ( phi );
-          sphi = sin ( phi );
-            *(vertex + offset + 0) = sphi * spsi ;
-            *(vertex + offset + 1) = cphi * spsi ;
-            *(vertex + offset + 2) = cpsi ;
-            phi += dphi;
-        }
+    /* Allocate memory for n samples, plus duplicate of first entry at the end */
+
+    *sint = (double *) calloc(sizeof(double), size+1);
+    *cost = (double *) calloc(sizeof(double), size+1);
+
+    /* Bail out if memory allocation fails, fgError never returns */
 
-        psi += dpsi;
+    if (!(*sint) || !(*cost))
+    {
+        free(*sint);
+        free(*cost);
+        fgError("Failed to allocate memory in circleTable");
     }
 
-    for( i=0; i<slices; i++ )
+    /* Compute cos and sin around the circle */
+
+    for (i=0; i<size; i++)
     {
-        glBegin( GL_LINE_STRIP );
-        glNormal3d( 0, 0, 1 );
-        glVertex3d( 0, 0, 1 );
+        (*sint)[i] = sin(angle*i);
+        (*cost)[i] = cos(angle*i);
+    }
 
-        for( j=0; j<stacks - 1; j++ )
-        {
-          int offset = 3 * ( j * slices + i );
-            glNormal3dv( vertex + offset );
-            glVertex3dv( vertex + offset );
+    /* Last sample is duplicate of the first */
+
+    (*sint)[size] = (*sint)[0];
+    (*cost)[size] = (*cost)[0];
+}
+
+/*
+ * Draws a solid sphere
+ */
+void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
+{
+    int i,j;
+
+    /* Adjust z and radius as stacks are drawn. */
+
+    double z0,z1;
+    double r0,r1;
+
+    /* Pre-computed circle */
+
+    double *sint1,*cost1;
+    double *sint2,*cost2;
+    circleTable(&sint1,&cost1,-slices);
+    circleTable(&sint2,&cost2,stacks*2);
+
+    /* The top stack is covered with a triangle fan */
+
+    z0 = 1.0;
+    z1 = cost2[1];
+    r0 = 0.0;
+    r1 = sint2[1];
+
+    glBegin(GL_TRIANGLE_FAN);
+
+        glNormal3d(0,0,1);
+        glVertex3d(0,0,radius);
+
+        for (j=slices; j>=0; j--)
+        {       
+            glNormal3d(cost1[j]*r1,        sint1[j]*r1,        z1       );
+            glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
         }
 
-        glNormal3d(0, 0, -1);
-        glVertex3d(0, 0, -1);
+    glEnd();
+
+    /* Cover each stack with a quad strip, except the top and bottom stacks */
+
+    for( i=1; i<stacks-1; i++ )
+    {
+        z0 = z1; z1 = cost2[i+1];
+        r0 = r1; r1 = sint2[i+1];
+
+        glBegin(GL_QUAD_STRIP);
+
+            for(j=0; j<=slices; j++)
+            {
+                glNormal3d(cost1[j]*r1,        sint1[j]*r1,        z1       );
+                glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
+                glNormal3d(cost1[j]*r0,        sint1[j]*r0,        z0       );
+                glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
+            }
+
         glEnd();
     }
 
-    for( j=0; j<stacks-1; j++ )
-    {
-        glBegin(GL_LINE_LOOP);
+    /* The bottom stack is covered with a triangle fan */
+
+    z0 = z1;
+    r0 = r1;
+
+    glBegin(GL_TRIANGLE_FAN);
+
+        glNormal3d(0,0,-1);
+        glVertex3d(0,0,-radius);
 
-        for( i=0; i<slices; i++ )
+        for (j=0; j<=slices; j++)
         {
-          int offset = 3 * ( j * slices + i );
-            glNormal3dv( vertex + offset );
-            glVertex3dv( vertex + offset );
+            glNormal3d(cost1[j]*r0,        sint1[j]*r0,        z0       );
+            glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
         }
 
-        glEnd();
-    }
+    glEnd();
+
+    /* Release sin and cos tables */
 
-    free( vertex );
-    glPopMatrix();
+    free(sint1);
+    free(cost1);
+    free(sint2);
+    free(cost2);
 }
 
 /*
- * Draws a solid sphere. Code contributed by Andreas Umbach <marvin@dataway.ch>
+ * Draws a solid sphere
  */
-void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
+void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
 {
-    double  radius = dRadius, phi, psi, dpsi, dphi;
-    double *next, *tmp, *row;
-    int    i, j;
-    double cphi, sphi, cpsi, spsi ;
+    int i,j;
 
-    glPushMatrix();
-    /* glScalef( radius, radius, radius ); */
+    /* Adjust z and radius as stacks and slices are drawn. */
 
-    row  = (double *)calloc( sizeof(double), slices * 3 );
-    next = (double *)calloc( sizeof(double), slices * 3 );
+    double r;
+    double x,y,z;
 
-    dpsi = M_PI / (stacks + 1);
-    dphi = 2 * M_PI / slices;
-    psi  = dpsi;
-    phi  = 0;
+    /* Pre-computed circle */
+        
+    double *sint1,*cost1;
+    double *sint2,*cost2;
+    circleTable(&sint1,&cost1,-slices  );
+    circleTable(&sint2,&cost2, stacks*2);
 
-    /* init first line + do polar cap */
-    glBegin( GL_TRIANGLE_FAN );
-    glNormal3d( 0.0, 0.0, 1.0 );
-    glVertex3d( 0.0, 0.0, radius );
+    /* Draw a line loop for each stack */
 
-    for( i=0; i<slices; i++ )
+    for (i=1; i<stacks; i++)
     {
-        row[ i * 3 + 0 ] = sin( phi ) * sin( psi );
-        row[ i * 3 + 1 ] = cos( phi ) * sin( psi );
-        row[ i * 3 + 2 ] = cos( psi );
-
-        glNormal3dv( row + 3 * i );
-        glVertex3d(
-            radius * *(row + 3 * i + 0),
-            radius * *(row + 3 * i + 1),
-                  radius * *(row + 3 * i + 2)
-            );
-        
-        phi += dphi;
+        z = cost2[i];
+        r = sint2[i];
+
+        glBegin(GL_LINE_LOOP);
+
+            for(j=0; j<=slices; j++)
+            {
+                x = cost1[j];
+                y = sint1[j];
+
+                glNormal3d(x,y,z);
+                glVertex3d(x*r*radius,y*r*radius,z*radius);
+            }
+
+        glEnd();
     }
 
-    glNormal3dv( row );
-    glVertex3d( radius * *(row + 0), radius * *(row + 1), radius * *(row + 2) );
-    glEnd();
+    /* Draw a line loop for each slice */
 
-    for( j=0; j<stacks-1; j++ )
+    for (i=0; i<slices; i++)
     {
-        phi = 0.0;
-        psi += dpsi;
-        cpsi = cos ( psi );
-        spsi = sin ( psi );
+        glBegin(GL_LINE_STRIP);
 
-        /* get coords */
-        glBegin( GL_QUAD_STRIP );
+            for(j=0; j<=stacks; j++)
+            {
+                x = cost1[i]*sint2[j];
+                y = sint1[i]*sint2[j];
+                z = cost2[j];
 
-        /* glBegin(GL_LINE_LOOP); */
-        for( i=0; i<slices; i++ )
-        {
-          cphi = cos ( phi );
-          sphi = sin ( phi );
-            next[ i * 3 + 0 ] = sphi * spsi ;
-            next[ i * 3 + 1 ] = cphi * spsi ;
-            next[ i * 3 + 2 ] = cpsi ;
-
-            glNormal3dv( row + i * 3 );
-            glVertex3d(
-                radius * *(row + 3 * i + 0),
-                radius * *(row + 3 * i + 1),
-                        radius * *(row + 3 * i + 2)
-                    );
-
-            glNormal3dv( next + i * 3 );
-            glVertex3d(
-                radius * *(next + 3 * i + 0),
-                radius * *(next + 3 * i + 1),
-                radius * *(next + 3 * i + 2)
-            );
-
-            phi += dphi;
-        }
+                glNormal3d(x,y,z);
+                glVertex3d(x*radius,y*radius,z*radius);
+            }
 
-        glNormal3dv( row );
-        glVertex3d( radius * *(row + 0), radius * *(row + 1), radius * *(row + 2) );
-        glNormal3dv( next );
-        glVertex3d( radius * *(next + 0), radius * *(next + 1), radius * *(next + 2) );
         glEnd();
-
-        tmp = row;
-        row = next;
-        next = tmp;
     }
 
-    /* south pole */
-    glBegin( GL_TRIANGLE_FAN );
-    glNormal3d( 0.0, 0.0, -1.0 );
-    glVertex3d( 0.0, 0.0, -radius );
-    glNormal3dv( row );
-    glVertex3d( radius * *(row + 0), radius * *(row + 1), radius * *(row + 2) );
+    /* Release sin and cos tables */
+
+    free(sint1);
+    free(cost1);
+    free(sint2);
+    free(cost2);
+}
+
+/*
+ * Draws a solid cone
+ */
+void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
+{
+    int i,j;
+
+    /* Step in z and radius as stacks are drawn. */
 
-    for( i=slices-1; i>=0; i-- )
+    double z0,z1;
+    double r0,r1;
+
+    const double zStep = height/stacks;
+    const double rStep = base/stacks;
+
+    /* Scaling factors for vertex normals */
+
+    const double cosn = ( height / sqrt ( height * height + base * base ));
+    const double sinn = ( base   / sqrt ( height * height + base * base ));
+
+    /* Pre-computed circle */
+
+    double *sint,*cost;
+    circleTable(&sint,&cost,-slices);
+
+    /* Cover the circular base with a triangle fan... */
+
+    z0 = 0.0;
+    z1 = zStep;
+
+    r0 = base;
+    r1 = r0 - rStep;
+
+    glBegin(GL_TRIANGLE_FAN);
+
+        glNormal3d(0.0,0.0,-1.0);
+        glVertex3d(0.0,0.0, z0 );
+
+        for (j=0; j<=slices; j++)
+            glVertex3d(cost[j]*r0, sint[j]*r0, z0);
+
+    glEnd();
+
+    /* Cover each stack with a quad strip, except the top stack */
+
+    for( i=0; i<stacks-1; i++ )
     {
-        glNormal3dv(row + 3 * i);
-        glVertex3d(
-            radius * *(row + 3 * i + 0),
-            radius * *(row + 3 * i + 1),
-                  radius * *(row + 3 * i + 2)
-           );
+        glBegin(GL_QUAD_STRIP);
+
+            for(j=0; j<=slices; j++)
+            {
+                glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
+                glVertex3d(cost[j]*r0,   sint[j]*r0,   z0  );
+                glVertex3d(cost[j]*r1,   sint[j]*r1,   z1  );
+            }
+
+            z0 = z1; z1 += zStep;
+            r0 = r1; r1 -= rStep;
+
+        glEnd();
     }
 
+    /* The top stack is covered with individual triangles */
+
+    glBegin(GL_TRIANGLES);
+
+        glNormal3d(cost[0]*sinn, sint[0]*sinn, cosn);
+
+        for (j=0; j<slices; j++)
+        {
+            glVertex3d(cost[j+0]*r0,   sint[j+0]*r0,   z0    );
+            glVertex3d(0,              0,              height);
+            glNormal3d(cost[j+1]*sinn, sint[j+1]*sinn, cosn  );
+            glVertex3d(cost[j+1]*r0,   sint[j+1]*r0,   z0    );
+        }
+
     glEnd();
 
-    free(row);
-    free(next);
-    glPopMatrix();
+    /* Release sin and cos tables */
+
+    free(sint);
+    free(cost);
 }
 
 /*
  * Draws a wire cone
  */
-void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
+void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
 {
-  double  alt   = height / (double) (stacks + 1);
-  double  angle = M_PI / (double) slices * 2.0;
-  double  slope = ( height / base );
-  double  sBase = base ;
-  double  sinNormal = ( base   / sqrt ( height * height + base * base ));
-  double  cosNormal = ( height / sqrt ( height * height + base * base ));
-
-  double *vertices = NULL;
-  int    i, j;
+    int i,j;
 
-  /*
-   * We need 'slices' points on a circle
-   */
-  vertices = (double *)calloc( sizeof(double), 2 * (slices + 1) );
+    /* Step in z and radius as stacks are drawn. */
 
-  for( j=0; j<slices+1; j++ )
-  {
-    vertices[ j*2 + 0 ] = cos( angle * j );
-    vertices[ j*2 + 1 ] = sin( angle * j );
-  }
+    double z = 0.0;
+    double r = base;
 
-  /*
-   * First the cone's bottom...
-   */
-  for( j=0; j<slices; j++ )
-  {
-    glBegin( GL_LINE_LOOP );
-      glNormal3d( 0.0, 0.0, -1.0 );
-      glVertex3d( vertices[ (j+0)*2+0 ] * sBase, vertices[ (j+0)*2+1 ] * sBase, 0 );
-      glVertex3d( vertices[ (j+1)*2+0 ] * sBase, vertices[ (j+1)*2+1 ] * sBase, 0 );
-      glVertex3d( 0.0, 0.0, 0.0 );
-    glEnd();
-  }
+    const double zStep = height/stacks;
+    const double rStep = base/stacks;
 
-  /*
-   * Then all the stacks between the bottom and the top
-   */
-  for( i=0; i<stacks; i++ )
-  {
-    double alt_a = i * alt, alt_b = (i + 1) * alt;
-    double scl_a = (height - alt_a) / slope;
-    double scl_b = (height - alt_b) / slope;
+    /* Scaling factors for vertex normals */
+
+    const double cosn = ( height / sqrt ( height * height + base * base ));
+    const double sinn = ( base   / sqrt ( height * height + base * base ));
+
+    /* Pre-computed circle */
+
+    double *sint,*cost;
+    circleTable(&sint,&cost,-slices);
 
-    for( j=0; j<slices; j++ )
+    /* Draw the stacks... */
+
+    for (i=0; i<stacks; i++)
     {
-      glBegin( GL_LINE_LOOP );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_a, vertices[(j+0)*2+1] * scl_a, alt_a );
-        glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-        glVertex3d( vertices[(j+1)*2+0] * scl_a, vertices[(j+1)*2+1] * scl_a, alt_a );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_b, vertices[(j+0)*2+1] * scl_b, alt_b );
-      glEnd();
-
-      glBegin( GL_LINE_LOOP );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_b, vertices[(j+0)*2+1] * scl_b, alt_b );
-        glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-        glVertex3d( vertices[(j+1)*2+0] * scl_b, vertices[(j+1)*2+1] * scl_b, alt_b );
-        glVertex3d( vertices[(j+1)*2+0] * scl_a, vertices[(j+1)*2+1] * scl_a, alt_a );
-      glEnd();
+        glBegin(GL_LINE_LOOP);
+
+            for( j=0; j<slices; j++ )
+            {
+                glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
+                glVertex3d(cost[j]*r,    sint[j]*r,    z   );
+            }
+
+        glEnd();
+
+        z += zStep;
+        r -= rStep;
     }
-  }
 
-  /*
-   * Finally have the top part drawn...
-   */
-  for( j=0; j<slices; j++ )
-  {
-    double scl = alt / slope;
+    /* Draw the slices */
+
+    r = base;
+
+    glBegin(GL_LINES);
+
+        for (j=0; j<slices; j++)
+        {
+            glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn  );
+            glVertex3d(cost[j]*r,    sint[j]*r,    0.0   );
+            glVertex3d(0.0,          0.0,          height);
+        }
 
-    glBegin( GL_LINE_LOOP );
-      glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-      glVertex3d( vertices[ (j+0)*2+0 ] * scl, vertices[ (j+0)*2+1 ] * scl, height - alt );
-      glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-      glVertex3d( vertices[ (j+1)*2+0 ] * scl, vertices[ (j+1)*2+1 ] * scl, height - alt );
-      glVertex3d( 0, 0, height );
     glEnd();
-  }
+
+    /* Release sin and cos tables */
+
+    free(sint);
+    free(cost);
 }
 
+
 /*
- * Draws a solid cone
+ * Draws a solid cylinder
  */
-void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
+void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
 {
-  double  alt   = height / (double) (stacks + 1);
-  double  angle = M_PI / (double) slices * 2.0f;
-  double  slope = ( height / base );
-  double  sBase = base ;
-  double  sinNormal = ( base   / sqrt ( height * height + base * base ));
-  double  cosNormal = ( height / sqrt ( height * height + base * base ));
-
-  double *vertices = NULL;
-  int    i, j;
+    int i,j;
 
-  /*
-   * We need 'slices' points on a circle
-   */
-  vertices = (double *)calloc( sizeof(double), 2 * (slices + 1) );
+    /* Step in z and radius as stacks are drawn. */
 
-  for( j=0; j<slices+1; j++ )
-  {
-    vertices[ j*2 + 0 ] = cos( angle * j );
-    vertices[ j*2 + 1 ] = sin( angle * j );
-  }
+          double z0,z1;
+    const double zStep = height/stacks;
 
-  /*
-   * First the cone's bottom...
-   */
-  for( j=0; j<slices; j++ )
-  {
-    glBegin( GL_TRIANGLES );
-      glNormal3d( 0.0, 0.0, -1.0 );
-      glVertex3d( vertices[ (j+0)*2+0 ] * sBase, vertices[ (j+0)*2+1 ] * sBase, 0 );
-      glVertex3d( vertices[ (j+1)*2+0 ] * sBase, vertices[ (j+1)*2+1 ] * sBase, 0 );
-      glVertex3d( 0.0, 0.0, 0.0 );
+    /* Pre-computed circle */
+
+    double *sint,*cost;
+    circleTable(&sint,&cost,-slices);
+
+    /* Cover the base and top */
+
+    glBegin(GL_TRIANGLE_FAN);
+        glNormal3d(0.0, 0.0, -1.0 );
+        glVertex3d(0.0, 0.0,  0.0 );
+        for (j=0; j<=slices; j++)
+          glVertex3d(cost[j]*radius, sint[j]*radius, 0.0);
     glEnd();
-  }
 
-  /*
-   * Then all the stacks between the bottom and the top
-   */
-  for( i=0; i<stacks; i++ )
-  {
-    double alt_a = i * alt, alt_b = (i + 1) * alt;
-    double scl_a = (height - alt_a) / slope;
-    double scl_b = (height - alt_b) / slope;
+    glBegin(GL_TRIANGLE_FAN);
+        glNormal3d(0.0, 0.0, 1.0   );
+        glVertex3d(0.0, 0.0, height);
+        for (j=slices; j>=0; j--)
+          glVertex3d(cost[j]*radius, sint[j]*radius, height);
+    glEnd();
+
+    /* Do the stacks */
+
+    z0 = 0.0;
+    z1 = zStep;
 
-    for( j=0; j<slices; j++ )
+    for (i=1; i<=stacks; i++)
     {
-      glBegin( GL_TRIANGLES );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_a, vertices[(j+0)*2+1] * scl_a, alt_a );
-        glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-        glVertex3d( vertices[(j+1)*2+0] * scl_a, vertices[(j+1)*2+1] * scl_a, alt_a );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_b, vertices[(j+0)*2+1] * scl_b, alt_b );
-      glEnd();
-
-      glBegin( GL_TRIANGLES );
-        glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-        glVertex3d( vertices[(j+0)*2+0] * scl_b, vertices[(j+0)*2+1] * scl_b, alt_b );
-        glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-        glVertex3d( vertices[(j+1)*2+0] * scl_b, vertices[(j+1)*2+1] * scl_b, alt_b );
-        glVertex3d( vertices[(j+1)*2+0] * scl_a, vertices[(j+1)*2+1] * scl_a, alt_a );
-      glEnd();
+        if (i==stacks)
+            z1 = height;
+
+        glBegin(GL_QUAD_STRIP);
+            for (j=0; j<=slices; j++ )
+            {
+                glNormal3d(cost[j],        sint[j],        0.0 );
+                glVertex3d(cost[j]*radius, sint[j]*radius, z0  );
+                glVertex3d(cost[j]*radius, sint[j]*radius, z1  );
+            }
+        glEnd();
+
+        z0 = z1; z1 += zStep;
     }
-  }
 
-  /*
-   * Finally have the top part drawn...
+    /* Release sin and cos tables */
+
+    free(sint);
+    free(cost);
+}
+
+/*
+ * Draws a wire cylinder
    */
-  for( j=0; j<slices; j++ )
-  {
-    double scl = alt / slope;
-
-    glBegin( GL_TRIANGLES );
-      glNormal3d( sinNormal * vertices[(j+0)*2+0], sinNormal * vertices[(j+0)*2+1], cosNormal );
-      glVertex3d( vertices[ (j+0)*2+0 ] * scl, vertices[ (j+0)*2+1 ] * scl, height - alt );
-      glNormal3d( sinNormal * vertices[(j+1)*2+0], sinNormal * vertices[(j+1)*2+1], cosNormal );
-      glVertex3d( vertices[ (j+1)*2+0 ] * scl, vertices[ (j+1)*2+1 ] * scl, height - alt );
-      glVertex3d( 0, 0, height );
+void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
+{
+    int i,j;
+
+    /* Step in z and radius as stacks are drawn. */
+
+          double z = 0.0;
+    const double zStep = height/stacks;
+
+    /* Pre-computed circle */
+
+    double *sint,*cost;
+    circleTable(&sint,&cost,-slices);
+
+    /* Draw the stacks... */
+
+    for (i=0; i<=stacks; i++)
+    {
+        if (i==stacks)
+            z = height;
+
+        glBegin(GL_LINE_LOOP);
+
+            for( j=0; j<slices; j++ )
+            {
+                glNormal3d(cost[j],        sint[j],        0.0);
+                glVertex3d(cost[j]*radius, sint[j]*radius, z  );
+            }
+
+        glEnd();
+
+        z += zStep;
+    }
+
+    /* Draw the slices */
+
+    glBegin(GL_LINES);
+
+        for (j=0; j<slices; j++)
+        {
+            glNormal3d(cost[j],        sint[j],        0.0   );
+            glVertex3d(cost[j]*radius, sint[j]*radius, 0.0   );
+            glVertex3d(cost[j]*radius, sint[j]*radius, height);
+        }
+
     glEnd();
-  }
+
+    /* Release sin and cos tables */
+
+    free(sint);
+    free(cost);
 }
 
 /*
@@ -499,27 +603,27 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi
 
   glPushMatrix();
 
-  dpsi = 2.0 * M_PI / (double)nRings ;
-  dphi = 2.0 * M_PI / (double)nSides ;
+  dpsi =  2.0 * M_PI / (double)nRings ;
+  dphi = -2.0 * M_PI / (double)nSides ;
   psi  = 0.0;
 
   for( j=0; j<nRings; j++ )
   {
-    cpsi = cos ( psi );
-    spsi = sin ( psi );
+    cpsi = cos ( psi ) ;
+    spsi = sin ( psi ) ;
     phi = 0.0;
 
     for( i=0; i<nSides; i++ )
     {
-      int offset = 3 * ( j * nSides + i );
-      cphi = cos ( phi );
-      sphi = sin ( phi );
-      *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius );
-      *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius );
+      int offset = 3 * ( j * nSides + i ) ;
+      cphi = cos ( phi ) ;
+      sphi = sin ( phi ) ;
+      *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
+      *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
       *(vertex + offset + 2) =                    sphi * iradius  ;
-      *(normal + offset + 0) = cpsi * cphi;
-      *(normal + offset + 1) = spsi * cphi;
-      *(normal + offset + 2) =        sphi;
+      *(normal + offset + 0) = cpsi * cphi ;
+      *(normal + offset + 1) = spsi * cphi ;
+      *(normal + offset + 2) =        sphi ;
       phi += dphi;
     }
 
@@ -532,7 +636,7 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi
 
     for( j=0; j<nRings; j++ )
     {
-      int offset = 3 * ( j * nSides + i );
+      int offset = 3 * ( j * nSides + i ) ;
       glNormal3dv( normal + offset );
       glVertex3dv( vertex + offset );
     }
@@ -546,7 +650,7 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi
 
     for( i=0; i<nSides; i++ )
     {
-      int offset = 3 * ( j * nSides + i );
+      int offset = 3 * ( j * nSides + i ) ;
       glNormal3dv( normal + offset );
       glVertex3dv( vertex + offset );
     }
@@ -554,8 +658,8 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi
     glEnd();
   }
 
-  free ( vertex );
-  free ( normal );
+  free ( vertex ) ;
+  free ( normal ) ;
   glPopMatrix();
 }
 
@@ -572,8 +676,8 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
   /*
    * Increment the number of sides and rings to allow for one more point than surface
    */
-  nSides ++;
-  nRings ++;
+  nSides ++ ;
+  nRings ++ ;
 
   /*
    * Allocate the vertices array
@@ -583,27 +687,27 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
 
   glPushMatrix();
 
-  dpsi = 2.0 * M_PI / (double)(nRings - 1);
-  dphi = 2.0 * M_PI / (double)(nSides - 1);
+  dpsi =  2.0 * M_PI / (double)(nRings - 1) ;
+  dphi = -2.0 * M_PI / (double)(nSides - 1) ;
   psi  = 0.0;
 
   for( j=0; j<nRings; j++ )
   {
-    cpsi = cos ( psi );
-    spsi = sin ( psi );
+    cpsi = cos ( psi ) ;
+    spsi = sin ( psi ) ;
     phi = 0.0;
 
     for( i=0; i<nSides; i++ )
     {
-      int offset = 3 * ( j * nSides + i );
-      cphi = cos ( phi );
-      sphi = sin ( phi );
-      *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius );
-      *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius );
+      int offset = 3 * ( j * nSides + i ) ;
+      cphi = cos ( phi ) ;
+      sphi = sin ( phi ) ;
+      *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
+      *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
       *(vertex + offset + 2) =                    sphi * iradius  ;
-      *(normal + offset + 0) = cpsi * cphi;
-      *(normal + offset + 1) = spsi * cphi;
-      *(normal + offset + 2) =        sphi;
+      *(normal + offset + 0) = cpsi * cphi ;
+      *(normal + offset + 1) = spsi * cphi ;
+      *(normal + offset + 2) =        sphi ;
       phi += dphi;
     }
 
@@ -615,7 +719,7 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
   {
     for( j=0; j<nRings-1; j++ )
     {
-      int offset = 3 * ( j * nSides + i );
+      int offset = 3 * ( j * nSides + i ) ;
       glNormal3dv( normal + offset );
       glVertex3dv( vertex + offset );
       glNormal3dv( normal + offset + 3 );
@@ -629,8 +733,8 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
 
   glEnd();
 
-  free ( vertex );
-  free ( normal );
+  free ( vertex ) ;
+  free ( normal ) ;
   glPopMatrix();
 }
 
@@ -644,44 +748,44 @@ void FGAPIENTRY glutWireDodecahedron( void )
    *   (+-x,0, z); (+-1, 1, 1); (0, z, x )
    * where x = 0.61803398875 and z = 1.61803398875.
    */
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.0,  0.525731112119,  0.850650808354 ); glVertex3d (  0.0,  1.61803398875,  0.61803398875 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ); glVertex3d (  0.61803398875, 0.0,  1.61803398875 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.0,  0.525731112119, -0.850650808354 ); glVertex3d (  0.0,  1.61803398875, -0.61803398875 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d (  0.61803398875, 0.0, -1.61803398875 ); glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.0, -0.525731112119,  0.850650808354 ); glVertex3d (  0.0, -1.61803398875,  0.61803398875 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d (  0.61803398875, 0.0,  1.61803398875 ); glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.0, -0.525731112119, -0.850650808354 ); glVertex3d (  0.0, -1.61803398875, -0.61803398875 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ); glVertex3d (  0.61803398875, 0.0, -1.61803398875 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.850650808354,  0.0,  0.525731112119 ); glVertex3d (  0.61803398875,  0.0,  1.61803398875 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d (  1.61803398875, -0.61803398875, 0.0 ); glVertex3d (  1.61803398875,  0.61803398875, 0.0 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d ( -0.850650808354,  0.0,  0.525731112119 ); glVertex3d ( -0.61803398875,  0.0,  1.61803398875 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ); glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.850650808354,  0.0, -0.525731112119 ); glVertex3d (  0.61803398875,  0.0, -1.61803398875 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d (  1.61803398875,  0.61803398875, 0.0 ); glVertex3d (  1.61803398875, -0.61803398875, 0.0 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d ( -0.850650808354,  0.0, -0.525731112119 ); glVertex3d ( -0.61803398875,  0.0, -1.61803398875 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ); glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.525731112119,  0.850650808354,  0.0 ); glVertex3d (  1.61803398875,  0.61803398875,  0.0 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ); glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d (  0.525731112119, -0.850650808354,  0.0 ); glVertex3d (  1.61803398875, -0.61803398875,  0.0 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ); glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d ( -0.525731112119,  0.850650808354,  0.0 ); glVertex3d ( -1.61803398875,  0.61803398875,  0.0 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ); glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_LINE_LOOP );
-  glNormal3d ( -0.525731112119, -0.850650808354,  0.0 ); glVertex3d ( -1.61803398875, -0.61803398875,  0.0 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ); glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.0,  0.525731112119,  0.850650808354 ) ; glVertex3d (  0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d (  0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.0,  0.525731112119, -0.850650808354 ) ; glVertex3d (  0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d (  0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.0, -0.525731112119,  0.850650808354 ) ; glVertex3d (  0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d (  0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d (  0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d (  0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.850650808354,  0.0,  0.525731112119 ) ; glVertex3d (  0.61803398875,  0.0,  1.61803398875 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d (  1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d (  1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d ( -0.850650808354,  0.0,  0.525731112119 ) ; glVertex3d ( -0.61803398875,  0.0,  1.61803398875 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.850650808354,  0.0, -0.525731112119 ) ; glVertex3d (  0.61803398875,  0.0, -1.61803398875 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d (  1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d (  1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d ( -0.850650808354,  0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875,  0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.525731112119,  0.850650808354,  0.0 ) ; glVertex3d (  1.61803398875,  0.61803398875,  0.0 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d (  0.525731112119, -0.850650808354,  0.0 ) ; glVertex3d (  1.61803398875, -0.61803398875,  0.0 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d ( -0.525731112119,  0.850650808354,  0.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875,  0.0 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_LINE_LOOP ) ;
+  glNormal3d ( -0.525731112119, -0.850650808354,  0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875,  0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
 }
 
 /*
@@ -694,44 +798,44 @@ void FGAPIENTRY glutSolidDodecahedron( void )
    *   (+-x,0, z); (+-1, 1, 1); (0, z, x )
    * where x = 0.61803398875 and z = 1.61803398875.
    */
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.0,  0.525731112119,  0.850650808354 ); glVertex3d (  0.0,  1.61803398875,  0.61803398875 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ); glVertex3d (  0.61803398875, 0.0,  1.61803398875 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.0,  0.525731112119, -0.850650808354 ); glVertex3d (  0.0,  1.61803398875, -0.61803398875 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d (  0.61803398875, 0.0, -1.61803398875 ); glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.0, -0.525731112119,  0.850650808354 ); glVertex3d (  0.0, -1.61803398875,  0.61803398875 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d (  0.61803398875, 0.0,  1.61803398875 ); glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.0, -0.525731112119, -0.850650808354 ); glVertex3d (  0.0, -1.61803398875, -0.61803398875 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ); glVertex3d (  0.61803398875, 0.0, -1.61803398875 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.850650808354,  0.0,  0.525731112119 ); glVertex3d (  0.61803398875,  0.0,  1.61803398875 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d (  1.61803398875, -0.61803398875, 0.0 ); glVertex3d (  1.61803398875,  0.61803398875, 0.0 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d ( -0.850650808354,  0.0,  0.525731112119 ); glVertex3d ( -0.61803398875,  0.0,  1.61803398875 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ); glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.850650808354,  0.0, -0.525731112119 ); glVertex3d (  0.61803398875,  0.0, -1.61803398875 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d (  1.61803398875,  0.61803398875, 0.0 ); glVertex3d (  1.61803398875, -0.61803398875, 0.0 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d ( -0.850650808354,  0.0, -0.525731112119 ); glVertex3d ( -0.61803398875,  0.0, -1.61803398875 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ); glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.525731112119,  0.850650808354,  0.0 ); glVertex3d (  1.61803398875,  0.61803398875,  0.0 ); glVertex3d (  1.0,  1.0, -1.0 ); glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ); glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ); glVertex3d (  1.0,  1.0,  1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d (  0.525731112119, -0.850650808354,  0.0 ); glVertex3d (  1.61803398875, -0.61803398875,  0.0 ); glVertex3d (  1.0, -1.0,  1.0 ); glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ); glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ); glVertex3d (  1.0, -1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d ( -0.525731112119,  0.850650808354,  0.0 ); glVertex3d ( -1.61803398875,  0.61803398875,  0.0 ); glVertex3d ( -1.0,  1.0,  1.0 ); glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ); glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ); glVertex3d ( -1.0,  1.0, -1.0 );
-  glEnd ();
-  glBegin ( GL_POLYGON );
-  glNormal3d ( -0.525731112119, -0.850650808354,  0.0 ); glVertex3d ( -1.61803398875, -0.61803398875,  0.0 ); glVertex3d ( -1.0, -1.0, -1.0 ); glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ); glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ); glVertex3d ( -1.0, -1.0,  1.0 );
-  glEnd ();
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.0,  0.525731112119,  0.850650808354 ) ; glVertex3d (  0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d (  0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.0,  0.525731112119, -0.850650808354 ) ; glVertex3d (  0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d (  0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.0, -0.525731112119,  0.850650808354 ) ; glVertex3d (  0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d (  0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0,  1.61803398875 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d (  0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d (  0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.850650808354,  0.0,  0.525731112119 ) ; glVertex3d (  0.61803398875,  0.0,  1.61803398875 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d (  1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d (  1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d ( -0.850650808354,  0.0,  0.525731112119 ) ; glVertex3d ( -0.61803398875,  0.0,  1.61803398875 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.850650808354,  0.0, -0.525731112119 ) ; glVertex3d (  0.61803398875,  0.0, -1.61803398875 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d (  1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d (  1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d ( -0.850650808354,  0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875,  0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875, 0.0 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.525731112119,  0.850650808354,  0.0 ) ; glVertex3d (  1.61803398875,  0.61803398875,  0.0 ) ; glVertex3d (  1.0,  1.0, -1.0 ) ; glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d (  1.0,  1.0,  1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d (  0.525731112119, -0.850650808354,  0.0 ) ; glVertex3d (  1.61803398875, -0.61803398875,  0.0 ) ; glVertex3d (  1.0, -1.0,  1.0 ) ; glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d (  1.0, -1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d ( -0.525731112119,  0.850650808354,  0.0 ) ; glVertex3d ( -1.61803398875,  0.61803398875,  0.0 ) ; glVertex3d ( -1.0,  1.0,  1.0 ) ; glVertex3d ( 0.0,  1.61803398875,  0.61803398875 ) ; glVertex3d ( 0.0,  1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0,  1.0, -1.0 ) ;
+  glEnd () ;
+  glBegin ( GL_POLYGON ) ;
+  glNormal3d ( -0.525731112119, -0.850650808354,  0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875,  0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875,  0.61803398875 ) ; glVertex3d ( -1.0, -1.0,  1.0 ) ;
+  glEnd () ;
 }
 
 /*
@@ -787,17 +891,17 @@ void FGAPIENTRY glutWireTetrahedron( void )
    * Normals:  The unit normals are simply the negative of the coordinates of the point not on the surface.
    */
 
-  double r0[3] = {             1.0,             0.0,             0.0 };
-  double r1[3] = { -0.333333333333,  0.942809041582,             0.0 };
-  double r2[3] = { -0.333333333333, -0.471404520791,  0.816496580928 };
-  double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 };
-
-  glBegin( GL_LINE_LOOP );
-    glNormal3d (           -1.0,             0.0,             0.0 ); glVertex3dv ( r1 ); glVertex3dv ( r3 ); glVertex3dv ( r2 );
-    glNormal3d ( 0.333333333333, -0.942809041582,             0.0 ); glVertex3dv ( r0 ); glVertex3dv ( r2 ); glVertex3dv ( r3 );
-    glNormal3d ( 0.333333333333,  0.471404520791, -0.816496580928 ); glVertex3dv ( r0 ); glVertex3dv ( r3 ); glVertex3dv ( r1 );
-    glNormal3d ( 0.333333333333,  0.471404520791,  0.816496580928 ); glVertex3dv ( r0 ); glVertex3dv ( r1 ); glVertex3dv ( r2 );
-  glEnd();
+  double r0[3] = {             1.0,             0.0,             0.0 } ;
+  double r1[3] = { -0.333333333333,  0.942809041582,             0.0 } ;
+  double r2[3] = { -0.333333333333, -0.471404520791,  0.816496580928 } ;
+  double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 } ;
+
+  glBegin( GL_LINE_LOOP ) ;
+    glNormal3d (           -1.0,             0.0,             0.0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r2 ) ;
+    glNormal3d ( 0.333333333333, -0.942809041582,             0.0 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r2 ) ; glVertex3dv ( r3 ) ;
+    glNormal3d ( 0.333333333333,  0.471404520791, -0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r1 ) ;
+    glNormal3d ( 0.333333333333,  0.471404520791,  0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r2 ) ;
+  glEnd() ;
 }
 
 /*
@@ -815,17 +919,17 @@ void FGAPIENTRY glutSolidTetrahedron( void )
    * Normals:  The unit normals are simply the negative of the coordinates of the point not on the surface.
    */
 
-  double r0[3] = {             1.0,             0.0,             0.0 };
-  double r1[3] = { -0.333333333333,  0.942809041582,             0.0 };
-  double r2[3] = { -0.333333333333, -0.471404520791,  0.816496580928 };
-  double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 };
-
-  glBegin( GL_TRIANGLES );
-    glNormal3d (           -1.0,             0.0,             0.0 ); glVertex3dv ( r1 ); glVertex3dv ( r3 ); glVertex3dv ( r2 );
-    glNormal3d ( 0.333333333333, -0.942809041582,             0.0 ); glVertex3dv ( r0 ); glVertex3dv ( r2 ); glVertex3dv ( r3 );
-    glNormal3d ( 0.333333333333,  0.471404520791, -0.816496580928 ); glVertex3dv ( r0 ); glVertex3dv ( r3 ); glVertex3dv ( r1 );
-    glNormal3d ( 0.333333333333,  0.471404520791,  0.816496580928 ); glVertex3dv ( r0 ); glVertex3dv ( r1 ); glVertex3dv ( r2 );
-  glEnd();
+  double r0[3] = {             1.0,             0.0,             0.0 } ;
+  double r1[3] = { -0.333333333333,  0.942809041582,             0.0 } ;
+  double r2[3] = { -0.333333333333, -0.471404520791,  0.816496580928 } ;
+  double r3[3] = { -0.333333333333, -0.471404520791, -0.816496580928 } ;
+
+  glBegin( GL_TRIANGLES ) ;
+    glNormal3d (           -1.0,             0.0,             0.0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r2 ) ;
+    glNormal3d ( 0.333333333333, -0.942809041582,             0.0 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r2 ) ; glVertex3dv ( r3 ) ;
+    glNormal3d ( 0.333333333333,  0.471404520791, -0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r3 ) ; glVertex3dv ( r1 ) ;
+    glNormal3d ( 0.333333333333,  0.471404520791,  0.816496580928 ) ; glVertex3dv ( r0 ) ; glVertex3dv ( r1 ) ; glVertex3dv ( r2 ) ;
+  glEnd() ;
 }
 
 /*
@@ -834,27 +938,27 @@ void FGAPIENTRY glutSolidTetrahedron( void )
 double icos_r[12][3] = { { 1.0, 0.0, 0.0 },
   {  0.447213595500,  0.894427191000, 0.0 }, {  0.447213595500,  0.276393202252, 0.850650808354 }, {  0.447213595500, -0.723606797748, 0.525731112119 }, {  0.447213595500, -0.723606797748, -0.525731112119 }, {  0.447213595500,  0.276393202252, -0.850650808354 },
   { -0.447213595500, -0.894427191000, 0.0 }, { -0.447213595500, -0.276393202252, 0.850650808354 }, { -0.447213595500,  0.723606797748, 0.525731112119 }, { -0.447213595500,  0.723606797748, -0.525731112119 }, { -0.447213595500, -0.276393202252, -0.850650808354 },
-  { -1.0, 0.0, 0.0 } };
+  { -1.0, 0.0, 0.0 } } ;
 int icos_v [20][3] = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 5 }, { 0, 5, 1 },
                        { 1, 8, 2 }, { 2, 7, 3 }, { 3, 6, 4 }, { 4, 10, 5 }, { 5, 9, 1 },
                        { 1, 9, 8 }, { 2, 8, 7 }, { 3, 7, 6 }, { 4, 6, 10 }, { 5, 10, 9 },
-                       { 11, 9, 10 }, { 11, 8, 9 }, { 11, 7, 8 }, { 11, 6, 7 }, { 11, 10, 6 } };
+                       { 11, 9, 10 }, { 11, 8, 9 }, { 11, 7, 8 }, { 11, 6, 7 }, { 11, 10, 6 } } ;
 
 void FGAPIENTRY glutWireIcosahedron( void )
 {
   int i ;
   for ( i = 0; i < 20; i++ )
   {
-    double normal[3];
-    normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] );
-    normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] );
-    normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] );
-    glBegin ( GL_LINE_LOOP );
-      glNormal3dv ( normal );
-      glVertex3dv ( icos_r[icos_v[i][0]] );
-      glVertex3dv ( icos_r[icos_v[i][1]] );
-      glVertex3dv ( icos_r[icos_v[i][2]] );
-    glEnd ();
+    double normal[3] ;
+    normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
+    normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
+    normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
+    glBegin ( GL_LINE_LOOP ) ;
+      glNormal3dv ( normal ) ;
+      glVertex3dv ( icos_r[icos_v[i][0]] ) ;
+      glVertex3dv ( icos_r[icos_v[i][1]] ) ;
+      glVertex3dv ( icos_r[icos_v[i][2]] ) ;
+    glEnd () ;
   }
 }
 
@@ -865,20 +969,20 @@ void FGAPIENTRY glutSolidIcosahedron( void )
 {
   int i ;
 
-  glBegin ( GL_TRIANGLES );
+  glBegin ( GL_TRIANGLES ) ;
   for ( i = 0; i < 20; i++ )
   {
-    double normal[3];
-    normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] );
-    normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] );
-    normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] );
-      glNormal3dv ( normal );
-      glVertex3dv ( icos_r[icos_v[i][0]] );
-      glVertex3dv ( icos_r[icos_v[i][1]] );
-      glVertex3dv ( icos_r[icos_v[i][2]] );
+    double normal[3] ;
+    normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
+    normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
+    normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
+      glNormal3dv ( normal ) ;
+      glVertex3dv ( icos_r[icos_v[i][0]] ) ;
+      glVertex3dv ( icos_r[icos_v[i][1]] ) ;
+      glVertex3dv ( icos_r[icos_v[i][2]] ) ;
   }
 
-  glEnd ();
+  glEnd () ;
 }
 
 /*
@@ -888,28 +992,28 @@ double rdod_r[14][3] = { { 0.0, 0.0, 1.0 },
   {  0.707106781187,  0.000000000000,  0.5 }, {  0.000000000000,  0.707106781187,  0.5 }, { -0.707106781187,  0.000000000000,  0.5 }, {  0.000000000000, -0.707106781187,  0.5 },
   {  0.707106781187,  0.707106781187,  0.0 }, { -0.707106781187,  0.707106781187,  0.0 }, { -0.707106781187, -0.707106781187,  0.0 }, {  0.707106781187, -0.707106781187,  0.0 },
   {  0.707106781187,  0.000000000000, -0.5 }, {  0.000000000000,  0.707106781187, -0.5 }, { -0.707106781187,  0.000000000000, -0.5 }, {  0.000000000000, -0.707106781187, -0.5 },
-  {  0.0, 0.0, -1.0 } };
+  {  0.0, 0.0, -1.0 } } ;
 int rdod_v [12][4] = { { 0,  1,  5,  2 }, { 0,  2,  6,  3 }, { 0,  3,  7,  4 }, { 0,  4,  8, 1 },
                        { 5, 10,  6,  2 }, { 6, 11,  7,  3 }, { 7, 12,  8,  4 }, { 8,  9,  5, 1 },
-                       { 5,  9, 13, 10 }, { 6, 10, 13, 11 }, { 7, 11, 13, 12 }, { 8, 12, 13, 9 } };
+                       { 5,  9, 13, 10 }, { 6, 10, 13, 11 }, { 7, 11, 13, 12 }, { 8, 12, 13, 9 } } ;
 double rdod_n[12][3] = {
   {  0.353553390594,  0.353553390594,  0.5 }, { -0.353553390594,  0.353553390594,  0.5 }, { -0.353553390594, -0.353553390594,  0.5 }, {  0.353553390594, -0.353553390594,  0.5 },
   {  0.000000000000,  1.000000000000,  0.0 }, { -1.000000000000,  0.000000000000,  0.0 }, {  0.000000000000, -1.000000000000,  0.0 }, {  1.000000000000,  0.000000000000,  0.0 },
   {  0.353553390594,  0.353553390594, -0.5 }, { -0.353553390594,  0.353553390594, -0.5 }, { -0.353553390594, -0.353553390594, -0.5 }, {  0.353553390594, -0.353553390594, -0.5 }
-  };
+  } ;
 
 void FGAPIENTRY glutWireRhombicDodecahedron( void )
 {
   int i ;
   for ( i = 0; i < 12; i++ )
   {
-    glBegin ( GL_LINE_LOOP );
-      glNormal3dv ( rdod_n[i] );
-      glVertex3dv ( rdod_r[rdod_v[i][0]] );
-      glVertex3dv ( rdod_r[rdod_v[i][1]] );
-      glVertex3dv ( rdod_r[rdod_v[i][2]] );
-      glVertex3dv ( rdod_r[rdod_v[i][3]] );
-    glEnd ();
+    glBegin ( GL_LINE_LOOP ) ;
+      glNormal3dv ( rdod_n[i] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
+    glEnd () ;
   }
 }
 
@@ -920,17 +1024,17 @@ void FGAPIENTRY glutSolidRhombicDodecahedron( void )
 {
   int i ;
 
-  glBegin ( GL_QUADS );
+  glBegin ( GL_QUADS ) ;
   for ( i = 0; i < 12; i++ )
   {
-      glNormal3dv ( rdod_n[i] );
-      glVertex3dv ( rdod_r[rdod_v[i][0]] );
-      glVertex3dv ( rdod_r[rdod_v[i][1]] );
-      glVertex3dv ( rdod_r[rdod_v[i][2]] );
-      glVertex3dv ( rdod_r[rdod_v[i][3]] );
+      glNormal3dv ( rdod_n[i] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
+      glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
   }
 
-  glEnd ();
+  glEnd () ;
 }
 
 #define NUM_FACES     4
@@ -941,12 +1045,12 @@ static GLdouble tetrahedron_v[4][3] =  /* Vertices */
   {  0.5, -0.288675134595, -0.144337567297 },
   {  0.0,  0.577350269189, -0.144337567297 },
   {  0.0,  0.0,             0.672159013631 }
-};
+} ;
 
 static GLint tetrahedron_i[4][3] =  /* Vertex indices */
 {
   { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 1 }, { 1, 3, 2 }
-};
+} ;
 
 static GLdouble tetrahedron_n[4][3] =  /* Normals */
 {
@@ -954,7 +1058,7 @@ static GLdouble tetrahedron_n[4][3] =  /* Normals */
   { -0.816496580928,  0.471404520791,  0.333333333333 },
   {  0.0,            -0.942809041582,  0.333333333333 },
   {  0.816496580928,  0.471404520791,  0.333333333333 }
-};
+} ;
 
 void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
 {
@@ -965,36 +1069,36 @@ void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], G
 
     for ( i = 0 ; i < NUM_FACES ; i++ )
     {
-      glBegin ( GL_LINE_LOOP );
-      glNormal3dv ( tetrahedron_n[i] );
+      glBegin ( GL_LINE_LOOP ) ;
+      glNormal3dv ( tetrahedron_n[i] ) ;
       for ( j = 0; j < 3; j++ )
       {
-        double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0];
-        double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1];
-        double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2];
-        glVertex3d ( x, y, z );
+        double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0] ;
+        double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1] ;
+        double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2] ;
+        glVertex3d ( x, y, z ) ;
       }
 
-      glEnd ();
+      glEnd () ;
     }
   }
   else
   {
-    GLdouble local_offset[3];  /* Use a local variable to avoid buildup of roundoff errors */
-    num_levels --;
+    GLdouble local_offset[3] ;  /* Use a local variable to avoid buildup of roundoff errors */
+    num_levels -- ;
     scale /= 2.0 ;
-    local_offset[0] = offset[0] + scale * tetrahedron_v[0][0];
-    local_offset[1] = offset[1] + scale * tetrahedron_v[0][1];
-    local_offset[2] = offset[2] + scale * tetrahedron_v[0][2];
-    glutWireSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[0] += scale;
-    glutWireSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[0] -= 0.5            * scale;
-    local_offset[1] += 0.866025403784 * scale;
-    glutWireSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[1] -= 0.577350269189 * scale;
-    local_offset[2] += 0.816496580928 * scale;
-    glutWireSierpinskiSponge ( num_levels, local_offset, scale );
+    local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;
+    local_offset[1] = offset[1] + scale * tetrahedron_v[0][1] ;
+    local_offset[2] = offset[2] + scale * tetrahedron_v[0][2] ;
+    glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[0] += scale ;
+    glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[0] -= 0.5            * scale ;
+    local_offset[1] += 0.866025403784 * scale ;
+    glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[1] -= 0.577350269189 * scale ;
+    local_offset[2] += 0.816496580928 * scale ;
+    glutWireSierpinskiSponge ( num_levels, local_offset, scale ) ;
   }
 }
 
@@ -1004,39 +1108,39 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3],
 
   if ( num_levels == 0 )
   {
-    glBegin ( GL_TRIANGLES );
+    glBegin ( GL_TRIANGLES ) ;
 
     for ( i = 0 ; i < NUM_FACES ; i++ )
     {
-      glNormal3dv ( tetrahedron_n[i] );
+      glNormal3dv ( tetrahedron_n[i] ) ;
       for ( j = 0; j < 3; j++ )
       {
-        double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0];
-        double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1];
-        double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2];
-        glVertex3d ( x, y, z );
+        double x = offset[0] + scale * tetrahedron_v[tetrahedron_i[i][j]][0] ;
+        double y = offset[1] + scale * tetrahedron_v[tetrahedron_i[i][j]][1] ;
+        double z = offset[2] + scale * tetrahedron_v[tetrahedron_i[i][j]][2] ;
+        glVertex3d ( x, y, z ) ;
       }
     }
 
-    glEnd ();
+    glEnd () ;
   }
   else
   {
-    GLdouble local_offset[3];  /* Use a local variable to avoid buildup of roundoff errors */
-    num_levels --;
+    GLdouble local_offset[3] ;  /* Use a local variable to avoid buildup of roundoff errors */
+    num_levels -- ;
     scale /= 2.0 ;
-    local_offset[0] = offset[0] + scale * tetrahedron_v[0][0];
-    local_offset[1] = offset[1] + scale * tetrahedron_v[0][1];
-    local_offset[2] = offset[2] + scale * tetrahedron_v[0][2];
-    glutSolidSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[0] += scale;
-    glutSolidSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[0] -= 0.5            * scale;
-    local_offset[1] += 0.866025403784 * scale;
-    glutSolidSierpinskiSponge ( num_levels, local_offset, scale );
-    local_offset[1] -= 0.577350269189 * scale;
-    local_offset[2] += 0.816496580928 * scale;
-    glutSolidSierpinskiSponge ( num_levels, local_offset, scale );
+    local_offset[0] = offset[0] + scale * tetrahedron_v[0][0] ;
+    local_offset[1] = offset[1] + scale * tetrahedron_v[0][1] ;
+    local_offset[2] = offset[2] + scale * tetrahedron_v[0][2] ;
+    glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[0] += scale ;
+    glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[0] -= 0.5            * scale ;
+    local_offset[1] += 0.866025403784 * scale ;
+    glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
+    local_offset[1] -= 0.577350269189 * scale ;
+    local_offset[2] += 0.816496580928 * scale ;
+    glutSolidSierpinskiSponge ( num_levels, local_offset, scale ) ;
   }
 }