Updates to SGI GLU code to get it to compile clean with the Open Watcom compiler.
authorKendall Bennett <KendallB@scitechsoft.com>
Tue, 14 Oct 2003 23:48:57 +0000 (23:48 +0000)
committerKendall Bennett <KendallB@scitechsoft.com>
Tue, 14 Oct 2003 23:48:57 +0000 (23:48 +0000)
Most of the changes were to get rid of warnings, but many of the warnings could
not be removed in the code so I also added #pragma's to disable the warnings.
Someone really should clean up this code, but I didn't want to mess with it
that much (and potentially break it).

18 files changed:
include/GL/glu.h
src/glu/sgi/include/gluos.h
src/glu/sgi/libnurbs/interface/bezierEval.cc
src/glu/sgi/libnurbs/interface/glrenderer.cc
src/glu/sgi/libnurbs/interface/glsurfeval.cc
src/glu/sgi/libnurbs/internals/arc.cc
src/glu/sgi/libnurbs/internals/basiccrveval.cc
src/glu/sgi/libnurbs/internals/basicsurfeval.cc
src/glu/sgi/libnurbs/internals/coveandtiler.cc
src/glu/sgi/libnurbs/internals/knotvector.cc
src/glu/sgi/libnurbs/nurbtess/directedLine.cc
src/glu/sgi/libnurbs/nurbtess/polyDBG.cc
src/glu/sgi/libtess/geom.h
src/glu/sgi/libtess/normal.c
src/glu/sgi/libtess/sweep.c
src/glu/sgi/libtess/tess.c
src/glu/sgi/libutil/mipmap.c
src/glu/sgi/libutil/quad.c

index 5eaa5547482bdf297c0b44b14292fa9f9bd95188..719feb1aed0021bc394bd3c1423b659c1daed4ac 100644 (file)
@@ -266,7 +266,7 @@ typedef GLUtesselator GLUtriangulatorObj;
 #define GLU_TESS_MAX_COORD 1.0e150
 
 /* Internal convenience typedefs */
-typedef void (GLAPIENTRY *_GLUfuncptr)();
+typedef void (GLAPIENTRY_GLUfuncptr)();
 
 GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
 GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
index dd0bd79b0de221ee3aadb67c5fc05caf20baace3..b91b9c5c06fc0ad9c5d6b65627789819df730593 100644 (file)
@@ -1,18 +1,38 @@
 /*
 ** gluos.h - operating system dependencies for GLU
 **
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/include/gluos.h,v 1.5 2003/02/12 16:04:07 brianp Exp $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/include/gluos.h,v 1.6 2003/10/14 23:48:57 kendallb Exp $
 */
 #ifdef __VMS
-#ifdef __cplusplus 
+#ifdef __cplusplus
 #pragma message disable nocordel
 #pragma message disable codeunreachable
 #pragma message disable codcauunr
 #endif
 #endif
 
-#ifdef _WIN32
-#include <stdlib.h>         /* For _MAX_PATH definition */
+#ifdef __WATCOMC__
+/* Disable *lots* of warnings to get a clean build. I can't be bothered fixing the
+ * code at the moment, as it is pretty ugly.
+ */
+#pragma warning 7   10
+#pragma warning 13  10
+#pragma warning 14  10
+#pragma warning 367 10
+#pragma warning 379 10
+#pragma warning 726 10
+#pragma warning 836 10
+#endif
+
+#ifdef BUILD_FOR_SNAP
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <malloc.h>
+
+#elif defined(_WIN32)
+
+#include <stdlib.h>        /* For _MAX_PATH definition */
 #include <stdio.h>
 #include <malloc.h>
 
index a1bbbf52a780db7d539bb93dc6460692dc32f394..c72d64f787f0462578f8f8eb92968b2a76d05b39 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2001/11/29 16:16:55 $ $Revision: 1.2 $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
 */
 /*
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.cc,v 1.2 2001/11/29 16:16:55 kschultz Exp $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/bezierEval.cc,v 1.3 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include <stdlib.h>
 #include <math.h>
 #include "bezierEval.h"
 
+#ifdef __WATCOMC__
+#pragma warning 14  10
+#endif
+
 #define TOLERANCE 0.0001
 
 #ifndef MAX_ORDER
@@ -88,7 +92,7 @@ void bezierCurveEval(float u0, float u1, int order, float *ctlpoints, int stride
   }
 }
 
-      
+
 
 /*order = degree +1 >=1.
  */
@@ -109,7 +113,7 @@ void bezierCurveEvalfast(float u0, float u1, int order, float *ctlpoints, int st
        buf[r][i][j] = (1-uprime)*buf[r-1][i][j] + uprime*buf[r-1][i+1][j];
     }
   }
-  
+
   for(j=0; j<dimension; j++)
     retpoint[j] = buf[order-1][0][j];
 }
@@ -135,10 +139,10 @@ void bezierCurveEvalDer(float u0, float u1, int order, float *ctlpoints, int str
     }
     ctlptr += stride;
   }
-  
+
   bezierCurveEval(u0, u1, order-1, (float*) buf, MAX_DIMENSION,  dimension, u, retDer);
 }
-  
+
 void bezierCurveEvalDerGen(int der, float u0, float u1, int order, float *ctlpoints, int stride,  int dimension, float u, float retDer[])
 {
   int i,k,r;
@@ -179,12 +183,12 @@ void bezierSurfEvalDerGen(int uder, int vder, float u0, float u1, int uorder, fl
     bezierCurveEvalDerGen(vder, v0, v1, vorder, ctlpoints+ustride*i, vstride, dimension, v, newPoints[i]);
 
   }
-  
+
   bezierCurveEvalDerGen(uder, u0, u1, uorder, (float *) newPoints, MAX_DIMENSION, dimension, u, ret);
 }
 
 
-/*division by w is performed*/    
+/*division by w is performed*/
 void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float ret[])
 {
   bezierSurfEvalDerGen(0, 0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, ret);
@@ -192,7 +196,7 @@ void bezierSurfEval(float u0, float u1, int uorder, float v0, float v1, int vord
     ret[0] /= ret[3];
     ret[1] /= ret[3];
     ret[2] /= ret[3];
-  }    
+  }
 }
 
 void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, int vorder, int dimension, float *ctlpoints, int ustride, int vstride, float u, float v, float retNormal[])
@@ -202,7 +206,7 @@ void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, in
   assert(dimension>=3 && dimension <=4);
   bezierSurfEvalDerGen(1,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialU);
   bezierSurfEvalDerGen(0,1, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, partialV);
-  
+
   if(dimension == 3){/*inhomogeneous*/
     crossProduct(partialU, partialV, retNormal);
 
@@ -215,11 +219,11 @@ void bezierSurfEvalNormal(float u0, float u1, int uorder, float v0, float v1, in
     float newPartialU[MAX_DIMENSION];
     float newPartialV[MAX_DIMENSION];
     int i;
-    bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);    
+    bezierSurfEvalDerGen(0,0, u0, u1, uorder, v0, v1, vorder, dimension, ctlpoints, ustride, vstride, u, v, val);
 
     for(i=0; i<=2; i++){
       newPartialU[i] = partialU[i] * val[3] - val[i] * partialU[3];
-      newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];      
+      newPartialV[i] = partialV[i] * val[3] - val[i] * partialV[3];
     }
     crossProduct(newPartialU, newPartialV, retNormal);
     normalize(retNormal);
@@ -231,7 +235,7 @@ static void normalize(float vec[3])
 {
   float size = (float)sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
 
-  if(size < TOLERANCE) 
+  if(size < TOLERANCE)
     {
 #ifdef DEBUG
       fprintf(stderr, "Warning: in oglBSpline.c normal is 0\n");
@@ -244,7 +248,7 @@ static void normalize(float vec[3])
     vec[2] = vec[2]/size;
   }
 }
-  
+
 
 static void crossProduct(float x[3], float y[3], float ret[3])
 {
index 15bea9c212e2e51dee06cf1ec97ff0417c5b63a3..7c9da9f45b1d458956d28283d0e18ece022a5d8f 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
 */
 /*
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.cc,v 1.2 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include "gluos.h"
@@ -99,7 +99,7 @@ GLUnurbs::GLUnurbs()
     //default autoloadmode is true
     autoloadmode = 1;
 
-    //default callbackFlag is 0 
+    //default callbackFlag is 0
     callbackFlag = 0;
 
     errorCallback = NULL;
@@ -127,8 +127,8 @@ GLUnurbs::errorHandler(int i)
     postError( gluError );
 }
 
-void 
-GLUnurbs::loadGLMatrices(void) 
+void
+GLUnurbs::loadGLMatrices(void)
 {
     GLfloat vmat[4][4];
     GLint viewport[4];
@@ -140,20 +140,20 @@ GLUnurbs::loadGLMatrices(void)
 }
 
 void
-GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16], 
+GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
                          const GLfloat projMatrix[16],
                          const GLint viewport[4])
 {
     GLfloat vmat[4][4];
 
-    multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix, 
+    multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
            (const GLfloat (*)[4]) projMatrix);
     loadCullingMatrix((GLfloat (*)[4]) vmat);
     loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
 }
 
 /*--------------------------------------------------------------------------
- * grabGLMatrix  
+ * grabGLMatrix
  *--------------------------------------------------------------------------
  */
 
@@ -164,8 +164,8 @@ GLUnurbs::grabGLMatrix(GLfloat vmat[4][4])
 
     ::glGetFloatv((GLenum) GL_MODELVIEW_MATRIX, (GLfloat *) &(m1[0][0]));
     ::glGetFloatv((GLenum) GL_PROJECTION_MATRIX, (GLfloat *) &(m2[0][0]));
-    multmatrix4d((GLfloat (*)[4]) vmat, 
-           (GLfloat (*)[4]) m1, (GLfloat (*)[4]) m2);
+    multmatrix4d((GLfloat (*)[4]) vmat,
+           (const GLfloat (*)[4]) m1, (const GLfloat (*)[4]) m2);
 }
 
 //for object space tesselation: view independent
@@ -180,27 +180,27 @@ GLUnurbs::setSamplingMatrixIdentity( void )
   };
   const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
   const long cstride = 1;
-  
-  setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+
+  setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
                   cstride);
-  setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+  setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
                   cstride);
-  setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+  setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
                   cstride);
-  setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+  setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
                   cstride);
 }
 
 
 void
-GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4], 
+GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
                               const GLint viewport[4])
 {
 
     /* rescale the mapping to correspond to pixels in x/y */
     REAL xsize = 0.5 * (REAL) (viewport[2]);
     REAL ysize = 0.5 * (REAL) (viewport[3]);
+
     INREAL smat[4][4];
     smat[0][0] = vmat[0][0] * xsize;
     smat[1][0] = vmat[1][0] * xsize;
@@ -225,13 +225,13 @@ GLUnurbs::loadSamplingMatrix(const GLfloat vmat[4][4],
     const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
     const long cstride = 1;
 
-    setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+    setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
            cstride);
-    setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+    setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
            cstride);
-    setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+    setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMATRIX, &smat[0][0], rstride,
            cstride);
-    setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride, 
+    setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMATRIX, &smat[0][0], rstride,
            cstride);
 }
 
@@ -263,14 +263,14 @@ GLUnurbs::loadCullingMatrix(GLfloat vmat[4][4])
     const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
     const long cstride = 1;
 
-    setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride, 
+    setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
            cstride);
-    setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride, 
+    setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
            cstride);
        //added for curves by zl
-    setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride, 
+    setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLINGMATRIX, &cmat[0][0], rstride,
            cstride);
-    setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride, 
+    setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLINGMATRIX, &cmat[0][0], rstride,
            cstride);
 }
 
index 3f6ff87942e2e319a9090099c4b0d37ffc01f4ed..6f63aff44bcbb9a95a9f98aab0b3c4373349dbaf 100644 (file)
@@ -35,8 +35,8 @@
 /*
  * glsurfeval.c++
  *
- * $Date: 2001/07/16 15:46:42 $ $Revision: 1.2 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glsurfeval.cc,v 1.2 2001/07/16 15:46:42 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glsurfeval.cc,v 1.3 2003/10/14 23:48:57 kendallb Exp $
  */
 
 /* Polynomial Evaluator Interface */
 /*#define NO_EVALUATION*/
 
 //#define USE_LOD //for LOD test, have to turn on USE_LOD in insurfeval.c++ too
+
 /*for statistics*/
 //#define STATISTICS
 #ifdef STATISTICS
 static int STAT_num_of_triangles=0;
 static int STAT_num_of_eval_vertices=0;
 static int STAT_num_of_quad_strips=0;
-#endif 
+#endif
 
 /*for output triangles*/
 /*#define OUTPUT_TRIANGLES*/
@@ -74,16 +74,16 @@ static int STAT_num_of_quad_strips=0;
 /*#define FOR_CHRIS*/
 #ifdef FOR_CHRIS
 extern "C"  {  void                evalUStripExt(int n_upper, REAL v_upper, REAL* upper_val,
-                                   int n_lower, REAL v_lower, REAL* lower_val);}
+                                  int n_lower, REAL v_lower, REAL* lower_val);}
 
 extern "C" {   void                evalVStripExt(int n_left, REAL u_left, REAL* left_val,
-                                   int n_right, REAL u_right, REAL* right_val);
+                                  int n_right, REAL u_right, REAL* right_val);
             }
 #endif
 
 
 /**************begin for LOD_eval_list***********/
-void OpenGLSurfaceEvaluator::LOD_eval_list(int level) 
+void OpenGLSurfaceEvaluator::LOD_eval_list(int level)
 {
   if(level == 0)
     LOD_eval_level = 1;
@@ -98,8 +98,8 @@ void OpenGLSurfaceEvaluator::LOD_eval_list(int level)
 }
 
 
-OpenGLSurfaceEvaluator::OpenGLSurfaceEvaluator() 
-{ 
+OpenGLSurfaceEvaluator::OpenGLSurfaceEvaluator()
+{
     int i;
 
     for (i=0; i<VERTEX_CACHE_SIZE; i++) {
@@ -120,7 +120,7 @@ OpenGLSurfaceEvaluator::OpenGLSurfaceEvaluator()
     global_uorder_BV = 0;
     global_vorder_BV = 0;
     global_baseData = NULL;
-       
+        
     global_bpm = NULL;
     output_triangles = 0; //don't output triangles by default
 
@@ -161,8 +161,8 @@ OpenGLSurfaceEvaluator::OpenGLSurfaceEvaluator()
 #endif
 }
 
-OpenGLSurfaceEvaluator::~OpenGLSurfaceEvaluator() 
-{ 
+OpenGLSurfaceEvaluator::~OpenGLSurfaceEvaluator()
+{
    for (int ii= 0; ii< VERTEX_CACHE_SIZE; ii++) {
       delete vertexCache[ii];
       vertexCache[ii]= 0;
@@ -197,11 +197,11 @@ void
 OpenGLSurfaceEvaluator::mapgrid2f(long nu, REAL u0, REAL u1, long nv, REAL v0, REAL v1)
 {
 #ifdef USE_INTERNAL_EVAL
-  inMapGrid2f((int) nu, (REAL) u0, (REAL) u1, (int) nv, 
+  inMapGrid2f((int) nu, (REAL) u0, (REAL) u1, (int) nv,
              (REAL) v0, (REAL) v1);
 #else
 
-  if(output_triangles) 
+  if(output_triangles)  
     {
       global_grid_u0 = u0;
       global_grid_u1 = u1;
@@ -211,7 +211,7 @@ OpenGLSurfaceEvaluator::mapgrid2f(long nu, REAL u0, REAL u1, long nv, REAL v0, R
       global_grid_nv = nv;
     }
   else
-    glMapGrid2d((GLint) nu, (GLdouble) u0, (GLdouble) u1, (GLint) nv, 
+    glMapGrid2d((GLint) nu, (GLdouble) u0, (GLdouble) u1, (GLint) nv,
            (GLdouble) v0, (GLdouble) v1);
 
 #endif
@@ -225,7 +225,7 @@ OpenGLSurfaceEvaluator::polymode(long style)
       switch(style) {
       default:
       case N_MESHFILL:
-       
+        
        glPolygonMode((GLenum) GL_FRONT_AND_BACK, (GLenum) GL_FILL);
        break;
       case N_MESHLINE:
@@ -361,11 +361,11 @@ OpenGLSurfaceEvaluator::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val, i
   /*
    *the algorithm works by scanning from left to right.
    *leftMostV: the left most of the remaining verteces (on both upper and lower).
-   *           it could an element of upperVerts or lowerVerts.
-   *i: upperVerts[i] is the first vertex to the right of leftMostV on upper line   
-   *j: lowerVerts[j] is the first vertex to the right of leftMostV on lower line   
+   *          it could an element of upperVerts or lowerVerts.
+   *i: upperVerts[i] is the first vertex to the right of leftMostV on upper line
+   *j: lowerVerts[j] is the first vertex to the right of leftMostV on lower line
    */
-  
+
   /*initialize i,j,and leftMostV
    */
   if(upper_val[0] <= lower_val[0])
@@ -385,140 +385,140 @@ OpenGLSurfaceEvaluator::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val, i
       leftMostV[1] = v_lower;
 
     }
-  
+
   /*the main loop.
-   *the invariance is that: 
-   *at the beginning of each loop, the meaning of i,j,and leftMostV are 
+   *the invariance is that:
+   *at the beginning of each loop, the meaning of i,j,and leftMostV are
    *maintained
    */
   while(1)
     {
       if(i >= n_upper) /*case1: no more in upper*/
-        {
-          if(j<n_lower-1) /*at least two vertices in lower*/
-            {
-              bgntfan();
+       {
+         if(j<n_lower-1) /*at least two vertices in lower*/
+           {
+             bgntfan();
              coord2f(leftMostV[0], leftMostV[1]);
 //           glNormal3fv(leftMostNormal);
-//              glVertex3fv(leftMostXYZ);
+//             glVertex3fv(leftMostXYZ);
 
-              while(j<n_lower){
+             while(j<n_lower){
                coord2f(lower_val[j], v_lower);
 //             glNormal3fv(lowerNormal[j]);
 //             glVertex3fv(lowerXYZ[j]);
                j++;
 
-              }
-              endtfan();
-            }
-          break; /*exit the main loop*/
-        }
+             }
+             endtfan();
+           }
+         break; /*exit the main loop*/
+       }
       else if(j>= n_lower) /*case2: no more in lower*/
-        {
-          if(i<n_upper-1) /*at least two vertices in upper*/
-            {
-              bgntfan();
+       {
+         if(i<n_upper-1) /*at least two vertices in upper*/
+           {
+             bgntfan();
              coord2f(leftMostV[0], leftMostV[1]);
 //           glNormal3fv(leftMostNormal);
 //           glVertex3fv(leftMostXYZ);
-             
-              for(k=n_upper-1; k>=i; k--) /*reverse order for two-side lighting*/
+        
+             for(k=n_upper-1; k>=i; k--) /*reverse order for two-side lighting*/
                {
                  coord2f(upper_val[k], v_upper);
 //               glNormal3fv(upperNormal[k]);
 //               glVertex3fv(upperXYZ[k]);
                }
 
-              endtfan();
-            }
-          break; /*exit the main loop*/
-        }
+             endtfan();
+           }
+         break; /*exit the main loop*/
+       }
       else /* case3: neither is empty, plus the leftMostV, there is at least one triangle to output*/
-        {
-          if(upper_val[i] <= lower_val[j])
-            {
+       {
+         if(upper_val[i] <= lower_val[j])
+           {
              bgntfan();
              coord2f(lower_val[j], v_lower);
 //           glNormal3fv(lowerNormal[j]);
 //           glVertex3fv(lowerXYZ[j]);
 
-              /*find the last k>=i such that 
-               *upperverts[k][0] <= lowerverts[j][0]
-               */
-              k=i;
+             /*find the last k>=i such that
+              *upperverts[k][0] <= lowerverts[j][0]
+              */
+             k=i;
 
-              while(k<n_upper)
-                {
-                  if(upper_val[k] > lower_val[j])
-                    break;
-                  k++;
+             while(k<n_upper)
+               {
+                 if(upper_val[k] > lower_val[j])
+                   break;
+                 k++;
 
-                }
-              k--;
+               }
+             k--;
 
 
-              for(l=k; l>=i; l--)/*the reverse is for two-side lighting*/
-                {
+             for(l=k; l>=i; l--)/*the reverse is for two-side lighting*/
+               {
                  coord2f(upper_val[l], v_upper);
 //               glNormal3fv(upperNormal[l]);
 //               glVertex3fv(upperXYZ[l]);
 
-                }
+               }
              coord2f(leftMostV[0], leftMostV[1]);
 //           glNormal3fv(leftMostNormal);
 //           glVertex3fv(leftMostXYZ);
 
-              endtfan();
+             endtfan();
 
-              /*update i and leftMostV for next loop
-               */
-              i = k+1;
+             /*update i and leftMostV for next loop
+              */
+             i = k+1;
 
              leftMostV[0] = upper_val[k];
              leftMostV[1] = v_upper;
 //           leftMostNormal = upperNormal[k];
 //           leftMostXYZ = upperXYZ[k];
-            }
-          else /*upperVerts[i][0] > lowerVerts[j][0]*/
-            {
+           }
+         else /*upperVerts[i][0] > lowerVerts[j][0]*/
+           {
              bgntfan();
              coord2f(upper_val[i], v_upper);
 //           glNormal3fv(upperNormal[i]);
 //           glVertex3fv(upperXYZ[i]);
-       
+        
              coord2f(leftMostV[0], leftMostV[1]);
-//              glNormal3fv(leftMostNormal);
+//             glNormal3fv(leftMostNormal);
 //           glVertex3fv(leftMostXYZ);
-             
-
-              /*find the last k>=j such that
-               *lowerverts[k][0] < upperverts[i][0]
-               */
-              k=j;
-              while(k< n_lower)
-                {
-                  if(lower_val[k] >= upper_val[i])
-                    break;
+        
+
+             /*find the last k>=j such that
+              *lowerverts[k][0] < upperverts[i][0]
+              */
+             k=j;
+             while(k< n_lower)
+               {
+                 if(lower_val[k] >= upper_val[i])
+                   break;
                  coord2f(lower_val[k], v_lower);
 //               glNormal3fv(lowerNormal[k]);
 //               glVertex3fv(lowerXYZ[k]);
 
-                  k++;
-                }
-              endtfan();
+                 k++;
+               }
+             endtfan();
 
-              /*update j and leftMostV for next loop
-               */
-              j=k;
+             /*update j and leftMostV for next loop
+              */
+             j=k;
              leftMostV[0] = lower_val[j-1];
              leftMostV[1] = v_lower;
 
 //           leftMostNormal = lowerNormal[j-1];
 //           leftMostXYZ = lowerXYZ[j-1];
-            }     
-        }
+           }
+       }
     }
-  //clean up 
+  //clean up
 //  free(upperXYZ);
 //  free(lowerXYZ);
 //  free(upperNormal);
@@ -526,7 +526,7 @@ OpenGLSurfaceEvaluator::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val, i
 #endif
 
 }
-  
+
 
 void
 OpenGLSurfaceEvaluator::evalVStrip(int n_left, REAL u_left, REAL* left_val, int n_right, REAL u_right, REAL* right_val)
@@ -548,11 +548,11 @@ OpenGLSurfaceEvaluator::evalVStrip(int n_left, REAL u_left, REAL* left_val, int
   /*
    *the algorithm works by scanning from bot to top.
    *botMostV: the bot most of the remaining verteces (on both left and right).
-   *           it could an element of leftVerts or rightVerts.
-   *i: leftVerts[i] is the first vertex to the top of botMostV on left line   
+   *          it could an element of leftVerts or rightVerts.
+   *i: leftVerts[i] is the first vertex to the top of botMostV on left line
    *j: rightVerts[j] is the first vertex to the top of botMostV on rightline
    */
-  
+
   /*initialize i,j,and botMostV
    */
   if(left_val[0] <= right_val[0])
@@ -573,142 +573,142 @@ OpenGLSurfaceEvaluator::evalVStrip(int n_left, REAL u_left, REAL* left_val, int
     }
 
   /*the main loop.
-   *the invariance is that: 
-   *at the beginning of each loop, the meaning of i,j,and botMostV are 
+   *the invariance is that:
+   *at the beginning of each loop, the meaning of i,j,and botMostV are
    *maintained
    */
   while(1)
     {
       if(i >= n_left) /*case1: no more in left*/
-        {
-          if(j<n_right-1) /*at least two vertices in right*/
-            {
-              bgntfan();
+       {
+         if(j<n_right-1) /*at least two vertices in right*/
+           {
+             bgntfan();
              coord2f(botMostV[0], botMostV[1]);
-              while(j<n_right){
+             while(j<n_right){
                coord2f(u_right, right_val[j]);
 //             glNormal3fv(rightNormal[j]);
 //             glVertex3fv(rightXYZ[j]);
                j++;
 
-              }
-              endtfan();
-            }
-          break; /*exit the main loop*/
-        }
+             }
+             endtfan();
+           }
+         break; /*exit the main loop*/
+       }
       else if(j>= n_right) /*case2: no more in right*/
-        {
-          if(i<n_left-1) /*at least two vertices in left*/
-            {
-              bgntfan();
-              coord2f(botMostV[0], botMostV[1]);
+       {
+         if(i<n_left-1) /*at least two vertices in left*/
+           {
+             bgntfan();
+             coord2f(botMostV[0], botMostV[1]);
 //           glNormal3fv(botMostNormal);
 //           glVertex3fv(botMostXYZ);
-             
-              for(k=n_left-1; k>=i; k--) /*reverse order for two-side lighting*/
+        
+             for(k=n_left-1; k>=i; k--) /*reverse order for two-side lighting*/
                {
                  coord2f(u_left, left_val[k]);
 //               glNormal3fv(leftNormal[k]);
 //               glVertex3fv(leftXYZ[k]);
                }
 
-              endtfan();
-            }
-          break; /*exit the main loop*/
-        }
+             endtfan();
+           }
+         break; /*exit the main loop*/
+       }
       else /* case3: neither is empty, plus the botMostV, there is at least one triangle to output*/
-        {
-          if(left_val[i] <= right_val[j])
-            {
+       {
+         if(left_val[i] <= right_val[j])
+           {
              bgntfan();
              coord2f(u_right, right_val[j]);
 //           glNormal3fv(rightNormal[j]);
 //           glVertex3fv(rightXYZ[j]);
 
-              /*find the last k>=i such that 
-               *leftverts[k][0] <= rightverts[j][0]
-               */
-              k=i;
+             /*find the last k>=i such that
+              *leftverts[k][0] <= rightverts[j][0]
+              */
+             k=i;
 
-              while(k<n_left)
-                {
-                  if(left_val[k] > right_val[j])
-                    break;
-                  k++;
+             while(k<n_left)
+               {
+                 if(left_val[k] > right_val[j])
+                   break;
+                 k++;
 
-                }
-              k--;
+               }
+             k--;
 
 
-              for(l=k; l>=i; l--)/*the reverse is for two-side lighting*/
-                {
+             for(l=k; l>=i; l--)/*the reverse is for two-side lighting*/
+               {
                  coord2f(u_left, left_val[l]);
 //               glNormal3fv(leftNormal[l]);
 //               glVertex3fv(leftXYZ[l]);
 
-                }
+               }
              coord2f(botMostV[0], botMostV[1]);
 //           glNormal3fv(botMostNormal);
 //           glVertex3fv(botMostXYZ);
 
-              endtfan();
+             endtfan();
 
-              /*update i and botMostV for next loop
-               */
-              i = k+1;
+             /*update i and botMostV for next loop
+              */
+             i = k+1;
 
              botMostV[0] = u_left;
              botMostV[1] = left_val[k];
 //           botMostNormal = leftNormal[k];
 //           botMostXYZ = leftXYZ[k];
-            }
-          else /*left_val[i] > right_val[j])*/
-            {
+           }
+         else /*left_val[i] > right_val[j])*/
+           {
              bgntfan();
              coord2f(u_left, left_val[i]);
 //           glNormal3fv(leftNormal[i]);
 //           glVertex3fv(leftXYZ[i]);
-             
+        
              coord2f(botMostV[0], botMostV[1]);
-//            glNormal3fv(botMostNormal);
+//           glNormal3fv(botMostNormal);
 //           glVertex3fv(botMostXYZ);
-             
-
-              /*find the last k>=j such that
-               *rightverts[k][0] < leftverts[i][0]
-               */
-              k=j;
-              while(k< n_right)
-                {
-                  if(right_val[k] >= left_val[i])
-                    break;
+        
+
+             /*find the last k>=j such that
+              *rightverts[k][0] < leftverts[i][0]
+              */
+             k=j;
+             while(k< n_right)
+               {
+                 if(right_val[k] >= left_val[i])
+                   break;
                  coord2f(u_right, right_val[k]);
 //               glNormal3fv(rightNormal[k]);
 //               glVertex3fv(rightXYZ[k]);
 
-                  k++;
-                }
-              endtfan();
+                 k++;
+               }
+             endtfan();
 
-              /*update j and botMostV for next loop
-               */
-              j=k;
+             /*update j and botMostV for next loop
+              */
+             j=k;
              botMostV[0] = u_right;
              botMostV[1] = right_val[j-1];
 
 //           botMostNormal = rightNormal[j-1];
 //           botMostXYZ = rightXYZ[j-1];
-            }     
-        }
+           }
+       }
     }
-  //clean up 
+  //clean up
 //  free(leftXYZ);
 //  free(leftNormal);
 //  free(rightXYZ);
 //  free(rightNormal);
 #endif
 }
-  
+
 
 void
 OpenGLSurfaceEvaluator::bgnqstrip(void)
@@ -742,25 +742,25 @@ OpenGLSurfaceEvaluator::bgnmap2f(long)
 {
   if(output_triangles)
     {
-      /*deallocate the space which may has been 
+      /*deallocate the space which may has been
        *allocated by global_bpm previously
        */
       if(global_bpm != NULL) {
        bezierPatchMeshListDelete(global_bpm);
        global_bpm = NULL;
       }
-      
+
 
       /*
        auto_normal_flag = 1; //always output normal in callback mode.
-                             //we could have used the following code,
-                             //but Inspector doesn't have gl context
-                              //before it calls tessellator.
-                             //this way is temporary.
+                             //we could have used the following code,
+                             //but Inspector doesn't have gl context
+                             //before it calls tessellator.
+                             //this way is temporary.
        */
       //NEWCALLBACK
       //if one of the two normal callback functions are set,
-      //then set 
+      //then set
       if(normalCallBackN != NULL ||
         normalCallBackData != NULL)
        auto_normal_flag = 1;
@@ -777,19 +777,19 @@ OpenGLSurfaceEvaluator::bgnmap2f(long)
       if(glIsEnabled(GL_AUTO_NORMAL) == GL_TRUE)
        auto_normal_flag = 1;
       else if (callback_auto_normal == 1)
-        auto_normal_flag = 1;
+       auto_normal_flag = 1;
       else
        auto_normal_flag = 0;
        */
 
       //NEWCALLBACK: no need to worry about gl states when gling clalback
     }
-  else 
+  else
     {
       glPushAttrib((GLbitfield) GL_EVAL_BIT);
-      
+
       /*to avoid side effect, we restor the opengl state for GL_POLYGON_MODE
-       */      
+       */       
       glGetIntegerv(GL_POLYGON_MODE, gl_polygon_mode);
     }
 
@@ -806,17 +806,17 @@ OpenGLSurfaceEvaluator::endmap2f(void)
   if(output_triangles)
     {
       //bezierPatchMeshListDelDeg(global_bpm);
-      
+
       //    bezierPatchMeshListEval(global_bpm);
 
       //surfcount++;
       //printf("surfcount=%i\n", surfcount);
       //if(surfcount == 8) exit(0);
-      
+
       inBPMListEvalEM(global_bpm);
-      
-      
-      
+
+
+
 /*
     global_bpm = bezierPatchMeshListReverse(global_bpm);
     {
@@ -837,7 +837,7 @@ OpenGLSurfaceEvaluator::endmap2f(void)
     //bezierPatchMeshListPrint(global_bpm);
     //bezierPatchMeshListDraw(global_bpm);
 
-//        printf("num triangles=%i\n", bezierPatchMeshListNumTriangles(global_bpm));
+//       printf("num triangles=%i\n", bezierPatchMeshListNumTriangles(global_bpm));
 
 #ifdef USE_LOD
 #else
@@ -873,20 +873,20 @@ glPopAttrib();
 void
 OpenGLSurfaceEvaluator::map2f(
     long _type,
-    REAL _ulower,      /* u lower domain coord         */
+    REAL _ulower,      /* u lower domain coord         */
     REAL _uupper,      /* u upper domain coord         */
     long _ustride,     /* interpoint distance          */
     long _uorder,      /* parametric order             */
-    REAL _vlower,      /* v lower domain coord         */
-    REAL _vupper,      /* v upper domain coord         */
+    REAL _vlower,      /* v lower domain coord         */
+    REAL _vupper,      /* v upper domain coord         */
     long _vstride,     /* interpoint distance          */
     long _vorder,      /* parametric order             */
-    REAL *pts)         /* control points               */
+    REAL *pts) /* control points               */
 {
 #ifdef USE_INTERNAL_EVAL
-   inMap2f((int) _type, (REAL) _ulower, (REAL) _uupper, 
-           (int) _ustride, (int) _uorder, (REAL) _vlower, 
-           (REAL) _vupper, (int) _vstride, (int) _vorder, 
+   inMap2f((int) _type, (REAL) _ulower, (REAL) _uupper,
+           (int) _ustride, (int) _uorder, (REAL) _vlower,
+           (REAL) _vupper, (int) _vstride, (int) _vorder,
            (REAL *) pts);
 #else
 
@@ -897,7 +897,7 @@ OpenGLSurfaceEvaluator::map2f(
        if(global_bpm == NULL)
         global_bpm = bezierPatchMeshMake2(10,10);
        if(
-         (global_bpm->bpatch == NULL && 
+         (global_bpm->bpatch == NULL &&
          (_type == GL_MAP2_VERTEX_3 || _type == GL_MAP2_VERTEX_4))
          ||
          (global_bpm->bpatch_normal == NULL &&
@@ -922,7 +922,7 @@ OpenGLSurfaceEvaluator::map2f(
           global_bpm = bezierPatchMeshListInsert(global_bpm, temp);
 
           /*
-          global_bpm = bezierPatchMeshListInsert(global_bpm, 
+          global_bpm = bezierPatchMeshListInsert(global_bpm,
                                                  bezierPatchMeshMake(
                                                                      (int) _type, _ulower, _uupper,(int)  _ustride, (int) _uorder, _vlower, _vupper, (int) _vstride, (int) _vorder, pts, 10, 10));
           */
@@ -930,12 +930,12 @@ OpenGLSurfaceEvaluator::map2f(
      }
    else /*not output triangles*/
      {
-       glMap2f((GLenum) _type, (GLfloat) _ulower, (GLfloat) _uupper, 
-              (GLint) _ustride, (GLint) _uorder, (GLfloat) _vlower, 
-              (GLfloat) _vupper, (GLint) _vstride, (GLint) _vorder, 
+       glMap2f((GLenum) _type, (GLfloat) _ulower, (GLfloat) _uupper,
+              (GLint) _ustride, (GLint) _uorder, (GLfloat) _vlower,
+              (GLfloat) _vupper, (GLint) _vstride, (GLint) _vorder,
               (const GLfloat *) pts);
      }
-   
+
 #endif
 }
 
@@ -976,18 +976,18 @@ if(output_triangles)
   if(global_grid_nu == 0 || global_grid_nv == 0)
     return; /*no points need to be output*/
   du = (global_grid_u1 - global_grid_u0) / (REAL)global_grid_nu;
-  dv = (global_grid_v1 - global_grid_v0) / (REAL)global_grid_nv;  
-  
+  dv = (global_grid_v1 - global_grid_v0) / (REAL)global_grid_nv;
+
   if(global_grid_nu >= global_grid_nv){
 
     for(i=umin; i<umax; i++){
       REAL u1 = (i==global_grid_nu)? global_grid_u1:(global_grid_u0 + i*du);
       REAL u2 = ((i+1) == global_grid_nu)? global_grid_u1: (global_grid_u0+(i+1)*du);
-      
+
       bgnqstrip();
       for(j=vmax; j>=vmin; j--){
        REAL v1 = (j == global_grid_nv)? global_grid_v1: (global_grid_v0 +j*dv);
-       
+        
        coord2f(u1, v1);
        coord2f(u2, v1);
       }
@@ -999,10 +999,10 @@ if(output_triangles)
     for(i=vmin; i<vmax; i++){
       REAL v1 = (i==global_grid_nv)? global_grid_v1:(global_grid_v0 + i*dv);
       REAL v2 = ((i+1) == global_grid_nv)? global_grid_v1: (global_grid_v0+(i+1)*dv);
-      
+
       bgnqstrip();
       for(j=umax; j>=umin; j--){
-       REAL u1 = (j == global_grid_nu)? global_grid_u1: (global_grid_u0 +j*du);        
+       REAL u1 = (j == global_grid_nu)? global_grid_u1: (global_grid_u0 +j*du);        
        coord2f(u1, v2);
        coord2f(u1, v1);
       }
@@ -1016,15 +1016,15 @@ else
     switch(style) {
     default:
     case N_MESHFILL:
-       glEvalMesh2((GLenum) GL_FILL, (GLint) umin, (GLint) umax, 
+       glEvalMesh2((GLenum) GL_FILL, (GLint) umin, (GLint) umax,
                (GLint) vmin, (GLint) vmax);
        break;
     case N_MESHLINE:
-       glEvalMesh2((GLenum) GL_LINE, (GLint) umin, (GLint) umax, 
+       glEvalMesh2((GLenum) GL_LINE, (GLint) umin, (GLint) umax,
                (GLint) vmin, (GLint) vmax);
        break;
     case N_MESHPOINT:
-       glEvalMesh2((GLenum) GL_POINT, (GLint) umin, (GLint) umax, 
+       glEvalMesh2((GLenum) GL_POINT, (GLint) umin, (GLint) umax,
                (GLint) vmin, (GLint) vmax);
        break;
     }
@@ -1171,7 +1171,7 @@ return;
        if (vcount == 2) {
            vertexCache[0]->invoke(this);
            vertexCache[1]->invoke(this);
-            coord2f(u,v);
+           coord2f(u,v);
 
        } else {
            vcount++;
index 845f05fab92064f7d9c25ec07cb241b821b5ac6f..3b968303bdc966ddcba54c10a1e61fb205e1fe65 100644 (file)
@@ -35,8 +35,8 @@
 /*
  * arc.c++
  *
- * $Date: 2002/11/01 23:35:07 $ $Revision: 1.2 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.cc,v 1.2 2002/11/01 23:35:07 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/arc.cc,v 1.3 2003/10/14 23:48:57 kendallb Exp $
  */
 
 #include <stdio.h>
 #include "simplemath.h"
 
 /* local preprocessor definitions */
-#define        ZERO            0.00001/*0.000001*/
+#define ZERO           0.00001/*0.000001*/
 
-const int      Arc::bezier_tag = (1<<13);
-const int      Arc::arc_tag = (1<<3);
-const int      Arc::tail_tag = (1<<6);
+const int      Arc::bezier_tag = (1<<13);
+const int      Arc::arc_tag = (1<<3);
+const int      Arc::tail_tag = (1<<6);
 
 /*--------------------------------------------------------------------------
  * makeSide - attach a pwl arc to an arc and mark it as a border arc
@@ -72,7 +72,7 @@ Arc::makeSide( PwlArc *pwl, arc_side side )
     clearbezier();
     setside( side );
 }
+
 
 /*--------------------------------------------------------------------------
  * numpts - count number of points on arc loop
@@ -100,7 +100,7 @@ void
 Arc::markverts( void )
 {
     Arc_ptr jarc = this;
-       
+        
     do {
        TrimVertex *p = jarc->pwlArc->pts;
        for( int i=0; i<jarc->pwlArc->npts; i++ )
@@ -125,22 +125,22 @@ Arc::getextrema( Arc_ptr extrema[4] )
     botpt  = toppt   = this->tail()[1];
 
     for( Arc_ptr jarc = this->next; jarc != this; jarc = jarc->next ) {
-       if ( jarc->tail()[0] <  leftpt || 
+       if ( jarc->tail()[0] <  leftpt ||
            (jarc->tail()[0] <= leftpt && jarc->rhead()[0]<=leftpt))  {
            leftpt = jarc->pwlArc->pts->param[0];
            extrema[1] = jarc;
        }
-       if ( jarc->tail()[0] >  rightpt || 
+       if ( jarc->tail()[0] >  rightpt ||
            (jarc->tail()[0] >= rightpt && jarc->rhead()[0] >= rightpt)) {
            rightpt = jarc->pwlArc->pts->param[0];
            extrema[3] = jarc;
        }
-       if ( jarc->tail()[1] <  botpt || 
-            (jarc->tail()[1] <= botpt && jarc->rhead()[1] <= botpt ))  {
+       if ( jarc->tail()[1] <  botpt ||
+           (jarc->tail()[1] <= botpt && jarc->rhead()[1] <= botpt ))  {
            botpt = jarc->pwlArc->pts->param[1];
            extrema[2] = jarc;
        }
-       if ( jarc->tail()[1] >  toppt || 
+       if ( jarc->tail()[1] >  toppt ||
            (jarc->tail()[1] >= toppt && jarc->rhead()[1] >= toppt))  {
            toppt = jarc->pwlArc->pts->param[1];
            extrema[0] = jarc;
@@ -160,7 +160,7 @@ Arc::show()
 #ifndef NDEBUG
     dprintf( "\tPWLARC NP: %d FL: 1\n", pwlArc->npts );
     for( int i = 0; i < pwlArc->npts; i++ ) {
-         dprintf( "\t\tVERTEX %f %f\n", pwlArc->pts[i].param[0],
+        dprintf( "\t\tVERTEX %f %f\n", pwlArc->pts[i].param[0],
                        pwlArc->pts[i].param[1] );
     }
 #endif
@@ -176,13 +176,6 @@ Arc::print( void )
 {
     Arc_ptr jarc = this;
 
-    if( ! this ) {
-#ifndef NDEBUG
-       dprintf( "\n\nEMPTY TRIM\n\n" );
-#endif
-       return;
-    }
-
 #ifndef NDEBUG
     dprintf( "BGNTRIM\n" );
 #endif
@@ -217,10 +210,10 @@ Arc::isDisconnected( void )
 #endif
        return 1;
     } else {
-        /* average two points together */
-        p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5;
-        p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5;
-        return 0;
+       /* average two points together */
+       p0[0] = p1[0] = (p1[0] + p0[0]) * 0.5;
+       p0[1] = p1[1] = (p1[1] + p0[1]) * 0.5;
+       return 0;
     }
 }
 
@@ -251,29 +244,29 @@ Arc::check( void )
     do {
        assert( (jarc->pwlArc != 0) || (jarc->bezierArc != 0) );
 
-        if (jarc->prev == 0 || jarc->next == 0) {
+       if (jarc->prev == 0 || jarc->next == 0) {
 #ifndef NDEBUG
            dprintf( "checkjarc:null next/prev pointer\n");
            jarc->print( );
 #endif
            return 0;
-        }
+       }
 
-        if (jarc->next->prev != jarc) {
+       if (jarc->next->prev != jarc) {
 #ifndef NDEBUG
            dprintf( "checkjarc: pointer linkage screwed up\n");
            jarc->print( );
 #endif
            return 0;
-        }
+       }
 
-        if( jarc->pwlArc ) {
+       if( jarc->pwlArc ) {
 #ifndef NDEBUG
            assert( jarc->pwlArc->npts >= 1 );
            assert( jarc->pwlArc->npts < 100000 );
 /*
            for( int i=0; i < jarc->pwlArc->npts-1; i++ )
-               assert( neq_vert( jarc->pwlArc->pts[i].param, 
+               assert( neq_vert( jarc->pwlArc->pts[i].param,
                             jarc->pwlArc->pts[i+1].param) );
 */
 #endif
@@ -287,7 +280,7 @@ Arc::check( void )
                    return 0;
                }
                if( jarc->tail()[0] != jarc->prev->rhead()[0] ) {
-                   
+               
 #ifndef NDEBUG
                    dprintf( "checkjarc: geometric linkage screwed up 2\n");
                    jarc->prev->show();
@@ -316,13 +309,13 @@ Arc::check( void )
            }
            if( jarc->isbezier() ) {
                assert( jarc->pwlArc->npts == 2 );
-               assert( (jarc->pwlArc->pts[0].param[0] == \
-                       jarc->pwlArc->pts[1].param[0]) ||\
-                       (jarc->pwlArc->pts[0].param[1] == \
-                       jarc->pwlArc->pts[1].param[1]) );
+               assert( (jarc->pwlArc->pts[0].param[0] == \
+                        jarc->pwlArc->pts[1].param[0]) ||\
+                        (jarc->pwlArc->pts[0].param[1] == \
+                        jarc->pwlArc->pts[1].param[1]) );
            }
        }
-        jarc = jarc->next;
+       jarc = jarc->next;
     } while (jarc != this);
     return 1;
 }
@@ -347,9 +340,9 @@ Arc::append( Arc_ptr jarc )
     if( jarc != 0 ) {
        next = jarc->next;
        prev = jarc;
-       next->prev = prev->next = this;
+       next->prev = prev->next = this;
     } else {
-        next = prev = this;
+       next = prev = this;
     }
     return this;
 }
index 0d3d5aa8d38554ddf43f1708b0ea53475854afd3..24b33f0667c0fe3a4aa15aaa8670dcc2baf1fc32 100644 (file)
 /*
  * basiccrveval.c++
  *
- * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basiccrveval.cc,v 1.2 2003/10/14 23:48:57 kendallb Exp $
  */
 
 #include "mystdio.h"
 #include "types.h"
 #include "basiccrveval.h"
 
-void 
+void
 BasicCurveEvaluator::domain1f( REAL, REAL )
 {
 #ifndef NDEBUG
@@ -51,15 +51,15 @@ BasicCurveEvaluator::domain1f( REAL, REAL )
 #endif
 }
 
-void 
-BasicCurveEvaluator::range1f( long type, REAL *, REAL * )
+void
+BasicCurveEvaluator::range1f( long , REAL *, REAL * )
 {
 #ifndef NDEBUG
     dprintf( "range1f\n" );
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::enable( long )
 {
 #ifndef NDEBUG
@@ -67,7 +67,7 @@ BasicCurveEvaluator::enable( long )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::disable( long )
 {
 #ifndef NDEBUG
@@ -75,7 +75,7 @@ BasicCurveEvaluator::disable( long )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::bgnmap1f( long )
 {
 #ifndef NDEBUG
@@ -83,7 +83,7 @@ BasicCurveEvaluator::bgnmap1f( long )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::map1f( long, REAL, REAL, long, long, REAL * )
 {
 #ifndef NDEBUG
@@ -91,7 +91,7 @@ BasicCurveEvaluator::map1f( long, REAL, REAL, long, long, REAL * )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::mapgrid1f( long, REAL, REAL )
 {
 #ifndef NDEBUG
@@ -99,7 +99,7 @@ BasicCurveEvaluator::mapgrid1f( long, REAL, REAL )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::mapmesh1f( long, long, long )
 {
 #ifndef NDEBUG
@@ -107,7 +107,7 @@ BasicCurveEvaluator::mapmesh1f( long, long, long )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::evalcoord1f( long, REAL )
 {
 #ifndef NDEBUG
@@ -115,7 +115,7 @@ BasicCurveEvaluator::evalcoord1f( long, REAL )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::endmap1f( void )
 {
 #ifndef NDEBUG
@@ -123,7 +123,7 @@ BasicCurveEvaluator::endmap1f( void )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::bgnline( void )
 {
 #ifndef NDEBUG
@@ -131,7 +131,7 @@ BasicCurveEvaluator::bgnline( void )
 #endif
 }
 
-void 
+void
 BasicCurveEvaluator::endline( void )
 {
 #ifndef NDEBUG
index 0ade6fa8f7d91192fdade09f658a7394897225a5..f84d3b6074fd3ca7ce2fa193ae06de376aebd806 100644 (file)
 /*
  * basicsurfaceevaluator.c++
  *
- * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/basicsurfeval.cc,v 1.2 2003/10/14 23:48:57 kendallb Exp $
  */
 
 #include "mystdio.h"
 #include "types.h"
 #include "basicsurfeval.h"
 
-void 
+#ifdef __WATCOMC__
+#pragma warning 726 10
+#endif
+
+void
 BasicSurfaceEvaluator::domain2f( REAL, REAL, REAL, REAL )
 {
 #ifndef NDEBUG
@@ -51,7 +55,7 @@ BasicSurfaceEvaluator::domain2f( REAL, REAL, REAL, REAL )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::polymode( long )
 {
 #ifndef NDEBUG
@@ -63,12 +67,12 @@ void
 BasicSurfaceEvaluator::range2f( long type, REAL *from, REAL *to )
 {
 #ifndef NDEBUG
-    dprintf( "range2f type %ld, from (%g,%g), to (%g,%g)\n", 
+    dprintf( "range2f type %ld, from (%g,%g), to (%g,%g)\n",
                type, from[0], from[1], to[0], to[1] );
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::enable( long )
 {
 #ifndef NDEBUG
@@ -76,7 +80,7 @@ BasicSurfaceEvaluator::enable( long )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::disable( long )
 {
 #ifndef NDEBUG
@@ -84,7 +88,7 @@ BasicSurfaceEvaluator::disable( long )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::bgnmap2f( long )
 {
 #ifndef NDEBUG
@@ -92,7 +96,7 @@ BasicSurfaceEvaluator::bgnmap2f( long )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endmap2f( void )
 {
 #ifndef NDEBUG
@@ -100,8 +104,8 @@ BasicSurfaceEvaluator::endmap2f( void )
 #endif
 }
 
-void 
-BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long, 
+void
+BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long,
                                    REAL, REAL, long, long,
                              REAL * )
 {
@@ -110,7 +114,7 @@ BasicSurfaceEvaluator::map2f( long, REAL, REAL, long, long,
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::mapgrid2f( long, REAL, REAL, long, REAL, REAL )
 {
 #ifndef NDEBUG
@@ -118,7 +122,7 @@ BasicSurfaceEvaluator::mapgrid2f( long, REAL, REAL, long, REAL, REAL )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::mapmesh2f( long, long, long, long, long )
 {
 #ifndef NDEBUG
@@ -126,7 +130,7 @@ BasicSurfaceEvaluator::mapmesh2f( long, long, long, long, long )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::evalcoord2f( long, REAL, REAL )
 {
 #ifndef NDEBUG
@@ -134,7 +138,7 @@ BasicSurfaceEvaluator::evalcoord2f( long, REAL, REAL )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::evalpoint2i( long, long )
 {
 #ifndef NDEBUG
@@ -142,7 +146,7 @@ BasicSurfaceEvaluator::evalpoint2i( long, long )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::bgnline( void )
 {
 #ifndef NDEBUG
@@ -150,7 +154,7 @@ BasicSurfaceEvaluator::bgnline( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endline( void )
 {
 #ifndef NDEBUG
@@ -158,7 +162,7 @@ BasicSurfaceEvaluator::endline( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::bgnclosedline( void )
 {
 #ifndef NDEBUG
@@ -166,7 +170,7 @@ BasicSurfaceEvaluator::bgnclosedline( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endclosedline( void )
 {
 #ifndef NDEBUG
@@ -174,7 +178,7 @@ BasicSurfaceEvaluator::endclosedline( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::bgntfan( void )
 {
 #ifndef NDEBUG
@@ -182,13 +186,13 @@ BasicSurfaceEvaluator::bgntfan( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endtfan( void )
 {
 }
 
 
-void 
+void
 BasicSurfaceEvaluator::bgntmesh( void )
 {
 #ifndef NDEBUG
@@ -196,7 +200,7 @@ BasicSurfaceEvaluator::bgntmesh( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::swaptmesh( void )
 {
 #ifndef NDEBUG
@@ -204,7 +208,7 @@ BasicSurfaceEvaluator::swaptmesh( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endtmesh( void )
 {
 #ifndef NDEBUG
@@ -212,7 +216,7 @@ BasicSurfaceEvaluator::endtmesh( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::bgnqstrip( void )
 {
 #ifndef NDEBUG
@@ -220,7 +224,7 @@ BasicSurfaceEvaluator::bgnqstrip( void )
 #endif
 }
 
-void 
+void
 BasicSurfaceEvaluator::endqstrip( void )
 {
 #ifndef NDEBUG
index 61ca3b8f70fced93ade57a1eb9d55930453609fe..9297d3fc21ffde59595082f5b5efe7ba568a3050 100644 (file)
@@ -35,8 +35,8 @@
 /*
  * coveandtiler.c++
  *
- * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.cc,v 1.1 2001/03/17 00:25:40 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/coveandtiler.cc,v 1.2 2003/10/14 23:48:57 kendallb Exp $
  */
 
 #include "glimports.h"
@@ -52,7 +52,7 @@
 const int CoveAndTiler::MAXSTRIPSIZE = 1000;
 
 CoveAndTiler::CoveAndTiler( Backend& b )
-            : backend( b )
+           : backend( b )
 { }
 
 CoveAndTiler::~CoveAndTiler( void )
@@ -76,19 +76,19 @@ CoveAndTiler::output( GridTrimVertex& g )
     backend.tmeshvert( &g );
 }
 
-void 
+void
 CoveAndTiler::coveAndTile( void )
 {
     long ustart = (top.ustart >= bot.ustart) ? top.ustart : bot.ustart;
-    long uend   = (top.uend <= bot.uend)     ? top.uend   : bot.uend;
+    long uend  = (top.uend <= bot.uend)     ? top.uend   : bot.uend;
     if( ustart <= uend ) {
        tile( bot.vindex, ustart, uend );
-       if( top.ustart >= bot.ustart )  
+       if( top.ustart >= bot.ustart )
            coveUpperLeft();
-       else 
+       else
            coveLowerLeft();
-    
-       if( top.uend <= bot.uend )  
+
+       if( top.uend <= bot.uend )
            coveUpperRight();
        else
            coveLowerRight();
@@ -126,7 +126,7 @@ CoveAndTiler::coveAndTile( void )
            } else {
                tllv.set( bot.ustart-1, top.vindex );
            }
-           coveLowerLeftNoGrid( tl );
+           coveLowerLeftNoGrid( tl );
        }
 
        TrimVertex brv, trv, *br, *tr;
@@ -158,7 +158,7 @@ CoveAndTiler::coveAndTile( void )
            br = rl;
            brrv.set( rl );
            if( rf->param[0] < uarray.uarray[bot.uend+1] ) {
-               assert( rf->param[0] >= uarray.uarray[bot.uend] );
+               assert( rf->param[0] >= uarray.uarray[bot.uend] );
                trrv.set( rf );
            } else {
                trrv.set( bot.uend+1, top.vindex );
@@ -179,7 +179,7 @@ CoveAndTiler::coveAndTile( void )
     }
 }
 
-void 
+void
 CoveAndTiler::tile( long vindex, long ustart, long uend )
 {
     long numsteps = uend - ustart;
@@ -195,7 +195,7 @@ CoveAndTiler::tile( long vindex, long ustart, long uend )
     }
 }
 
-void 
+void
 CoveAndTiler::coveUpperRight( void )
 {
     GridVertex tgv( top.uend, top.vindex );
@@ -207,7 +207,7 @@ CoveAndTiler::coveUpperRight( void )
     output( tgv );
     backend.swaptmesh();
     output( gv );
-        coveUR();
+       coveUR();
     backend.endtmesh();
 }
 
@@ -215,15 +215,15 @@ void
 CoveAndTiler::coveUpperRightNoGrid( TrimVertex* br )
 {
     backend.bgntmesh( "coveUpperRight" );
-    output( right.first() ); 
+    output( right.first() );
     output( right.next() );
     backend.swaptmesh();
     output( br );
-        coveUR();
+       coveUR();
     backend.endtmesh();
 }
 
-void 
+void
 CoveAndTiler::coveUR( )
 {
     GridVertex gv( top.uend, bot.vindex );
@@ -238,7 +238,7 @@ CoveAndTiler::coveUR( )
            backend.swaptmesh();
        }
     } else while( 1 ) {
-        if( vert->param[0] < uarray.uarray[gv.gparam[0]]  ) {
+       if( vert->param[0] < uarray.uarray[gv.gparam[0]]  ) {
            output( vert );
            backend.swaptmesh();
            vert = right.next();
@@ -250,7 +250,7 @@ CoveAndTiler::coveUR( )
                for( ; vert; vert = right.next() ) {
                    output( vert );
                    backend.swaptmesh();
-               }
+               }
                break;
            }
        }
@@ -269,7 +269,7 @@ CoveAndTiler::coveUpperLeft( void )
     output( left.next() );
     output( gv );
     backend.swaptmesh();
-        coveUL();
+       coveUL();
     backend.endtmesh();
 }
 
@@ -277,15 +277,15 @@ void
 CoveAndTiler::coveUpperLeftNoGrid( TrimVertex* bl )
 {
     backend.bgntmesh( "coveUpperLeftNoGrid" );
-    output( left.first() ); 
+    output( left.first() );
     output( left.next() );
     output( bl );
     backend.swaptmesh();
-        coveUL();
+       coveUL();
     backend.endtmesh();
 }
 
-void 
+void
 CoveAndTiler::coveUL()
 {
     GridVertex gv( top.ustart, bot.vindex );
@@ -318,7 +318,7 @@ CoveAndTiler::coveUL()
     }
 }
 
-void 
+void
 CoveAndTiler::coveLowerLeft( void )
 {
     GridVertex bgv( bot.ustart, bot.vindex );
@@ -330,7 +330,7 @@ CoveAndTiler::coveLowerLeft( void )
     output( bgv );
     backend.swaptmesh();
     output( gv );
-        coveLL();
+       coveLL();
     backend.endtmesh();
 }
 
@@ -338,15 +338,15 @@ void
 CoveAndTiler::coveLowerLeftNoGrid( TrimVertex* tl )
 {
     backend.bgntmesh( "coveLowerLeft" );
-    output( left.last() ); 
+    output( left.last() );
     output( left.prev() );
     backend.swaptmesh();
     output( tl );
-        coveLL( );
+       coveLL( );
     backend.endtmesh();
 }
 
-void 
+void
 CoveAndTiler::coveLL()
 {
     GridVertex gv( bot.ustart, top.vindex );
@@ -360,7 +360,7 @@ CoveAndTiler::coveLL()
            backend.swaptmesh();
        }
     } else while( 1 ) {
-        if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){
+       if( vert->param[0] > uarray.uarray[gv.gparam[0]] ){
            output( vert );
            backend.swaptmesh();
            vert = left.prev();
@@ -369,29 +369,29 @@ CoveAndTiler::coveLL()
            backend.swaptmesh();
            output( gv );
            if( gv.prevu() == top.ustart ) {
-               for( ; vert; vert = left.prev() ) {
+               for( ; vert; vert = left.prev() ) {
                    output( vert );
                    backend.swaptmesh();
-               }
-               break;
+               }
+               break;
            }
        }
     }
 }
 
-void 
+void
 CoveAndTiler::coveLowerRight( void )
 {
     GridVertex bgv( bot.uend, bot.vindex );
     GridVertex gv( bot.uend, top.vindex );
 
     right.last();
-    backend.bgntmesh( "coveLowerRight" );      
+    backend.bgntmesh( "coveLowerRight" );       
     output( bgv );
     output( right.prev() );
     output( gv );
     backend.swaptmesh();
-        coveLR();
+       coveLR();
     backend.endtmesh( );
 }
 
@@ -399,15 +399,15 @@ void
 CoveAndTiler::coveLowerRightNoGrid( TrimVertex* tr )
 {
     backend.bgntmesh( "coveLowerRIght" );
-    output( right.last() ); 
+    output( right.last() );
     output( right.prev() );
     output( tr );
     backend.swaptmesh();
-        coveLR();
+       coveLR();
     backend.endtmesh();
 }
 
-void 
+void
 CoveAndTiler::coveLR( )
 {
     GridVertex gv( bot.uend, top.vindex );
@@ -421,7 +421,7 @@ CoveAndTiler::coveLR( )
            output( vert );
        }
     } else while( 1 ) {
-        if( vert->param[0] < uarray.uarray[gv.gparam[0]]  ) {
+       if( vert->param[0] < uarray.uarray[gv.gparam[0]]  ) {
            backend.swaptmesh();
            output( vert );
            vert = right.prev();
@@ -430,11 +430,11 @@ CoveAndTiler::coveLR( )
            output( gv );
            backend.swaptmesh();
            if( gv.nextu() == top.uend ) {
-               for( ; vert; vert = right.prev() ) {
+               for( ; vert; vert = right.prev() ) {
                    backend.swaptmesh();
                    output( vert );
-               }
-               break;
+               }
+               break;
            }
        }
     }
index b48efbd4bfad0e104e37f9c8880ee7aaee0f8ec8..3e047456f5c006d983fa2212939a57ac73395828 100644 (file)
@@ -35,8 +35,8 @@
 /*
  * knotvector.c++
  *
- * $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
- * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/knotvector.cc,v 1.1 2001/03/17 00:25:41 brianp Exp $
+ * $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
+ * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/internals/knotvector.cc,v 1.2 2003/10/14 23:48:57 kendallb Exp $
  */
 
 #include "glimports.h"
 #include "knotvector.h"
 #include "defines.h"
 
+#ifdef __WATCOMC__
+#pragma warning 726 10
+#endif
 
 void Knotvector::init( long _knotcount, long _stride, long _order, INREAL *_knotlist )
 {
-    knotcount = _knotcount; 
-    stride = _stride; 
-    order = _order; 
+    knotcount = _knotcount;
+    stride = _stride;
+    order = _order;
     knotlist = new Knot[_knotcount];
     assert( knotlist != 0 );
 
     for( int i = 0; i != _knotcount; i++ )
-        knotlist[i] = (Knot) _knotlist[i]; 
+       knotlist[i] = (Knot) _knotlist[i];
 }
 
 Knotvector::Knotvector( void )
@@ -70,7 +73,7 @@ Knotvector::~Knotvector( void )
 
 int Knotvector::validate( void )
 {
-   /* kindex is used as an array index so subtract one first, 
+   /* kindex is used as an array index so subtract one first,
      * this propagates throughout the code so study carefully */
     long       kindex = knotcount-1;
 
@@ -85,7 +88,7 @@ int Knotvector::validate( void )
     }
 
     if( identical( knotlist[kindex-(order-1)], knotlist[order-1]) ) {
-       // valid knot range is empty 
+       // valid knot range is empty
        return( 3 );
     }
 
@@ -94,33 +97,33 @@ int Knotvector::validate( void )
            // decreasing knot sequence
            return( 4 );
        }
-       
+        
     /* check for valid multiplicity */
 
     /* kindex is currently the index of the last knot.
      * In the next loop  it is decremented to ignore the last knot
-     * and the loop stops when kindex  is 2 so as to ignore the first
-     *  knot as well.  These knots are not used in computing 
-     *  knot multiplicities.
+     * and the loop stops when kindex  is 2 so as to ignore the first
+     * knot as well.  These knots are not used in computing
+     * knot multiplicities.
      */
 
     long multi = 1;
     for( ; kindex >= 1; kindex-- ) {
        if( knotlist[kindex] - knotlist[kindex-1] < TOLERANCE ) {
-           multi++; 
+           multi++;
            continue;
-       } 
+       }
        if ( multi > order ) {
-            // knot multiplicity greater than order of spline
+           // knot multiplicity greater than order of spline
            return( 5 );
-       } 
+       }
        multi = 1;
     }
 
     if ( multi > order ) {
-        // knot multiplicity greater than order of spline
+       // knot multiplicity greater than order of spline
        return( 5 );
-    } 
+    }
 
     return 0;
 }
@@ -128,7 +131,7 @@ int Knotvector::validate( void )
 void Knotvector::show( char *msg )
 {
 #ifndef NDEBUG
-    dprintf( "%s\n", msg ); 
+    dprintf( "%s\n", msg );
     dprintf( "order = %ld, count = %ld\n", order, knotcount );
 
     for( int i=0; i<knotcount; i++ )
index 81e010491545b8124ba7cf095ea32558e18eaba6..187204583052acdf8ea9104ed60efaa96faecac3 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2001/11/29 16:16:55 $ $Revision: 1.2 $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
 */
 /*
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/directedLine.cc,v 1.2 2001/11/29 16:16:55 kschultz Exp $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/directedLine.cc,v 1.3 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include <stdlib.h>
 #include "directedLine.h"
 #include "polyDBG.h"
 
+#ifdef __WATCOMC__
+#pragma warning 726 10
+#endif
+
 //we must return the newLine
 directedLine* directedLine::deleteChain(directedLine* begin, directedLine* end)
 {
@@ -61,10 +65,10 @@ directedLine* directedLine::deleteChain(directedLine* begin, directedLine* end)
       delete end->sline;
       delete begin;
       delete end;
-      
+
       return ret;
     }
+
   directedLine* newLine;
   sampledLine* sline = new sampledLine(begin->head(), end->tail());
   newLine =  new directedLine(INCREASING, sline);
@@ -85,9 +89,9 @@ directedLine* directedLine::deleteChain(directedLine* begin, directedLine* end)
 
 void directedLine::deleteSingleLine(directedLine* dline)
 {
-  //make sure that dline->prev->tail is the same as 
+  //make sure that dline->prev->tail is the same as
   //dline->next->head. This is for numerical erros.
-  //for example, if we delete a line which is almost degeneate 
+  //for example, if we delete a line which is almost degeneate
   //within (epsilon), then we want to make that the polygon after deletion
   //is still a valid polygon
 
@@ -107,18 +111,18 @@ static Int myequal(Real a[2], Real b[2])
   if(a[0]==b[0] && a[1] == b[1])
     return 1;
   else
-    return 0;    
+    return 0;
     */
-  
+
 
   if(fabs(a[0]-b[0]) < 0.00001 &&
      fabs(a[1]-b[1]) < 0.00001)
     return 1;
   else
     return 0;
-    
+
 }
-      
+
 directedLine* directedLine::deleteDegenerateLines()
 {
   //if there is only one edge or two edges, don't do anything
@@ -136,7 +140,7 @@ directedLine* directedLine::deleteDegenerateLines()
   head()[1] != tail()[1])
   */
     first = this;
-  else 
+  else
     {
       for(temp = this->next; temp != this; temp = temp->next)
        {
@@ -149,7 +153,7 @@ directedLine* directedLine::deleteDegenerateLines()
              first = temp;
              break;
            }
-         
+        
        }
     }
 
@@ -164,17 +168,17 @@ directedLine* directedLine::deleteDegenerateLines()
   for(temp =first->next; temp != first; temp = tempNext)
     {
       tempNext = temp->getNext();
-/*      
+/*
       if(temp->head()[0] == temp->tail()[0] &&
         temp->head()[1] == temp->tail()[1])
-*/      
+*/      
 
       if(myequal(temp->head(), temp->tail()))
        deleteSingleLine(temp);
-    }    
+    }   
   return first;
 }
-  
+
 directedLine* directedLine::deleteDegenerateLinesAllPolygons()
 {
   directedLine* temp;
@@ -188,7 +192,7 @@ directedLine* directedLine::deleteDegenerateLinesAllPolygons()
       if(ret == NULL)
        {
          ret = retEnd = temp->deleteDegenerateLines();
-         
+        
        }
       else
        {
@@ -277,7 +281,7 @@ void directedLine::deletePolygonList()
       temp->deleteSinglePolygon();
     }
 }
-      
+
 
 /*a loop by itself*/
 directedLine::directedLine(short dir, sampledLine* sl)
@@ -289,7 +293,7 @@ directedLine::directedLine(short dir, sampledLine* sl)
   nextPolygon = NULL;
 //  prevPolygon = NULL;
   rootBit = 0;/*important to initilzae to 0 meaning not root yet*/
-  
+
   rootLink = NULL;
 
 }
@@ -305,7 +309,7 @@ directedLine::directedLine()
   next = this;
   prev = this;
   nextPolygon = NULL;
-  rootBit = 0;/*important to initilzae to 0 meaning not root yet*/  
+  rootBit = 0;/*important to initilzae to 0 meaning not root yet*/
   rootLink = NULL;
 }
 
@@ -344,7 +348,7 @@ Int directedLine::numEdges()
   Int ret=0;
   directedLine* temp;
   if(next == this) return 1;
-  
+
   ret = 1;
   for(temp = next; temp != this; temp = temp->next)
     ret++;
@@ -373,7 +377,7 @@ short directedLine::isPolygon()
 
   /*check this edge*/
   if(! isConnected()) return 0;
-  
+
   /*check all other edges*/
   for(temp=next; temp != this; temp = temp->next){
     if(!isConnected()) return 0;
@@ -381,14 +385,14 @@ short directedLine::isPolygon()
   return 1;
 }
 
-/*check if the head of this edge is connected to 
+/*check if the head of this edge is connected to
  *the tail of the prev
  */
 short directedLine::isConnected()
 {
   if( (head()[0] == prev->tail()[0]) && (head()[1] == prev->tail()[1]))
     return 1;
-  else 
+  else
     return 0;
 }
 
@@ -410,9 +414,9 @@ Int compV2InX(Real A[2], Real B[2])
 
 /*compare two vertices NOT lines!
  *A vertex is the head of a directed line.
- *(x_1, y_1) <= (x_2, y_2) if 
+ *(x_1, y_1) <= (x_2, y_2) if
  *either y_1 < y_2
- *or     y_1 == y_2 && x_1 < x_2.
+ *or    y_1 == y_2 && x_1 < x_2.
  *return -1 if this->head() <= nl->head(),
  *return  1 otherwise
  */
@@ -425,9 +429,9 @@ Int directedLine::compInY(directedLine* nl)
 
 /*compare two vertices NOT lines!
  *A vertex is the head of a directed line.
- *(x_1, y_1) <= (x_2, y_2) if 
+ *(x_1, y_1) <= (x_2, y_2) if
  *either x_1 < x_2
- *or     x_1 == x_2 && y_1 < y_2.
+ *or    x_1 == x_2 && y_1 < y_2.
  *return -1 if this->head() <= nl->head(),
  *return  1 otherwise
  */
@@ -467,8 +471,8 @@ void directedLine::printSingle()
 {
   if(direction == INCREASING)
     printf("direction is INCREASING\n");
-  else 
-    printf("direction is DECREASING\n");    
+  else
+    printf("direction is DECREASING\n");
   printf("head=%f,%f)\n", head()[0], head()[1]);
   sline->print();
 }
@@ -515,7 +519,7 @@ directedLine* directedLine::cutoffPolygon(directedLine *p)
 
   for(temp=this; temp != p; temp = temp->nextPolygon)
     {
-      if(temp == NULL) 
+      if(temp == NULL)
        {
          fprintf(stderr, "in cutoffPolygon, not found\n");
          exit(1);
@@ -531,7 +535,7 @@ directedLine* directedLine::cutoffPolygon(directedLine *p)
   else {
     prev_polygon->nextPolygon = p->nextPolygon;
     return this;
-  } 
+  }
 }
 
 Int directedLine::numPolygons()
@@ -539,9 +543,9 @@ Int directedLine::numPolygons()
   if(nextPolygon == NULL) return 1;
   else return 1+nextPolygon->numPolygons();
 }
-  
 
-/*let  array[index ...] denote 
+
+/*let  array[index ...] denote
  *all the edges in this polygon
  *return the next available index of array.
  */
@@ -555,8 +559,8 @@ Int directedLine::toArraySinglePolygon(directedLine** array, Int index)
     }
   return index;
 }
-/*the space is allocated. The caller is responsible for 
+
+/*the space is allocated. The caller is responsible for
  *deallocate the space.
  *total_num_edges is set to be the total number of edges of all polygons
  */
@@ -602,14 +606,14 @@ Real directedLine::polyArea()
 /*******************split or combine polygons begin********************/
 /*conect a diagonal of a single simple polygon or  two simple polygons.
  *If the two vertices v1 (head) and v2 (head) are in the same simple polygon,
- *then we actually split the simple polygon into two polygons. 
+ *then we actually split the simple polygon into two polygons.
  *If instead two vertices velong to two difference polygons,
  *then we combine the  two polygons into one polygon.
- *It is upto the caller to decide whether this is a split or a 
+ *It is upto the caller to decide whether this is a split or a
  *combination.
  *
  *Case Split:
- *split a single simple polygon into two simple polygons by 
+ *split a single simple polygon into two simple polygons by
  *connecting a diagonal (two vertices).
  *v1, v2: the two vertices are the head() of the two directedLines.
  *  this routine generates one new sampledLine which is returned in
@@ -625,11 +629,11 @@ Real directedLine::polyArea()
  *the returned polygon is returned in ret_p1.
  */
 /*ARGSUSED*/
-void directedLine::connectDiagonal(directedLine* v1, directedLine* v2, 
-                          directedLine** ret_p1, 
+void directedLine::connectDiagonal(directedLine* v1, directedLine* v2,
+                          directedLine** ret_p1,
                           directedLine** ret_p2,
                           sampledLine** generatedLine,
-                          directedLine* polygonList                                                               )
+                          directedLine* polygonList                                                               )
 {
   sampledLine *nsline  = new sampledLine(2);
 
@@ -637,7 +641,7 @@ void directedLine::connectDiagonal(directedLine* v1, directedLine* v2,
 
   nsline->setPoint(0, v1->head());
   nsline->setPoint(1, v2->head());
-  
+
 
 
   /*the increasing line is from v1 head to v2 head*/
@@ -651,12 +655,12 @@ void directedLine::connectDiagonal(directedLine* v1, directedLine* v2,
   directedLine* v1Prev = v1->prev;
   directedLine* v2Prev = v2->prev;
 
-  v1        ->prev = newLineDec; 
+  v1       ->prev = newLineDec;
   v2Prev    ->next = newLineDec;
   newLineDec->next = v1;
   newLineDec->prev = v2Prev;
 
-  v2        ->prev = newLineInc;
+  v2       ->prev = newLineInc;
   v1Prev    ->next = newLineInc;
   newLineInc->next = v2;
   newLineInc->prev = v1Prev;
@@ -668,19 +672,19 @@ void directedLine::connectDiagonal(directedLine* v1, directedLine* v2,
 
 //see the function connectDiangle
 /*ARGSUSED*/
-void directedLine::connectDiagonal_2slines(directedLine* v1, directedLine* v2, 
-                          directedLine** ret_p1, 
+void directedLine::connectDiagonal_2slines(directedLine* v1, directedLine* v2,
+                          directedLine** ret_p1,
                           directedLine** ret_p2,
-                          directedLine* polygonList                                                               )
+                          directedLine* polygonList                                                               )
 {
   sampledLine *nsline  = new sampledLine(2);
-  sampledLine *nsline2  = new sampledLine(2);
+  sampledLine *nsline2 = new sampledLine(2);
 
   nsline->setPoint(0, v1->head());
   nsline->setPoint(1, v2->head());
   nsline2->setPoint(0, v1->head());
   nsline2->setPoint(1, v2->head());
-  
+
   /*the increasing line is from v1 head to v2 head*/
   directedLine* newLineInc = new directedLine(INCREASING, nsline);
 
@@ -689,12 +693,12 @@ void directedLine::connectDiagonal_2slines(directedLine* v1, directedLine* v2,
   directedLine* v1Prev = v1->prev;
   directedLine* v2Prev = v2->prev;
 
-  v1        ->prev = newLineDec; 
+  v1       ->prev = newLineDec;
   v2Prev    ->next = newLineDec;
   newLineDec->next = v1;
   newLineDec->prev = v2Prev;
 
-  v2        ->prev = newLineInc;
+  v2       ->prev = newLineInc;
   v1Prev    ->next = newLineInc;
   newLineInc->next = v2;
   newLineInc->prev = v1Prev;
@@ -793,7 +797,7 @@ directedLine* readAllPolygons(char* filename)
   Int nPolygons;
   fscanf(fp, "%i", &nPolygons);
   directedLine *ret = NULL;
-  
+
   for(i=0; i<nPolygons; i++)
     {
       Int nEdges;
@@ -810,7 +814,7 @@ directedLine* readAllPolygons(char* filename)
       sampledLine *sLine = new sampledLine(2, vert);
       directedLine *thisPoly = new directedLine(INCREASING, sLine);
 thisPoly->rootLinkSet(NULL);
-      
+
       directedLine *dLine;
       for(j=2; j<nEdges; j++)
        {
@@ -830,7 +834,7 @@ dLine->rootLinkSet(thisPoly);
       dLine = new directedLine(INCREASING, sLine);
 dLine->rootLinkSet(thisPoly);
       thisPoly->insert(dLine);
-      
+
       ret = thisPoly->insertPolygon(ret);
     }
   fclose(fp);
index e4a65c2eb3c61a9cd22c98c28aed4e44a8f4e943..76f1076623c137d175ba40704c1e05c61ff15c5d 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2001/11/29 16:16:55 $ $Revision: 1.2 $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
 */
 /*
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/polyDBG.cc,v 1.2 2001/11/29 16:16:55 kschultz Exp $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/polyDBG.cc,v 1.3 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include <stdlib.h>
 #include "zlassert.h"
 #include "polyDBG.h"
 
+#ifdef __WATCOMC__
+#pragma warning 14  10
+#pragma warning 391 10
+#pragma warning 726 10
+#endif
 
 static Real area(Real A[2], Real B[2], Real C[2])
 {
@@ -71,7 +76,7 @@ Int DBG_is_U_monotone(directedLine* poly)
 {
   Int n_changes = 0;
   Int prev_sign;
-  Int cur_sign;  
+  Int cur_sign;
    directedLine* temp;
   cur_sign = compV2InX(poly->tail(), poly->head());
 
@@ -119,7 +124,7 @@ Int DBG_is_U_direction(directedLine* poly)
       if(temp->head()[0] == temp->tail()[0])
        V_count += temp->get_npoints();
       else if(temp->head()[1] == temp->tail()[1])
-       U_count += temp->get_npoints();      
+       U_count += temp->get_npoints();
        */
     }
 
@@ -142,7 +147,7 @@ Int DBG_edgesIntersect(directedLine* l1, directedLine* l2)
             (l1->tail()[1] - l1->head()[1])*(l2->tail()[1]-l2->head()[1]) >=0)
            return 0; //not intersect
          else
-           return 1;       
+           return 1;
        }
       //else we use the normal code
     }
@@ -154,8 +159,8 @@ Int DBG_edgesIntersect(directedLine* l1, directedLine* l2)
             (l2->tail()[1] - l2->head()[1])*(l1->tail()[1]-l1->head()[1]) >=0)
            return 0; //not intersect
          else
-           return 1;       
-       }      
+           return 1;
+       }
       //else we use the normal code
     }
   else //the two edges are not connected
@@ -165,11 +170,11 @@ Int DBG_edgesIntersect(directedLine* l1, directedLine* l2)
         (l1->tail()[0] == l2->tail()[0] &&
         l1->tail()[1] == l2->tail()[1]))
        return 1;
-       
+
     }
-  
 
-  if( 
+
+  if(
      (
       area(l1->head(), l1->tail(), l2->head())
       *
@@ -184,7 +189,7 @@ Int DBG_edgesIntersect(directedLine* l1, directedLine* l2)
       )
      )
     return 1;
-  else 
+  else
     return 0;
 }
 
@@ -207,7 +212,7 @@ Int DBG_edgesIntersectGen(Real A[2], Real B[2], Real C[2], Real D[2])
   else
     return 0;
 }
-       
+
 /*determien whether    (A,B) interesect chain[start] to [end]
  */
 Int DBG_intersectChain(vertexArray* chain, Int start, Int end, Real A[2], Real B[2])
@@ -216,13 +221,13 @@ Int DBG_intersectChain(vertexArray* chain, Int start, Int end, Real A[2], Real B
   for(i=start; i<=end-2; i++)
     if(DBG_edgesIntersectGen(chain->getVertex(i), chain->getVertex(i+1), A, B))
       return 1;
-  
+
   return 0;
 }
 
 /*determine whether a polygon intersect itself or not
  *return 1 is it does,
- *       0 otherwise
+ *      0 otherwise
  */
 Int DBG_polygonSelfIntersect(directedLine* poly)
 {
@@ -235,7 +240,7 @@ Int DBG_polygonSelfIntersect(directedLine* poly)
        {
          return 1;
        }
-         
+
     }
 
   for(temp1=poly->getNext(); temp1 != poly; temp1 = temp1->getNext())
@@ -261,7 +266,7 @@ Int DBG_edgeIntersectPoly(directedLine* edge, directedLine* poly)
       return 1;
   return 0;
 }
-  
+
 /*check whether two polygons intersect
  */
 Int DBG_polygonsIntersect(directedLine* p1, directedLine* p2)
@@ -291,7 +296,7 @@ Int DBG_polygonListIntersect(directedLine* pList)
        if(DBG_polygonsIntersect(temp, temp2))
          return 1;
     }
-  
+
   return 0;
 }
 
@@ -303,16 +308,16 @@ Int DBG_isCounterclockwise(directedLine* poly)
 
 /*ray: v0 with direction (dx,dy).
  *edge: v1-v2.
- * the extra point v10[2] is given for the information at 
+ * the extra point v10[2] is given for the information at
  *v1. Basically this edge is connectd to edge
- * v10-v1. If v1 is on the ray, 
+ * v10-v1. If v1 is on the ray,
  * then we need v10  to determine whether this ray intersects
- * the edge or not (that is, return 1 or return 0). 
+ * the edge or not (that is, return 1 or return 0).
  * If v1 is on the ray, then if v2 and v10 are on the same side of the ray,
  * we return 0, otherwise return 1.
  *For v2, if v2 is on the ray, we always return 0.
  *Notice that v1 and v2 are not symmetric. So the edge is directed!!!
- * The purpose for this convention is such that: a point is inside a polygon 
+ * The purpose for this convention is such that: a point is inside a polygon
  * if and only if it intersets with odd number of edges.
  */
 Int DBG_rayIntersectEdge(Real v0[2], Real dx, Real dy, Real v10[2], Real v1[2], Real v2[2])
@@ -330,17 +335,17 @@ if( (v1[1] >= v0[1] && v2[1]<= v0[1] )
 
 
   /*if the ray is parallel to the edge, return 0: not intersect*/
-  if(denom == 0.0) 
+  if(denom == 0.0)
     return 0;
 
   /*if v0 is on the edge, return 0: not intersect*/
-  if(nomRay == 0.0) 
+  if(nomRay == 0.0)
     return 0;
-  
+
   /*if v1 is on the positive ray, and the neighbor of v1 crosses the ray
    *return 1: intersect
    */
-  if(nomEdge == 0) 
+  if(nomEdge == 0)
     { /*v1 is on the positive or negative ray*/
 
 /*
@@ -351,7 +356,7 @@ if( (v1[1] >= v0[1] && v2[1]<= v0[1] )
        {
          if(area(v0, v1, v10) * area(v0, v1, v2) >0)
            return 0;
-         else 
+         else
            return 1;
        }
       else /*v1 on negative ray*/
@@ -378,10 +383,10 @@ Int DBG_rayIntersectPoly(Real v0[2], Real dx, Real dy, directedLine* poly)
   Int count=0;
   if(DBG_rayIntersectEdge(v0, dx, dy, poly->getPrev()->head(), poly->head(), poly->tail()))
     count++;
-  
+
   for(temp=poly->getNext(); temp != poly; temp = temp->getNext())
     if(DBG_rayIntersectEdge(v0, dx, dy, temp->getPrev()->head(), temp->head(), temp->tail()))
-      count++;    
+      count++;
 /*printf("ray intersect poly: count=%i\n", count);*/
   return count;
 }
@@ -398,8 +403,8 @@ poly->printList();
         == (DBG_rayIntersectPoly(v,1,Real(0.1234), poly) % 2 )
         );
   if(DBG_rayIntersectPoly(v, 1, 0, poly) % 2 == 1)
-    return 1; 
-  else 
+    return 1;
+  else
     return 0;
 }
 
@@ -410,8 +415,8 @@ Int DBG_enclosingPolygons(directedLine* poly, directedLine* list)
 {
   directedLine* temp;
   Int count=0;
-/*  
-printf("%i\n", DBG_pointInsidePoly(poly->head(), 
+/*
+printf("%i\n", DBG_pointInsidePoly(poly->head(),
                                   list->getNextPolygon()
                                   ->getNextPolygon()
                                   ->getNextPolygon()
@@ -423,15 +428,15 @@ printf("%i\n", DBG_pointInsidePoly(poly->head(),
     {
       if(poly != temp)
        if(DBG_pointInsidePoly(poly->head(), temp))
-         count++;    
-/*      printf("count=%i\n", count);*/
+         count++;
+/*     printf("count=%i\n", count);*/
     }
   return count;
 }
 
 void  DBG_reverse(directedLine* poly)
 {
-  if(poly->getDirection() == INCREASING) 
+  if(poly->getDirection() == INCREASING)
     poly->putDirection(DECREASING);
   else
     poly->putDirection(INCREASING);
@@ -443,7 +448,7 @@ void  DBG_reverse(directedLine* poly)
   directedLine* temp;
   for(temp=oldNext; temp!=poly; temp = oldNext)
     {
-      if(temp->getDirection() == INCREASING) 
+      if(temp->getDirection() == INCREASING)
        temp->putDirection(DECREASING);
       else
        temp->putDirection(INCREASING);
@@ -512,7 +517,7 @@ Int DBG_check(directedLine *polyList)
        correctDir = 0; /*clockwise*/
 
       Int actualDir = DBG_isCounterclockwise(temp);
-      
+
       if(correctDir != actualDir)
        {
          fprintf(stderr, "DBG_check: polygon with incorrect orientations. reversed\n");
@@ -526,7 +531,7 @@ Int DBG_check(directedLine *polyList)
 
 /**************handle self intersections*****************/
 //determine whether e interects [begin, end] or not
-static directedLine* DBG_edgeIntersectChainD(directedLine *e, 
+static directedLine* DBG_edgeIntersectChainD(directedLine *e,
                               directedLine *begin, directedLine *end)
 {
   directedLine *temp;
@@ -537,10 +542,10 @@ static directedLine* DBG_edgeIntersectChainD(directedLine *e,
     }
   if(DBG_edgesIntersect(e, end))
     return end;
-  return NULL;      
+  return NULL;
 }
 
-//given a polygon, cut the edges off and finally obtain a 
+//given a polygon, cut the edges off and finally obtain a
 //a polygon without intersections. The cut-off edges are
 //dealloated. The new polygon is returned.
 directedLine* DBG_cutIntersectionPoly(directedLine *polygon, int& cutOccur)
@@ -563,7 +568,7 @@ directedLine* DBG_cutIntersectionPoly(directedLine *polygon, int& cutOccur)
               Int n=5;
               buf[0] = interc->tail()[0];
               buf[1] = interc->tail()[1];
-              
+
               for(i=1; i<n; i++)
                 {
                   Real r = ((Real)i) / ((Real) n);
@@ -591,7 +596,7 @@ directedLine* DBG_cutIntersectionPoly(directedLine *polygon, int& cutOccur)
            {
              cutOccur = 1;
              begin->deleteSingleLine(next);
-             
+
              if(begin != end)
                {
                  if(DBG_polygonSelfIntersect(begin))
@@ -615,7 +620,7 @@ directedLine* DBG_cutIntersectionPoly(directedLine *polygon, int& cutOccur)
   return begin;
 }
 
-//given a polygon, cut the edges off and finally obtain a 
+//given a polygon, cut the edges off and finally obtain a
 //a polygon without intersections. The cut-off edges are
 //dealloated. The new polygon is returned.
 static directedLine* DBG_cutIntersectionPoly_notwork(directedLine *polygon)
@@ -642,7 +647,7 @@ static directedLine* DBG_cutIntersectionPoly_notwork(directedLine *polygon)
          crt=crt->deleteChain(crt, crt->getNext());
        }
       else
-       {         
+       {
          //now we know crt and crt->getNext do not intersect
          begin = crt;
          end = crt->getNext();
@@ -651,8 +656,8 @@ static directedLine* DBG_cutIntersectionPoly_notwork(directedLine *polygon)
          for(temp=end->getNext(); temp!=begin; temp= temp->getNext())
            {
 //printf("temp=(%f,%f)\n", temp->head()[0], temp->head()[1]);
-               directedLine *intersect = DBG_edgeIntersectChainD(temp, begin, end);
-               if(intersect != NULL)
+              directedLine *intersect = DBG_edgeIntersectChainD(temp, begin, end);
+              if(intersect != NULL)
                {
                  crt = crt->deleteChain(intersect, temp);
                  find=1;
@@ -686,7 +691,7 @@ directedLine* DBG_cutIntersectionAllPoly(directedLine* list)
       if(left != NULL)
        ret=left->insertPolygon(ret);
     }
-  return ret;            
+  return ret;
 }
 
 sampledLine*  DBG_collectSampledLinesAllPoly(directedLine *polygonList)
@@ -709,7 +714,7 @@ sampledLine*  DBG_collectSampledLinesAllPoly(directedLine *polygonList)
       DBG_collectSampledLinesPoly(temp, tempHead, tempTail);
       cTail->insert(tempHead);
       cTail = tempTail;
-    }  
+    }
   return cHead;
 }
 
@@ -721,7 +726,7 @@ void  DBG_collectSampledLinesPoly(directedLine *polygon, sampledLine*& retHead,
   retTail = NULL;
   if(polygon == NULL)
     return;
-    
+
   retHead = retTail = polygon->getSampledLine();
   for(temp = polygon->getNext(); temp != polygon; temp=temp->getNext())
     {
index 14969d4878110478216c4bde0132fd5585077cd1..d2c649eee25ec9190f0122bea000b487e036ea53 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -35,8 +35,8 @@
 /*
 ** Author: Eric Veach, July 1994.
 **
-** $Date: 2001/03/17 00:25:41 $ $Revision: 1.1 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/geom.h,v 1.1 2001/03/17 00:25:41 brianp Exp $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.2 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/geom.h,v 1.2 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #ifndef __geom_h_
@@ -58,8 +58,8 @@
                          ((u)->s == (v)->s && (u)->t <= (v)->t))
 #endif
 
-#define EdgeEval(u,v,w)        __gl_edgeEval(u,v,w)
-#define EdgeSign(u,v,w)        __gl_edgeSign(u,v,w)
+#define EdgeEval(u,v,w) __gl_edgeEval(u,v,w)
+#define EdgeSign(u,v,w) __gl_edgeSign(u,v,w)
 
 /* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
 
 #define TransSign(u,v,w)       __gl_transSign(u,v,w)
 
 
-#define EdgeGoesLeft(e)                VertLeq( (e)->Dst, (e)->Org )
+#define EdgeGoesLeft(e)        VertLeq( (e)->Dst, (e)->Org )
 #define EdgeGoesRight(e)       VertLeq( (e)->Org, (e)->Dst )
 
+#undef ABS
 #define ABS(x) ((x) < 0 ? -(x) : (x))
-#define VertL1dist(u,v)        (ABS(u->s - v->s) + ABS(u->t - v->t))
+#define VertL1dist(u,v) (ABS(u->s - v->s) + ABS(u->t - v->t))
 
 #define VertCCW(u,v,w) __gl_vertCCW(u,v,w)
 
index 618cfd9ccf44a8cb69a2f640c5ca70575f41837d..7ffd39eb32d95af0b69d09c938389c19cc06b589 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -35,8 +35,8 @@
 /*
 ** Author: Eric Veach, July 1994.
 **
-** $Date: 2002/11/01 23:45:31 $ $Revision: 1.2 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/normal.c,v 1.2 2002/11/01 23:45:31 brianp Exp $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.3 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/normal.c,v 1.3 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include "gluos.h"
@@ -64,6 +64,7 @@ static void Normalize( GLdouble v[3] )
 }
 #endif
 
+#undef ABS
 #define ABS(x) ((x) < 0 ? -(x) : (x))
 
 static int LongAxis( GLdouble v[3] )
@@ -138,7 +139,7 @@ static void ComputeNormal( GLUtesselator *tess, GLdouble norm[3] )
     norm[LongAxis(d1)] = 1;
   }
 }
-  
+
 
 static void CheckOrientation( GLUtesselator *tess )
 {
@@ -176,7 +177,7 @@ extern int RandomSweep;
 #define S_UNIT_X       (RandomSweep ? (2*drand48()-1) : 1.0)
 #define S_UNIT_Y       (RandomSweep ? (2*drand48()-1) : 0.0)
 #else
-#if defined(SLANTED_SWEEP) 
+#if defined(SLANTED_SWEEP)
 /* The "feature merging" is not intended to be complete.  There are
  * special cases where edges are nearly parallel to the sweep line
  * which are not implemented.  The algorithm should still behave
@@ -242,7 +243,7 @@ void __gl_projectPolygon( GLUtesselator *tess )
   sUnit[i] = 0;
   sUnit[(i+1)%3] = S_UNIT_X;
   sUnit[(i+2)%3] = S_UNIT_Y;
-  
+
   tUnit[i] = 0;
   tUnit[(i+1)%3] = (norm[i] > 0) ? -S_UNIT_Y : S_UNIT_Y;
   tUnit[(i+2)%3] = (norm[i] > 0) ? S_UNIT_X : -S_UNIT_X;
index f28fad4e506d5db751fa556a8964c77e894a575e..e9fa8a77166499acf3ee36abbfb28f9f7d22e5ab 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -35,8 +35,8 @@
 /*
 ** Author: Eric Veach, July 1994.
 **
-** $Date: 2002/11/07 14:17:05 $ $Revision: 1.5 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/sweep.c,v 1.5 2002/11/07 14:17:05 brianp Exp $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.6 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/sweep.c,v 1.6 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include "gluos.h"
@@ -92,6 +92,8 @@ extern void DebugEvent( GLUtesselator *tess );
  *   when it is necessary.)
  */
 
+#undef MAX
+#undef MIN
 #define MAX(x,y)       ((x) >= (y) ? (x) : (y))
 #define MIN(x,y)       ((x) <= (y) ? (x) : (y))
 
@@ -99,7 +101,7 @@ extern void DebugEvent( GLUtesselator *tess );
  * winding of the new edge.
  */
 #define AddWinding(eDst,eSrc)  (eDst->winding += eSrc->winding, \
-                                eDst->Sym->winding += eSrc->Sym->winding)
+                                 eDst->Sym->winding += eSrc->Sym->winding)
 
 static void SweepEvent( GLUtesselator *tess, GLUvertex *vEvent );
 static void WalkDirtyRegions( GLUtesselator *tess, ActiveRegion *regUp );
@@ -175,7 +177,7 @@ static int FixUpperEdge( ActiveRegion *reg, GLUhalfEdge *newEdge )
   reg->eUp = newEdge;
   newEdge->activeRegion = reg;
 
-  return 1; 
+  return 1;
 }
 
 static ActiveRegion *TopLeftRegion( ActiveRegion *reg )
@@ -225,7 +227,7 @@ static ActiveRegion *AddRegionBelow( GLUtesselator *tess,
   if (regNew == NULL) longjmp(tess->env,1);
 
   regNew->eUp = eNewUp;
-  /* __gl_dictListInsertBefore */ 
+  /* __gl_dictListInsertBefore */
   regNew->nodeUp = dictInsertBefore( tess->dict, regAbove->nodeUp, regNew );
   if (regNew->nodeUp == NULL) longjmp(tess->env,1);
   regNew->fixUpperEdge = FALSE;
@@ -292,7 +294,7 @@ static GLUhalfEdge *FinishLeftRegions( GLUtesselator *tess,
  * active region to the face, since at this point each face will belong
  * to at most one region (this was not necessarily true until this point
  * in the sweep).  The walk stops at the region above regLast; if regLast
- * is NULL we walk as far as possible.  At the same time we relink the
+ * is NULL we walk as far as possible. At the same time we relink the
  * mesh if necessary, so that the ordering of edges around vOrg is the
  * same as in the dictionary.
  */
@@ -449,11 +451,11 @@ static void SpliceMergeVertices( GLUtesselator *tess, GLUhalfEdge *e1,
   data[0] = e1->Org->data;
   data[1] = e2->Org->data;
   CallCombine( tess, e1->Org, data, weights, FALSE );
-  if ( !__gl_meshSplice( e1, e2 ) ) longjmp(tess->env,1); 
+  if ( !__gl_meshSplice( e1, e2 ) ) longjmp(tess->env,1);
 }
 
 static void VertexWeights( GLUvertex *isect, GLUvertex *org, GLUvertex *dst,
-                           GLfloat *weights )
+                          GLfloat *weights )
 /*
  * Find some weights which describe how the intersection vertex is
  * a linear combination of "org" and "dest".  Each of the two edges
@@ -596,7 +598,7 @@ static int CheckForLeftSplice( GLUtesselator *tess, ActiveRegion *regUp )
     /* eUp->Dst is below eLo, so splice eUp->Dst into eLo */
     regUp->dirty = regLo->dirty = TRUE;
     e = __gl_meshSplitEdge( eLo );
-    if (e == NULL) longjmp(tess->env,1);    
+    if (e == NULL) longjmp(tess->env,1);
     if ( !__gl_meshSplice( eUp->Lnext, eLo->Sym ) ) longjmp(tess->env,1);
     e->Rface->inside = regUp->inside;
   }
@@ -682,7 +684,7 @@ static int CheckForIntersect( GLUtesselator *tess, ActiveRegion *regUp )
     return FALSE;
   }
 
-  if(    (! VertEq( dstUp, tess->event )
+  if(   (! VertEq( dstUp, tess->event )
          && EdgeSign( dstUp, tess->event, &isect ) >= 0)
       || (! VertEq( dstLo, tess->event )
          && EdgeSign( dstLo, tess->event, &isect ) <= 0 ))
@@ -705,7 +707,7 @@ static int CheckForIntersect( GLUtesselator *tess, ActiveRegion *regUp )
     if( dstUp == tess->event ) {
       /* Splice dstUp into eLo, and process the new region(s) */
       if (__gl_meshSplitEdge( eLo->Sym ) == NULL) longjmp(tess->env,1);
-      if ( !__gl_meshSplice( eUp->Lnext, eLo->Oprev ) ) longjmp(tess->env,1); 
+      if ( !__gl_meshSplice( eUp->Lnext, eLo->Oprev ) ) longjmp(tess->env,1);
       regLo = regUp;
       regUp = TopRightRegion( regUp );
       e = RegionBelow(regUp)->eUp->Rprev;
@@ -813,7 +815,7 @@ static void WalkDirtyRegions( GLUtesselator *tess, ActiveRegion *regUp )
     if( eUp->Org != eLo->Org ) {
       if(    eUp->Dst != eLo->Dst
          && ! regUp->fixUpperEdge && ! regLo->fixUpperEdge
-          && (eUp->Dst == tess->event || eLo->Dst == tess->event) )
+         && (eUp->Dst == tess->event || eLo->Dst == tess->event) )
       {
        /* When all else fails in CheckForIntersect(), it uses tess->event
         * as the intersection location.  To make this possible, it requires
@@ -822,7 +824,7 @@ static void WalkDirtyRegions( GLUtesselator *tess, ActiveRegion *regUp )
         * case it might splice one of these edges into tess->event, and
         * violate the invariant that fixable edges are the only right-going
         * edge from their associated vertex).
-         */
+        */
        if( CheckForIntersect( tess, regUp )) {
          /* WalkDirtyRegions() was called recursively; we're done */
          return;
@@ -846,7 +848,7 @@ static void WalkDirtyRegions( GLUtesselator *tess, ActiveRegion *regUp )
 
 
 static void ConnectRightVertex( GLUtesselator *tess, ActiveRegion *regUp,
-                               GLUhalfEdge *eBottomLeft )
+                               GLUhalfEdge *eBottomLeft )
 /*
  * Purpose: connect a "right" vertex vEvent (one where all edges go left)
  * to the unprocessed portion of the mesh.  Since there are no right-going
@@ -959,7 +961,7 @@ static void ConnectLeftDegenerate( GLUtesselator *tess,
     SpliceMergeVertices( tess, e, vEvent->anEdge );
     return;
   }
-  
+
   if( ! VertEq( e->Dst, vEvent )) {
     /* General case -- splice vEvent into edge e which passes through it */
     if (__gl_meshSplitEdge( e->Sym ) == NULL) longjmp(tess->env,1);
@@ -969,7 +971,7 @@ static void ConnectLeftDegenerate( GLUtesselator *tess,
       regUp->fixUpperEdge = FALSE;
     }
     if ( !__gl_meshSplice( vEvent->anEdge, e ) ) longjmp(tess->env,1);
-    SweepEvent( tess, vEvent );        /* recurse */
+    SweepEvent( tess, vEvent ); /* recurse */
     return;
   }
 
@@ -1075,9 +1077,9 @@ static void SweepEvent( GLUtesselator *tess, GLUvertex *vEvent )
   ActiveRegion *regUp, *reg;
   GLUhalfEdge *e, *eTopLeft, *eBottomLeft;
 
-  tess->event = vEvent;                /* for access in EdgeLeq() */
+  tess->event = vEvent;        /* for access in EdgeLeq() */
   DebugEvent( tess );
-  
+
   /* Check if this vertex is the right endpoint of an edge that is
    * already in the dictionary.  In this case we don't need to waste
    * time searching for the location to insert new edges.
@@ -1143,7 +1145,7 @@ static void AddSentinel( GLUtesselator *tess, GLdouble t )
   e->Org->t = t;
   e->Dst->s = -SENTINEL_COORD;
   e->Dst->t = t;
-  tess->event = e->Dst;                /* initialize it */
+  tess->event = e->Dst;        /* initialize it */
 
   reg->eUp = e;
   reg->windingNumber = 0;
@@ -1193,7 +1195,7 @@ static void DoneEdgeDict( GLUtesselator *tess )
     DeleteRegion( tess, reg );
 /*    __gl_meshDelete( reg->eUp );*/
   }
-  dictDeleteDict( tess->dict );        /* __gl_dictListDeleteDict */
+  dictDeleteDict( tess->dict ); /* __gl_dictListDeleteDict */
 }
 
 
@@ -1209,10 +1211,10 @@ static void RemoveDegenerateEdges( GLUtesselator *tess )
   for( e = eHead->next; e != eHead; e = eNext ) {
     eNext = e->next;
     eLnext = e->Lnext;
-    
+
     if( VertEq( e->Org, e->Dst ) && e->Lnext->Lnext != e ) {
       /* Zero-length edge, contour has at least 3 edges */
-      
+
       SpliceMergeVertices( tess, eLnext, e );  /* deletes e->Org */
       if ( !__gl_meshDelete( e ) ) longjmp(tess->env,1); /* e is a self-loop */
       e = eLnext;
@@ -1220,7 +1222,7 @@ static void RemoveDegenerateEdges( GLUtesselator *tess )
     }
     if( eLnext->Lnext == e ) {
       /* Degenerate contour (one or two edges) */
-      
+
       if( eLnext != e ) {
        if( eLnext == eNext || eLnext == eNext->Sym ) { eNext = eNext->next; }
        if ( !__gl_meshDelete( eLnext ) ) longjmp(tess->env,1);
@@ -1327,7 +1329,7 @@ int __gl_computeInterior( GLUtesselator *tess )
     for( ;; ) {
       vNext = (GLUvertex *)pqMinimum( tess->pq ); /* __gl_pqSortMinimum */
       if( vNext == NULL || ! VertEq( vNext, v )) break;
-      
+
       /* Merge together all vertices at exactly the same location.
        * This is more efficient than processing them one at a time,
        * simplifies the code (see ConnectLeftDegenerate), and is also
@@ -1349,7 +1351,7 @@ int __gl_computeInterior( GLUtesselator *tess )
   }
 
   /* Set tess->event for debugging purposes */
-  /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */ 
+  /* __GL_DICTLISTKEY */ /* __GL_DICTLISTMIN */
   tess->event = ((ActiveRegion *) dictKey( dictMin( tess->dict )))->eUp->Org;
   DebugEvent( tess );
   DoneEdgeDict( tess );
index 0793106334f45117ca540d9af7babb844649e3dd..308b2f56b90f0368c9b7f08157f7be945f3b682b 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -35,8 +35,8 @@
 /*
 ** Author: Eric Veach, July 1994.
 **
-** $Date: 2002/11/01 23:45:31 $ $Revision: 1.3 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/tess.c,v 1.3 2002/11/01 23:45:31 brianp Exp $
+** $Date: 2003/10/14 23:48:57 $ $Revision: 1.4 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libtess/tess.c,v 1.4 2003/10/14 23:48:57 kendallb Exp $
 */
 
 #include "gluos.h"
 /*ARGSUSED*/ static void GLAPIENTRY noEnd( void ) {}
 /*ARGSUSED*/ static void GLAPIENTRY noError( GLenum errnum ) {}
 /*ARGSUSED*/ static void GLAPIENTRY noCombine( GLdouble coords[3], void *data[4],
-                                    GLfloat weight[4], void **dataOut ) {}
+                                   GLfloat weight[4], void **dataOut ) {}
 /*ARGSUSED*/ static void GLAPIENTRY noMesh( GLUmesh *mesh ) {}
 
 
 /*ARGSUSED*/ void GLAPIENTRY __gl_noBeginData( GLenum type,
                                             void *polygonData ) {}
-/*ARGSUSED*/ void GLAPIENTRY __gl_noEdgeFlagData( GLboolean boundaryEdge, 
+/*ARGSUSED*/ void GLAPIENTRY __gl_noEdgeFlagData( GLboolean boundaryEdge,
                                       void *polygonData ) {}
 /*ARGSUSED*/ void GLAPIENTRY __gl_noVertexData( void *data,
                                              void *polygonData ) {}
 /* Half-edges are allocated in pairs (see mesh.c) */
 typedef struct { GLUhalfEdge e, eSym; } EdgePair;
 
+#undef MAX
 #define MAX(a,b)       ((a) > (b) ? (a) : (b))
 #define MAX_FAST_ALLOC (MAX(sizeof(EdgePair), \
-                        MAX(sizeof(GLUvertex),sizeof(GLUface))))
+                         MAX(sizeof(GLUvertex),sizeof(GLUface))))
 
 
 GLUtesselator * GLAPIENTRY
@@ -170,7 +171,7 @@ static void GotoState( GLUtesselator *tess, enum TessState newState )
        gluTessBeginContour( tess );
        break;
       default:
-         ;
+        ;
       }
     } else {
       switch( tess->state ) {
@@ -184,7 +185,7 @@ static void GotoState( GLUtesselator *tess, enum TessState newState )
        MakeDormant( tess );
        break;
       default:
-         ;
+        ;
       }
     }
   }
@@ -246,7 +247,7 @@ gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value )
       /* tolerance should be in range [0..1] */
       assert(0.0 <= tess->relTolerance && tess->relTolerance <= 1.0);
       *value= tess->relTolerance;
-      break;    
+      break;
    case GLU_TESS_WINDING_RULE:
       assert(tess->windingRule == GLU_TESS_WINDING_ODD ||
             tess->windingRule == GLU_TESS_WINDING_NONZERO ||
@@ -295,7 +296,7 @@ gluTessCallback( GLUtesselator *tess, GLenum which, _GLUfuncptr fn)
     return;
   case GLU_TESS_EDGE_FLAG_DATA:
     tess->callEdgeFlagData= (fn == NULL) ?
-       &__gl_noEdgeFlagData : (void (GLAPIENTRY *)(GLboolean, void *)) fn; 
+       &__gl_noEdgeFlagData : (void (GLAPIENTRY *)(GLboolean, void *)) fn;
     /* If the client wants boundary edges to be flagged,
      * we render everything as separate triangles (no strips or fans).
      */
@@ -313,8 +314,8 @@ gluTessCallback( GLUtesselator *tess, GLenum which, _GLUfuncptr fn)
     tess->callEnd = (fn == NULL) ? &noEnd : (void (GLAPIENTRY *)(void)) fn;
     return;
   case GLU_TESS_END_DATA:
-    tess->callEndData = (fn == NULL) ? &__gl_noEndData : 
-                                       (void (GLAPIENTRY *)(void *)) fn;
+    tess->callEndData = (fn == NULL) ? &__gl_noEndData :
+                                      (void (GLAPIENTRY *)(void *)) fn;
     return;
   case GLU_TESS_ERROR:
     tess->callError = (fn == NULL) ? &noError : (void (GLAPIENTRY *)(GLenum)) fn;
@@ -329,9 +330,9 @@ gluTessCallback( GLUtesselator *tess, GLenum which, _GLUfuncptr fn)
     return;
   case GLU_TESS_COMBINE_DATA:
     tess->callCombineData = (fn == NULL) ? &__gl_noCombineData :
-                                           (void (GLAPIENTRY *)(GLdouble [3],
-                                                    void *[4], 
-                                                    GLfloat [4], 
+                                          (void (GLAPIENTRY *)(GLdouble [3],
+                                                    void *[4],
+                                                    GLfloat [4],
                                                     void **,
                                                     void *)) fn;
     return;
@@ -368,7 +369,7 @@ static int AddVertex( GLUtesselator *tess, GLdouble coords[3], void *data )
   e->Org->coords[0] = coords[0];
   e->Org->coords[1] = coords[1];
   e->Org->coords[2] = coords[2];
-  
+
   /* The winding of an edge says how the winding number changes as we
    * cross from the edge''s right face to its left face.  We add the
    * vertices in such an order that a CCW contour will add +1 to
@@ -503,7 +504,7 @@ gluTessEndPolygon( GLUtesselator *tess )
 {
   GLUmesh *mesh;
 
-  if (setjmp(tess->env) != 0) {        
+  if (setjmp(tess->env) != 0) { 
      /* come back here if out of memory */
      CALL_ERROR_OR_ERROR_DATA( GLU_OUT_OF_MEMORY );
      return;
@@ -521,7 +522,7 @@ gluTessEndPolygon( GLUtesselator *tess )
        * an explicit mesh either.
        */
       if( __gl_renderCache( tess )) {
-       tess->polygonData= NULL; 
+       tess->polygonData= NULL;
        return;
       }
     }
@@ -554,15 +555,15 @@ gluTessEndPolygon( GLUtesselator *tess )
     if( tess->boundaryOnly ) {
       rc = __gl_meshSetWindingNumber( mesh, 1, TRUE );
     } else {
-      rc = __gl_meshTessellateInterior( mesh ); 
+      rc = __gl_meshTessellateInterior( mesh );
     }
     if (rc == 0) longjmp(tess->env,1); /* could've used a label */
 
     __gl_meshCheckMesh( mesh );
 
     if( tess->callBegin != &noBegin || tess->callEnd != &noEnd
-       || tess->callVertex != &noVertex || tess->callEdgeFlag != &noEdgeFlag 
-       || tess->callBeginData != &__gl_noBeginData 
+       || tess->callVertex != &noVertex || tess->callEdgeFlag != &noEdgeFlag
+       || tess->callBeginData != &__gl_noBeginData
        || tess->callEndData != &__gl_noEndData
        || tess->callVertexData != &__gl_noVertexData
        || tess->callEdgeFlagData != &__gl_noEdgeFlagData )
index 5b275fa50d1a5dcb5cb3c103b75c7e0071ddf06d..4ee54533582fdfe02da51d36ecdbcf996893fe70 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -31,8 +31,8 @@
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2002/11/01 23:45:31 $ $Revision: 1.3 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libutil/mipmap.c,v 1.3 2002/11/01 23:45:31 brianp Exp $
+** $Date: 2003/10/14 23:48:58 $ $Revision: 1.4 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libutil/mipmap.c,v 1.4 2003/10/14 23:48:58 kendallb Exp $
 */
 
 #include "gluos.h"
@@ -55,11 +55,11 @@ typedef union {
     float f;
 } Type_Widget;
 
-/* Pixel storage modes */ 
+/* Pixel storage modes */
 typedef struct {
    GLint pack_alignment;
-   GLint pack_row_length; 
-   GLint pack_skip_rows;  
+   GLint pack_row_length;
+   GLint pack_skip_rows;
    GLint pack_skip_pixels;
    GLint pack_lsb_first;
    GLint pack_swap_bytes;
@@ -76,20 +76,20 @@ typedef struct {
    GLint unpack_image_height;
 } PixelStorageModes;
 
-static int gluBuild1DMipmapLevelsCore(GLenum, GLint, 
+static int gluBuild1DMipmapLevelsCore(GLenum, GLint,
                                      GLsizei,
                                      GLsizei,
-                                     GLenum, GLenum, GLint, GLint, GLint, 
+                                     GLenum, GLenum, GLint, GLint, GLint,
                                      const void *);
-static int gluBuild2DMipmapLevelsCore(GLenum, GLint, 
-                                     GLsizei, GLsizei, 
-                                     GLsizei, GLsizei, 
-                                     GLenum, GLenum, GLint, GLint, GLint, 
+static int gluBuild2DMipmapLevelsCore(GLenum, GLint,
+                                     GLsizei, GLsizei,
+                                     GLsizei, GLsizei,
+                                     GLenum, GLenum, GLint, GLint, GLint,
                                      const void *);
-static int gluBuild3DMipmapLevelsCore(GLenum, GLint, 
+static int gluBuild3DMipmapLevelsCore(GLenum, GLint,
                                      GLsizei, GLsizei, GLsizei,
                                      GLsizei, GLsizei, GLsizei,
-                                     GLenum, GLenum, GLint, GLint, GLint, 
+                                     GLenum, GLenum, GLint, GLint, GLint,
                                      const void *);
 
 /*
@@ -100,58 +100,58 @@ static GLint elements_per_group(GLenum format, GLenum type);
 static GLint is_index(GLenum format);
 static GLint image_size(GLint width, GLint height, GLenum format, GLenum type);
 static void fill_image(const PixelStorageModes *,
-                      GLint width, GLint height, GLenum format, 
-                      GLenum type, GLboolean index_format, 
+                      GLint width, GLint height, GLenum format,
+                      GLenum type, GLboolean index_format,
                       const void *userdata, GLushort *newimage);
 static void empty_image(const PixelStorageModes *,
-                       GLint width, GLint height, GLenum format, 
-                       GLenum type, GLboolean index_format, 
+                       GLint width, GLint height, GLenum format,
+                       GLenum type, GLboolean index_format,
                        const GLushort *oldimage, void *userdata);
-static void scale_internal(GLint components, GLint widthin, GLint heightin, 
-                          const GLushort *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal(GLint components, GLint widthin, GLint heightin,
+                          const GLushort *datain,
+                          GLint widthout, GLint heightout,
                           GLushort *dataout);
 
-static void scale_internal_ubyte(GLint components, GLint widthin, 
-                          GLint heightin, const GLubyte *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal_ubyte(GLint components, GLint widthin,
+                          GLint heightin, const GLubyte *datain,
+                          GLint widthout, GLint heightout,
                           GLubyte *dataout, GLint element_size,
                           GLint ysize, GLint group_size);
 static void scale_internal_byte(GLint components, GLint widthin,
-                           GLint heightin, const GLbyte *datain,
-                           GLint widthout, GLint heightout,
-                           GLbyte *dataout, GLint element_size,
-                           GLint ysize, GLint group_size);
+                          GLint heightin, const GLbyte *datain,
+                          GLint widthout, GLint heightout,
+                          GLbyte *dataout, GLint element_size,
+                          GLint ysize, GLint group_size);
 static void scale_internal_ushort(GLint components, GLint widthin,
-                           GLint heightin, const GLushort *datain,
-                           GLint widthout, GLint heightout,
-                           GLushort *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes);
+                          GLint heightin, const GLushort *datain,
+                          GLint widthout, GLint heightout,
+                          GLushort *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes);
 static void scale_internal_short(GLint components, GLint widthin,
-                           GLint heightin, const GLshort *datain,
-                           GLint widthout, GLint heightout,
-                           GLshort *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes);
+                          GLint heightin, const GLshort *datain,
+                          GLint widthout, GLint heightout,
+                          GLshort *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes);
 static void scale_internal_uint(GLint components, GLint widthin,
-                           GLint heightin, const GLuint *datain,
-                           GLint widthout, GLint heightout,
-                           GLuint *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes);
+                          GLint heightin, const GLuint *datain,
+                          GLint widthout, GLint heightout,
+                          GLuint *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes);
 static void scale_internal_int(GLint components, GLint widthin,
-                           GLint heightin, const GLint *datain,
-                           GLint widthout, GLint heightout,
-                           GLint *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes);
+                          GLint heightin, const GLint *datain,
+                          GLint widthout, GLint heightout,
+                          GLint *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes);
 static void scale_internal_float(GLint components, GLint widthin,
-                           GLint heightin, const GLfloat *datain,
-                           GLint widthout, GLint heightout,
-                           GLfloat *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes);
+                          GLint heightin, const GLfloat *datain,
+                          GLint widthout, GLint heightout,
+                          GLfloat *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes);
 
 static int checkMipmapArgs(GLenum, GLenum, GLenum);
 static GLboolean legalFormat(GLenum);
@@ -231,27 +231,27 @@ static void halve1DimagePackedPixel(int,
 
 static void halve1Dimage_ubyte(GLint, GLuint, GLuint,const GLubyte *,
                               GLubyte *, GLint, GLint, GLint);
-static void halve1Dimage_byte(GLint, GLuint, GLuint,const GLbyte *, GLbyte *, 
+static void halve1Dimage_byte(GLint, GLuint, GLuint,const GLbyte *, GLbyte *,
                              GLint, GLint, GLint);
 static void halve1Dimage_ushort(GLint, GLuint, GLuint, const GLushort *,
                                GLushort *, GLint, GLint, GLint, GLint);
-static void halve1Dimage_short(GLint, GLuint, GLuint,const GLshort *, GLshort *, 
+static void halve1Dimage_short(GLint, GLuint, GLuint,const GLshort *, GLshort *,
                               GLint, GLint, GLint, GLint);
-static void halve1Dimage_uint(GLint, GLuint, GLuint, const GLuint *, GLuint *, 
+static void halve1Dimage_uint(GLint, GLuint, GLuint, const GLuint *, GLuint *,
                              GLint, GLint, GLint, GLint);
-static void halve1Dimage_int(GLint, GLuint, GLuint, const GLint *, GLint *, 
+static void halve1Dimage_int(GLint, GLuint, GLuint, const GLint *, GLint *,
                             GLint, GLint, GLint, GLint);
-static void halve1Dimage_float(GLint, GLuint, GLuint, const GLfloat *, GLfloat *, 
+static void halve1Dimage_float(GLint, GLuint, GLuint, const GLfloat *, GLfloat *,
                               GLint, GLint, GLint, GLint);
 
 static GLint imageSize3D(GLint, GLint, GLint, GLenum,GLenum);
-static void fillImage3D(const PixelStorageModes *, GLint, GLint, GLint,GLenum, 
+static void fillImage3D(const PixelStorageModes *, GLint, GLint, GLint,GLenum,
                        GLenum, GLboolean, const void *, GLushort *);
 static void emptyImage3D(const PixelStorageModes *,
-                        GLint, GLint, GLint, GLenum, 
-                        GLenum, GLboolean, 
+                        GLint, GLint, GLint, GLenum,
+                        GLenum, GLboolean,
                         const GLushort *, void *);
-static void scaleInternal3D(GLint, GLint, GLint, GLint, const GLushort *, 
+static void scaleInternal3D(GLint, GLint, GLint, GLint, const GLushort *,
                            GLint, GLint, GLint, GLushort *);
 
 static void retrieveStoreModes(PixelStorageModes *psm)
@@ -312,8 +312,8 @@ static int computeLog(GLuint value)
     }
 }
 
-/* 
-** Compute the nearest power of 2 number.  This algorithm is a little 
+/*
+** Compute the nearest power of 2 number.  This algorithm is a little
 ** strange, but it works quite well.
 */
 static int nearestPower(GLuint value)
@@ -341,10 +341,10 @@ static int nearestPower(GLuint value)
 
 #define __GLU_SWAP_4_BYTES(s)\
 (GLuint)(((GLuint)((const GLubyte*)(s))[3])<<24 | \
-       ((GLuint)((const GLubyte*)(s))[2])<<16 | \
-       ((GLuint)((const GLubyte*)(s))[1])<<8  | ((const GLubyte*)(s))[0])
+        ((GLuint)((const GLubyte*)(s))[2])<<16 | \
+        ((GLuint)((const GLubyte*)(s))[1])<<8  | ((const GLubyte*)(s))[0])
 
-static void halveImage(GLint components, GLuint width, GLuint height, 
+static void halveImage(GLint components, GLuint width, GLuint height,
                       const GLushort *datain, GLushort *dataout)
 {
     int i, j, k;
@@ -363,7 +363,7 @@ static void halveImage(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               s[0] = (t[0] + t[components] + t[delta] + 
+               s[0] = (t[0] + t[components] + t[delta] +
                        t[delta+components] + 2) / 4;
                s++; t++;
            }
@@ -373,7 +373,7 @@ static void halveImage(GLint components, GLuint width, GLuint height,
     }
 }
 
-static void halveImage_ubyte(GLint components, GLuint width, GLuint height, 
+static void halveImage_ubyte(GLint components, GLuint width, GLuint height,
                        const GLubyte *datain, GLubyte *dataout,
                        GLint element_size, GLint ysize, GLint group_size)
 {
@@ -399,11 +399,11 @@ static void halveImage_ubyte(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-                s[0] = (*(const GLubyte*)t + 
+               s[0] = (*(const GLubyte*)t +
                        *(const GLubyte*)(t+group_size) +
-                        *(const GLubyte*)(t+ysize) +
-                        *(const GLubyte*)(t+ysize+group_size) + 2) / 4;
-                s++; t += element_size;
+                       *(const GLubyte*)(t+ysize) +
+                       *(const GLubyte*)(t+ysize+group_size) + 2) / 4;
+               s++; t += element_size;
            }
            t += group_size;
        }
@@ -412,9 +412,9 @@ static void halveImage_ubyte(GLint components, GLuint width, GLuint height,
 }
 
 /* */
-static void halve1Dimage_ubyte(GLint components, GLuint width, GLuint height, 
-                              const GLubyte *dataIn, GLubyte *dataOut, 
-                              GLint element_size, GLint ysize, 
+static void halve1Dimage_ubyte(GLint components, GLuint width, GLuint height,
+                              const GLubyte *dataIn, GLubyte *dataOut,
+                              GLint element_size, GLint ysize,
                               GLint group_size)
 {
    GLint halfWidth= width / 2;
@@ -437,19 +437,19 @@ static void halve1Dimage_ubyte(GLint components, GLuint width, GLuint height,
                 *(const GLubyte*)(src+group_size)) / 2;
 
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -460,7 +460,7 @@ static void halve1Dimage_ubyte(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -471,7 +471,7 @@ static void halve1Dimage_ubyte(GLint components, GLuint width, GLuint height,
          [components * element_size * halfWidth * halfHeight]);
 } /* halve1Dimage_ubyte() */
 
-static void halveImage_byte(GLint components, GLuint width, GLuint height, 
+static void halveImage_byte(GLint components, GLuint width, GLuint height,
                        const GLbyte *datain, GLbyte *dataout,
                        GLint element_size,
                        GLint ysize, GLint group_size)
@@ -498,11 +498,11 @@ static void halveImage_byte(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-                s[0] = (*(const GLbyte*)t + 
+               s[0] = (*(const GLbyte*)t +
                        *(const GLbyte*)(t+group_size) +
-                        *(const GLbyte*)(t+ysize) +
-                        *(const GLbyte*)(t+ysize+group_size) + 2) / 4;
-                s++; t += element_size;
+                       *(const GLbyte*)(t+ysize) +
+                       *(const GLbyte*)(t+ysize+group_size) + 2) / 4;
+               s++; t += element_size;
            }
            t += group_size;
        }
@@ -510,8 +510,8 @@ static void halveImage_byte(GLint components, GLuint width, GLuint height,
     }
 }
 
-static void halve1Dimage_byte(GLint components, GLuint width, GLuint height, 
-                             const GLbyte *dataIn, GLbyte *dataOut, 
+static void halve1Dimage_byte(GLint components, GLuint width, GLuint height,
+                             const GLbyte *dataIn, GLbyte *dataOut,
                              GLint element_size,GLint ysize, GLint group_size)
 {
    GLint halfWidth= width / 2;
@@ -533,19 +533,19 @@ static void halve1Dimage_byte(GLint components, GLuint width, GLuint height,
            *dest= (*(const GLbyte*)src + *(const GLbyte*)(src+group_size)) / 2;
 
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -556,7 +556,7 @@ static void halve1Dimage_byte(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -568,8 +568,8 @@ static void halve1Dimage_byte(GLint components, GLuint width, GLuint height,
          [components * element_size * halfWidth * halfHeight]);
 } /* halve1Dimage_byte() */
 
-static void halveImage_ushort(GLint components, GLuint width, GLuint height, 
-                       const GLushort *datain, GLushort *dataout,
+static void halveImage_ushort(GLint components, GLuint width, GLuint height,
+                       const GLushort *datain, GLushort *dataout,
                        GLint element_size, GLint ysize, GLint group_size,
                        GLint myswap_bytes)
 {
@@ -596,9 +596,9 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               s[0] = (*(const GLushort*)t + 
-                       *(const GLushort*)(t+group_size) + 
-                       *(const GLushort*)(t+ysize) + 
+               s[0] = (*(const GLushort*)t +
+                       *(const GLushort*)(t+group_size) +
+                       *(const GLushort*)(t+ysize) +
                        *(const GLushort*)(t+ysize+group_size) + 2) / 4;
                s++; t += element_size;
            }
@@ -608,23 +608,23 @@ static void halveImage_ushort(GLint components, GLuint width, GLuint height,
     }
     else
     for (i = 0; i < newheight; i++) {
-        for (j = 0; j < newwidth; j++) {
-            for (k = 0; k < components; k++) {
+       for (j = 0; j < newwidth; j++) {
+           for (k = 0; k < components; k++) {
                s[0] = (__GLU_SWAP_2_BYTES(t) +
                        __GLU_SWAP_2_BYTES(t+group_size) +
                        __GLU_SWAP_2_BYTES(t+ysize) +
                        __GLU_SWAP_2_BYTES(t+ysize+group_size)+ 2)/4;
-                s++; t += element_size;
+               s++; t += element_size;
            }
            t += group_size;
-        }
-        t += ysize;
+       }
+       t += ysize;
     }
 }
 
-static void halve1Dimage_ushort(GLint components, GLuint width, GLuint height, 
-                               const GLushort *dataIn, GLushort *dataOut, 
-                               GLint element_size, GLint ysize, 
+static void halve1Dimage_ushort(GLint components, GLuint width, GLuint height,
+                               const GLushort *dataIn, GLushort *dataOut,
+                               GLint element_size, GLint ysize,
                                GLint group_size, GLint myswap_bytes)
 {
    GLint halfWidth= width / 2;
@@ -656,19 +656,19 @@ static void halve1Dimage_ushort(GLint components, GLuint width, GLuint height,
 
            *dest= (ushort[0] + ushort[1]) / 2;
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -689,7 +689,7 @@ static void halve1Dimage_ushort(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -703,7 +703,7 @@ static void halve1Dimage_ushort(GLint components, GLuint width, GLuint height,
 } /* halve1Dimage_ushort() */
 
 
-static void halveImage_short(GLint components, GLuint width, GLuint height, 
+static void halveImage_short(GLint components, GLuint width, GLuint height,
                        const GLshort *datain, GLshort *dataout,
                        GLint element_size, GLint ysize, GLint group_size,
                        GLint myswap_bytes)
@@ -731,9 +731,9 @@ static void halveImage_short(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               s[0] = (*(const GLshort*)t + 
-                       *(const GLshort*)(t+group_size) + 
-                       *(const GLshort*)(t+ysize) + 
+               s[0] = (*(const GLshort*)t +
+                       *(const GLshort*)(t+group_size) +
+                       *(const GLshort*)(t+ysize) +
                        *(const GLshort*)(t+ysize+group_size) + 2) / 4;
                s++; t += element_size;
            }
@@ -743,30 +743,30 @@ static void halveImage_short(GLint components, GLuint width, GLuint height,
     }
     else
     for (i = 0; i < newheight; i++) {
-        for (j = 0; j < newwidth; j++) {
-            for (k = 0; k < components; k++) {
+       for (j = 0; j < newwidth; j++) {
+           for (k = 0; k < components; k++) {
                GLushort b;
                GLint buf;
-                b = __GLU_SWAP_2_BYTES(t);
+               b = __GLU_SWAP_2_BYTES(t);
                buf = *(const GLshort*)&b;
-                b = __GLU_SWAP_2_BYTES(t+group_size);
+               b = __GLU_SWAP_2_BYTES(t+group_size);
                buf += *(const GLshort*)&b;
-                b = __GLU_SWAP_2_BYTES(t+ysize);
+               b = __GLU_SWAP_2_BYTES(t+ysize);
                buf += *(const GLshort*)&b;
-                b = __GLU_SWAP_2_BYTES(t+ysize+group_size);
+               b = __GLU_SWAP_2_BYTES(t+ysize+group_size);
                buf += *(const GLshort*)&b;
                s[0] = (GLshort)((buf+2)/4);
-                s++; t += element_size;
+               s++; t += element_size;
            }
            t += group_size;
-        }
-        t += ysize;
+       }
+       t += ysize;
     }
 }
 
-static void halve1Dimage_short(GLint components, GLuint width, GLuint height, 
-                               const GLshort *dataIn, GLshort *dataOut, 
-                               GLint element_size, GLint ysize, 
+static void halve1Dimage_short(GLint components, GLuint width, GLuint height,
+                               const GLshort *dataIn, GLshort *dataOut,
+                               GLint element_size, GLint ysize,
                                GLint group_size, GLint myswap_bytes)
 {
    GLint halfWidth= width / 2;
@@ -798,19 +798,19 @@ static void halve1Dimage_short(GLint components, GLuint width, GLuint height,
 
            *dest= (sshort[0] + sshort[1]) / 2;
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -831,7 +831,7 @@ static void halve1Dimage_short(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -845,8 +845,8 @@ static void halve1Dimage_short(GLint components, GLuint width, GLuint height,
 } /* halve1Dimage_short() */
 
 
-static void halveImage_uint(GLint components, GLuint width, GLuint height, 
-                       const GLuint *datain, GLuint *dataout,
+static void halveImage_uint(GLint components, GLuint width, GLuint height,
+                       const GLuint *datain, GLuint *dataout,
                        GLint element_size, GLint ysize, GLint group_size,
                        GLint myswap_bytes)
 {
@@ -869,15 +869,15 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height,
     t = (const char *)datain;
 
     /* Piece o' cake! */
-    if (!myswap_bytes) 
+    if (!myswap_bytes)
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               /* need to cast to double to hold large unsigned ints */
-               s[0] = ((double)*(const GLuint*)t + 
-                       (double)*(const GLuint*)(t+group_size) + 
-                       (double)*(const GLuint*)(t+ysize) + 
-                       (double)*(const GLuint*)(t+ysize+group_size))/4 + 0.5;
+               /* need to cast to double to hold large unsigned ints */
+               s[0] = ((double)*(const GLuint*)t +
+                       (double)*(const GLuint*)(t+group_size) +
+                       (double)*(const GLuint*)(t+ysize) +
+                       (double)*(const GLuint*)(t+ysize+group_size))/4 + 0.5;
                s++; t += element_size;
 
            }
@@ -887,28 +887,28 @@ static void halveImage_uint(GLint components, GLuint width, GLuint height,
     }
     else
     for (i = 0; i < newheight; i++) {
-        for (j = 0; j < newwidth; j++) {
-            for (k = 0; k < components; k++) {
-               /* need to cast to double to hold large unsigned ints */
+       for (j = 0; j < newwidth; j++) {
+           for (k = 0; k < components; k++) {
+               /* need to cast to double to hold large unsigned ints */
                GLdouble buf;
-                buf = (GLdouble)__GLU_SWAP_4_BYTES(t) +
-                      (GLdouble)__GLU_SWAP_4_BYTES(t+group_size) +
-                      (GLdouble)__GLU_SWAP_4_BYTES(t+ysize) +
-                      (GLdouble)__GLU_SWAP_4_BYTES(t+ysize+group_size);
-                s[0] = (GLuint)(buf/4 + 0.5);
+               buf = (GLdouble)__GLU_SWAP_4_BYTES(t) +
+                     (GLdouble)__GLU_SWAP_4_BYTES(t+group_size) +
+                     (GLdouble)__GLU_SWAP_4_BYTES(t+ysize) +
+                     (GLdouble)__GLU_SWAP_4_BYTES(t+ysize+group_size);
+               s[0] = (GLuint)(buf/4 + 0.5);
 
                s++; t += element_size;
            }
            t += group_size;
-        }
-        t += ysize;
+       }
+       t += ysize;
     }
 }
 
 /* */
-static void halve1Dimage_uint(GLint components, GLuint width, GLuint height, 
-                             const GLuint *dataIn, GLuint *dataOut, 
-                             GLint element_size, GLint ysize, 
+static void halve1Dimage_uint(GLint components, GLuint width, GLuint height,
+                             const GLuint *dataIn, GLuint *dataOut,
+                             GLint element_size, GLint ysize,
                              GLint group_size, GLint myswap_bytes)
 {
    GLint halfWidth= width / 2;
@@ -937,22 +937,22 @@ static void halve1Dimage_uint(GLint components, GLuint width, GLuint height,
               uint[0]= *(const GLuint*)src;
               uint[1]= *(const GLuint*)(src+group_size);
            }
-           *dest= ((double)uint[0]+(double)uint[1])/2.0;   
+           *dest= ((double)uint[0]+(double)uint[1])/2.0;
 
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -973,7 +973,7 @@ static void halve1Dimage_uint(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -986,8 +986,8 @@ static void halve1Dimage_uint(GLint components, GLuint width, GLuint height,
 
 } /* halve1Dimage_uint() */
 
-static void halveImage_int(GLint components, GLuint width, GLuint height, 
-                       const GLint *datain, GLint *dataout, GLint element_size,
+static void halveImage_int(GLint components, GLuint width, GLuint height,
+                       const GLint *datain, GLint *dataout, GLint element_size,
                        GLint ysize, GLint group_size, GLint myswap_bytes)
 {
     int i, j, k;
@@ -1009,13 +1009,13 @@ static void halveImage_int(GLint components, GLuint width, GLuint height,
     t = (const char *)datain;
 
     /* Piece o' cake! */
-    if (!myswap_bytes) 
+    if (!myswap_bytes)
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               s[0] = ((float)*(const GLint*)t + 
-                       (float)*(const GLint*)(t+group_size) + 
-                       (float)*(const GLint*)(t+ysize) + 
+               s[0] = ((float)*(const GLint*)t +
+                       (float)*(const GLint*)(t+group_size) +
+                       (float)*(const GLint*)(t+ysize) +
                        (float)*(const GLint*)(t+ysize+group_size))/4 + 0.5;
                s++; t += element_size;
            }
@@ -1023,34 +1023,34 @@ static void halveImage_int(GLint components, GLuint width, GLuint height,
        }
        t += ysize;
     }
-    else 
+    else
     for (i = 0; i < newheight; i++) {
-        for (j = 0; j < newwidth; j++) {
-            for (k = 0; k < components; k++) {
+       for (j = 0; j < newwidth; j++) {
+           for (k = 0; k < components; k++) {
                GLuint b;
-                GLfloat buf;
-                b = __GLU_SWAP_4_BYTES(t);
-                buf = *(GLint*)&b;
-                b = __GLU_SWAP_4_BYTES(t+group_size);
-                buf += *(GLint*)&b;
-                b = __GLU_SWAP_4_BYTES(t+ysize);
-                buf += *(GLint*)&b;
-                b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
-                buf += *(GLint*)&b;
-                s[0] = (GLint)(buf/4 + 0.5);
-
-                s++; t += element_size;
+               GLfloat buf;
+               b = __GLU_SWAP_4_BYTES(t);
+               buf = *(GLint*)&b;
+               b = __GLU_SWAP_4_BYTES(t+group_size);
+               buf += *(GLint*)&b;
+               b = __GLU_SWAP_4_BYTES(t+ysize);
+               buf += *(GLint*)&b;
+               b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
+               buf += *(GLint*)&b;
+               s[0] = (GLint)(buf/4 + 0.5);
+
+               s++; t += element_size;
            }
            t += group_size;
-        }
-        t += ysize;
+       }
+       t += ysize;
     }
 }
 
 /* */
-static void halve1Dimage_int(GLint components, GLuint width, GLuint height, 
-                            const GLint *dataIn, GLint *dataOut, 
-                            GLint element_size, GLint ysize, 
+static void halve1Dimage_int(GLint components, GLuint width, GLuint height,
+                            const GLint *dataIn, GLint *dataOut,
+                            GLint element_size, GLint ysize,
                             GLint group_size, GLint myswap_bytes)
 {
    GLint halfWidth= width / 2;
@@ -1082,19 +1082,19 @@ static void halve1Dimage_int(GLint components, GLuint width, GLuint height,
            *dest= ((float)uint[0]+(float)uint[1])/2.0;
 
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -1115,7 +1115,7 @@ static void halve1Dimage_int(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;
       }
@@ -1129,8 +1129,8 @@ static void halve1Dimage_int(GLint components, GLuint width, GLuint height,
 } /* halve1Dimage_int() */
 
 
-static void halveImage_float(GLint components, GLuint width, GLuint height, 
-                       const GLfloat *datain, GLfloat *dataout,
+static void halveImage_float(GLint components, GLuint width, GLuint height,
+                       const GLfloat *datain, GLfloat *dataout,
                        GLint element_size, GLint ysize, GLint group_size,
                        GLint myswap_bytes)
 {
@@ -1157,9 +1157,9 @@ static void halveImage_float(GLint components, GLuint width, GLuint height,
     for (i = 0; i < newheight; i++) {
        for (j = 0; j < newwidth; j++) {
            for (k = 0; k < components; k++) {
-               s[0] = (*(const GLfloat*)t + 
-                       *(const GLfloat*)(t+group_size) + 
-                       *(const GLfloat*)(t+ysize) + 
+               s[0] = (*(const GLfloat*)t +
+                       *(const GLfloat*)(t+group_size) +
+                       *(const GLfloat*)(t+ysize) +
                        *(const GLfloat*)(t+ysize+group_size)) / 4;
                s++; t += element_size;
            }
@@ -1167,38 +1167,38 @@ static void halveImage_float(GLint components, GLuint width, GLuint height,
        }
        t += ysize;
     }
-    else 
+    else
     for (i = 0; i < newheight; i++) {
-        for (j = 0; j < newwidth; j++) {
-            for (k = 0; k < components; k++) {
+       for (j = 0; j < newwidth; j++) {
+           for (k = 0; k < components; k++) {
                GLuint b;
-                b = __GLU_SWAP_4_BYTES(t);
-                s[0] = *(GLfloat*)&b;
-                b = __GLU_SWAP_4_BYTES(t+group_size);
-                s[0] += *(GLfloat*)&b;
-                b = __GLU_SWAP_4_BYTES(t+ysize);
-                s[0] += *(GLfloat*)&b;
-                b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
-                s[0] += *(GLfloat*)&b;
+               b = __GLU_SWAP_4_BYTES(t);
+               s[0] = *(GLfloat*)&b;
+               b = __GLU_SWAP_4_BYTES(t+group_size);
+               s[0] += *(GLfloat*)&b;
+               b = __GLU_SWAP_4_BYTES(t+ysize);
+               s[0] += *(GLfloat*)&b;
+               b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
+               s[0] += *(GLfloat*)&b;
                s[0] /= 4;
-                s++; t += element_size;
+               s++; t += element_size;
            }
            t += group_size;
-        }
-        t += ysize;
+       }
+       t += ysize;
     }
 }
 
 /* */
-static void halve1Dimage_float(GLint components, GLuint width, GLuint height, 
-                              const GLfloat *dataIn, GLfloat *dataOut, 
-                              GLint element_size, GLint ysize, 
+static void halve1Dimage_float(GLint components, GLuint width, GLuint height,
+                              const GLfloat *dataIn, GLfloat *dataOut,
+                              GLint element_size, GLint ysize,
                               GLint group_size, GLint myswap_bytes)
 {
    GLint halfWidth= width / 2;
    GLint halfHeight= height / 2;
    const char *src= (const char *) dataIn;
-   GLfloat *dest= dataOut; 
+   GLfloat *dest= dataOut;
    int jj;
 
    assert(width == 1 || height == 1); /* must be 1D */
@@ -1224,19 +1224,19 @@ static void halve1Dimage_float(GLint components, GLuint width, GLuint height,
 
            *dest= (sfloat[0] + sfloat[1]) / 2.0;
            src+= element_size;
-           dest++;  
-        } 
+           dest++;
+        }
         src+= group_size;      /* skip to next 2 */
       }
       {
-        int padBytes= ysize - (width*group_size); 
+        int padBytes= ysize - (width*group_size);
         src+= padBytes;        /* for assertion only */
       }
    }
    else if (width == 1) {      /* 1 column */
       int padBytes= ysize - (width * group_size);
       assert(height != 1);     /* widthxheight can't be 1x1 */
-      halfWidth= 1; 
+      halfWidth= 1;
       /* one vertical column with possible pad bytes per row */
       /* average two at a time */
 
@@ -1257,7 +1257,7 @@ static void halve1Dimage_float(GLint components, GLuint width, GLuint height,
 
            src+= element_size;
            dest++;
-        }  
+        }
         src+= padBytes; /* add pad bytes, if any, to get to end to row */
         src+= ysize;           /* skip to odd row */
       }
@@ -1268,9 +1268,9 @@ static void halve1Dimage_float(GLint components, GLuint width, GLuint height,
          [components * element_size * halfWidth * halfHeight]);
 } /* halve1Dimage_float() */
 
-static void scale_internal(GLint components, GLint widthin, GLint heightin, 
-                          const GLushort *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal(GLint components, GLint widthin, GLint heightin,
+                          const GLushort *datain,
+                          GLint widthout, GLint heightout,
                           GLushort *dataout)
 {
     float x, lowx, highx, convx, halfconvx;
@@ -1364,9 +1364,9 @@ static void scale_internal(GLint components, GLint widthin, GLint heightin,
     }
 }
 
-static void scale_internal_ubyte(GLint components, GLint widthin, 
-                          GLint heightin, const GLubyte *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal_ubyte(GLint components, GLint widthin,
+                          GLint heightin, const GLubyte *datain,
+                          GLint widthout, GLint heightout,
                           GLubyte *dataout, GLint element_size,
                           GLint ysize, GLint group_size)
 {
@@ -1391,8 +1391,8 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
     const char *left, *right;
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-       halveImage_ubyte(components, widthin, heightin, 
-       (const GLubyte *)datain, (GLubyte *)dataout, 
+       halveImage_ubyte(components, widthin, heightin,
+       (const GLubyte *)datain, (GLubyte *)dataout,
        element_size, ysize, group_size);
        return;
     }
@@ -1402,7 +1402,7 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
     convy_float = convy - convy_int;
     convx_int = floor(convx);
     convx_float = convx - convx_int;
-   
+
     area = convx * convy;
 
     lowy_int = 0;
@@ -1430,58 +1430,58 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
 
                y_percent = 1-lowy_float;
-               temp = (const char *)datain + xindex + lowy_int * ysize;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
                percent = y_percent * (1-lowx_float);
-               for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-               }
+               }
                left = temp;
-               for(l = lowx_int+1; l < highx_int; l++) {
+               for(l = lowx_int+1; l < highx_int; l++) {
                    temp += group_size;
-                   for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * y_percent;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLubyte)(*(temp_index)) * y_percent;
                    }
-               }
+               }
                temp += group_size;
                right = temp;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
 
-                /* calculate the value for pixels in the last row */           
+               /* calculate the value for pixels in the last row */            
                y_percent = highy_float;
                percent = y_percent * (1-lowx_float);
                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * y_percent;
-                    }
-                }
-                temp += group_size;
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLubyte)(*(temp_index)) * y_percent;
+                   }
+               }
+               temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
 
 
-                /* calculate the value for pixels in the 1st and last column */
+               /* calculate the value for pixels in the 1st and last column */
                for(m = lowy_int+1; m < highy_int; m++) {
                    left += ysize;
                    right += ysize;
-                    for (k = 0; k < components; 
-                        k++, left += element_size, right += element_size) {
-                        totals[k] += (GLubyte)(*(left))*(1-lowx_float)
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       totals[k] += (GLubyte)(*(left))*(1-lowx_float)
                                +(GLubyte)(*(right))*highx_float;
                    }
                }
@@ -1489,68 +1489,68 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
                x_percent = highx_float - lowx_float;
                percent = (1-lowy_float)*x_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-               }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
                for(m = lowy_int+1; m < highy_int; m++) {
                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * x_percent;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLubyte)(*(temp_index)) * x_percent;
                    }
                }
                percent = x_percent * highy_float;
                temp += ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
            } else if (highx_int > lowx_int) {
                y_percent = highy_float - lowy_float;
                percent = (1-lowx_float)*y_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * y_percent;
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLubyte)(*(temp_index)) * y_percent;
                    }
                }
                temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
                }
            } else {
                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLubyte)(*(temp_index)) * percent;
+               }
            }
 
 
 
-            /* this is for the pixels in the body */
+           /* this is for the pixels in the body */
            temp0 = (const char *)datain + xindex + group_size +
                 (lowy_int+1)*ysize;
            for (m = lowy_int+1; m < highy_int; m++) {
                temp = temp0;
                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLubyte)(*(temp_index));
-                    }
-                    temp += group_size;
-                }
-               temp0 += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLubyte)(*(temp_index));
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
            }
 
            outindex = (j + (i * widthout)) * components;
@@ -1561,7 +1561,7 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
            lowx_int = highx_int;
            lowx_float = highx_float;
            highx_int += convx_int;
-           highx_float += convx_float;
+           highx_float += convx_float;
            if(highx_float > 1) {
                highx_float -= 1.0;
                highx_int++;
@@ -1578,9 +1578,9 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
     }
 }
 
-static void scale_internal_byte(GLint components, GLint widthin, 
-                          GLint heightin, const GLbyte *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal_byte(GLint components, GLint widthin,
+                          GLint heightin, const GLbyte *datain,
+                          GLint widthout, GLint heightout,
                           GLbyte *dataout, GLint element_size,
                           GLint ysize, GLint group_size)
 {
@@ -1605,8 +1605,8 @@ static void scale_internal_byte(GLint components, GLint widthin,
     const char *left, *right;
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-       halveImage_byte(components, widthin, heightin, 
-       (const GLbyte *)datain, (GLbyte *)dataout, 
+       halveImage_byte(components, widthin, heightin,
+       (const GLbyte *)datain, (GLbyte *)dataout,
        element_size, ysize, group_size);
        return;
     }
@@ -1616,7 +1616,7 @@ static void scale_internal_byte(GLint components, GLint widthin,
     convy_float = convy - convy_int;
     convx_int = floor(convx);
     convx_float = convx - convx_int;
-   
+
     area = convx * convy;
 
     lowy_int = 0;
@@ -1639,63 +1639,63 @@ static void scale_internal_byte(GLint components, GLint widthin,
            */
            totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
 
-            /* calculate the value for pixels in the 1st row */
+           /* calculate the value for pixels in the 1st row */
            xindex = lowx_int*group_size;
            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
 
                y_percent = 1-lowy_float;
-               temp = (const char *)datain + xindex + lowy_int * ysize;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
                percent = y_percent * (1-lowx_float);
-               for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-               }
+               }
                left = temp;
-               for(l = lowx_int+1; l < highx_int; l++) {
+               for(l = lowx_int+1; l < highx_int; l++) {
                    temp += group_size;
-                   for (k = 0, temp_index = temp; k < components; 
+                   for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * y_percent;
+                       totals[k] += (GLbyte)(*(temp_index)) * y_percent;
                    }
-               }
+               }
                temp += group_size;
                right = temp;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
 
-                /* calculate the value for pixels in the last row */           
+               /* calculate the value for pixels in the last row */            
                y_percent = highy_float;
                percent = y_percent * (1-lowx_float);
                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * y_percent;
-                    }
-                }
-                temp += group_size;
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLbyte)(*(temp_index)) * y_percent;
+                   }
+               }
+               temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
 
 
-                /* calculate the value for pixels in the 1st and last column */
+               /* calculate the value for pixels in the 1st and last column */
                for(m = lowy_int+1; m < highy_int; m++) {
                    left += ysize;
                    right += ysize;
-                    for (k = 0; k < components; 
-                        k++, left += element_size, right += element_size) {
-                        totals[k] += (GLbyte)(*(left))*(1-lowx_float)
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       totals[k] += (GLbyte)(*(left))*(1-lowx_float)
                                +(GLbyte)(*(right))*highx_float;
                    }
                }
@@ -1703,68 +1703,68 @@ static void scale_internal_byte(GLint components, GLint widthin,
                x_percent = highx_float - lowx_float;
                percent = (1-lowy_float)*x_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-               }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
                for(m = lowy_int+1; m < highy_int; m++) {
                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * x_percent;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLbyte)(*(temp_index)) * x_percent;
                    }
                }
                percent = x_percent * highy_float;
                temp += ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
            } else if (highx_int > lowx_int) {
                y_percent = highy_float - lowy_float;
                percent = (1-lowx_float)*y_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * y_percent;
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       totals[k] += (GLbyte)(*(temp_index)) * y_percent;
                    }
                }
                temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
                }
            } else {
                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index)) * percent;
-                }
+                       totals[k] += (GLbyte)(*(temp_index)) * percent;
+               }
            }
 
 
 
-            /* this is for the pixels in the body */
-           temp0 = (const char *)datain + xindex + group_size + 
+           /* this is for the pixels in the body */
+           temp0 = (const char *)datain + xindex + group_size +
                (lowy_int+1)*ysize;
            for (m = lowy_int+1; m < highy_int; m++) {
                temp = temp0;
                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components; 
+                   for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                        totals[k] += (GLbyte)(*(temp_index));
-                    }
-                    temp += group_size;
-                }
-               temp0 += ysize;
+                       totals[k] += (GLbyte)(*(temp_index));
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
            }
 
            outindex = (j + (i * widthout)) * components;
@@ -1775,7 +1775,7 @@ static void scale_internal_byte(GLint components, GLint widthin,
            lowx_int = highx_int;
            lowx_float = highx_float;
            highx_int += convx_int;
-           highx_float += convx_float;
+           highx_float += convx_float;
            if(highx_float > 1) {
                highx_float -= 1.0;
                highx_int++;
@@ -1792,9 +1792,9 @@ static void scale_internal_byte(GLint components, GLint widthin,
     }
 }
 
-static void scale_internal_ushort(GLint components, GLint widthin, 
-                          GLint heightin, const GLushort *datain, 
-                          GLint widthout, GLint heightout, 
+static void scale_internal_ushort(GLint components, GLint widthin,
+                          GLint heightin, const GLushort *datain,
+                          GLint widthout, GLint heightout,
                           GLushort *dataout, GLint element_size,
                           GLint ysize, GLint group_size,
                           GLint myswap_bytes)
@@ -1820,8 +1820,8 @@ static void scale_internal_ushort(GLint components, GLint widthin,
     const char *left, *right;
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-       halveImage_ushort(components, widthin, heightin, 
-       (const GLushort *)datain, (GLushort *)dataout, 
+       halveImage_ushort(components, widthin, heightin,
+       (const GLushort *)datain, (GLushort *)dataout,
        element_size, ysize, group_size, myswap_bytes);
        return;
     }
@@ -1831,7 +1831,7 @@ static void scale_internal_ushort(GLint components, GLint widthin,
     convy_float = convy - convy_int;
     convx_int = floor(convx);
     convx_float = convx - convx_int;
-   
+
     area = convx * convy;
 
     lowy_int = 0;
@@ -1858,171 +1858,171 @@ static void scale_internal_ushort(GLint components, GLint widthin,
            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
 
                y_percent = 1-lowy_float;
-               temp = (const char *)datain + xindex + lowy_int * ysize;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
                percent = y_percent * (1-lowx_float);
-               for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
                    if (myswap_bytes) {
                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
                    } else {
-                       totals[k] += *(const GLushort*)temp_index * percent;
+                       totals[k] += *(const GLushort*)temp_index * percent;
                    }
-               }
+               }
                left = temp;
-               for(l = lowx_int+1; l < highx_int; l++) {
+               for(l = lowx_int+1; l < highx_int; l++) {
                    temp += group_size;
-                   for (k = 0, temp_index = temp; k < components; 
+                   for (k = 0, temp_index = temp; k < components;
                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
-                   }
-               }
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
+                   }
+               }
                temp += group_size;
                right = temp;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
-
-               /* calculate the value for pixels in the last row */            
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the last row */            
                y_percent = highy_float;
                percent = y_percent * (1-lowx_float);
                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 
                /* calculate the value for pixels in the 1st and last column */
                for(m = lowy_int+1; m < highy_int; m++) {
                    left += ysize;
                    right += ysize;
-                    for (k = 0; k < components; 
-                        k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                               __GLU_SWAP_2_BYTES(left) * (1-lowx_float) +
-                               __GLU_SWAP_2_BYTES(right) * highx_float;
-                        } else {
-                            totals[k] += *(const GLushort*)left * (1-lowx_float)
-                                       + *(const GLushort*)right * highx_float;
-                        }
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                               __GLU_SWAP_2_BYTES(left) * (1-lowx_float) +
+                               __GLU_SWAP_2_BYTES(right) * highx_float;
+                       } else {
+                           totals[k] += *(const GLushort*)left * (1-lowx_float)
+                                      + *(const GLushort*)right * highx_float;
+                       }
                    }
                }
            } else if (highy_int > lowy_int) {
                x_percent = highx_float - lowx_float;
                percent = (1-lowy_float)*x_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-               }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
                for(m = lowy_int+1; m < highy_int; m++) {
                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
                                __GLU_SWAP_2_BYTES(temp_index) * x_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * x_percent;
-                        }
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * x_percent;
+                       }
                    }
                }
                percent = x_percent * highy_float;
                temp += ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
            } else if (highx_int > lowx_int) {
                y_percent = highy_float - lowy_float;
                percent = (1-lowx_float)*y_percent;
                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                               __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                               __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
                    }
                }
                temp += group_size;
                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
                }
            } else {
                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
            }
 
            /* this is for the pixels in the body */
@@ -2031,17 +2031,17 @@ static void scale_internal_ushort(GLint components, GLint widthin,
            for (m = lowy_int+1; m < highy_int; m++) {
                temp = temp0;
                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += __GLU_SWAP_2_BYTES(temp_index);
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index;
-                        }
-                    }
-                    temp += group_size;
-                }
-               temp0 += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] += __GLU_SWAP_2_BYTES(temp_index);
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index;
+                       }
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
            }
 
            outindex = (j + (i * widthout)) * components;
@@ -2052,7 +2052,7 @@ static void scale_internal_ushort(GLint components, GLint widthin,
            lowx_int = highx_int;
            lowx_float = highx_float;
            highx_int += convx_int;
-           highx_float += convx_float;
+           highx_float += convx_float;
            if(highx_float > 1) {
                highx_float -= 1.0;
                highx_int++;
@@ -2070,11 +2070,11 @@ static void scale_internal_ushort(GLint components, GLint widthin,
 }
 
 static void scale_internal_short(GLint components, GLint widthin,
-                           GLint heightin, const GLshort *datain,
-                           GLint widthout, GLint heightout,
-                           GLshort *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes)
+                          GLint heightin, const GLshort *datain,
+                          GLint widthout, GLint heightout,
+                          GLshort *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes)
 {
     float convx;
     float convy;
@@ -2099,10 +2099,10 @@ static void scale_internal_short(GLint components, GLint widthin,
     GLushort swapbuf;  /* unsigned buffer */
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-        halveImage_short(components, widthin, heightin,
-        (const GLshort *)datain, (GLshort *)dataout,
-        element_size, ysize, group_size, myswap_bytes);
-        return;
+       halveImage_short(components, widthin, heightin,
+       (const GLshort *)datain, (GLshort *)dataout,
+       element_size, ysize, group_size, myswap_bytes);
+       return;
     }
     convy = (float) heightin/heightout;
     convx = (float) widthin/widthout;
@@ -2119,253 +2119,253 @@ static void scale_internal_short(GLint components, GLint widthin,
     highy_float = convy_float;
 
     for (i = 0; i < heightout; i++) {
-        lowx_int = 0;
-        lowx_float = 0;
-        highx_int = convx_int;
-        highx_float = convx_float;
-
-        for (j = 0; j < widthout; j++) {
-            /*
-            ** Ok, now apply box filter to box that goes from (lowx, lowy)
-            ** to (highx, highy) on input data into this pixel on output
-            ** data.
-            */
-            totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
-
-            /* calculate the value for pixels in the 1st row */
-            xindex = lowx_int*group_size;
-            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
-
-                y_percent = 1-lowy_float;
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                percent = y_percent * (1-lowx_float);
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+       lowx_int = 0;
+       lowx_float = 0;
+       highx_int = convx_int;
+       highx_float = convx_float;
+
+       for (j = 0; j < widthout; j++) {
+           /*
+           ** Ok, now apply box filter to box that goes from (lowx, lowy)
+           ** to (highx, highy) on input data into this pixel on output
+           ** data.
+           */
+           totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
+
+           /* calculate the value for pixels in the 1st row */
+           xindex = lowx_int*group_size;
+           if((highy_int>lowy_int) && (highx_int>lowx_int)) {
+
+               y_percent = 1-lowy_float;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               percent = y_percent * (1-lowx_float);
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-                left = temp;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+               left = temp;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                            totals[k] += *(const GLshort*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLshort*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                right = temp;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLshort*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLshort*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               right = temp;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the last row */
-                y_percent = highy_float;
-                percent = y_percent * (1-lowx_float);
-                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the last row */
+               y_percent = highy_float;
+               percent = y_percent * (1-lowx_float);
+               temp = (const char *)datain + xindex + highy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                            totals[k] += *(const GLshort*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLshort*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLshort*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLshort*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the 1st and last column */
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    left += ysize;
-                    right += ysize;
-                    for (k = 0; k < components;
-                         k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the 1st and last column */
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   left += ysize;
+                   right += ysize;
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(left);
-                            totals[k] += *(const GLshort*)&swapbuf * (1-lowx_float);
+                           totals[k] += *(const GLshort*)&swapbuf * (1-lowx_float);
                            swapbuf = __GLU_SWAP_2_BYTES(right);
                            totals[k] += *(const GLshort*)&swapbuf * highx_float;
-                        } else {
-                            totals[k] += *(const GLshort*)left * (1-lowx_float)
-                                       + *(const GLshort*)right * highx_float;
-                        }
-                    }
-                }
-            } else if (highy_int > lowy_int) {
-                x_percent = highx_float - lowx_float;
-                percent = (1-lowy_float)*x_percent;
-                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       } else {
+                           totals[k] += *(const GLshort*)left * (1-lowx_float)
+                                      + *(const GLshort*)right * highx_float;
+                       }
+                   }
+               }
+           } else if (highy_int > lowy_int) {
+               x_percent = highx_float - lowx_float;
+               percent = (1-lowy_float)*x_percent;
+               temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   temp += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                            totals[k] += *(const GLshort*)&swapbuf * x_percent;
-                        } else {
-                            totals[k] += *(const GLshort*)temp_index * x_percent;
-                        }
-                    }
-                }
-                percent = x_percent * highy_float;
-                temp += ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLshort*)&swapbuf * x_percent;
+                       } else {
+                           totals[k] += *(const GLshort*)temp_index * x_percent;
+                       }
+                   }
+               }
+               percent = x_percent * highy_float;
+               temp += ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-            } else if (highx_int > lowx_int) {
-                y_percent = highy_float - lowy_float;
-                percent = (1-lowx_float)*y_percent;
-   
-             temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+           } else if (highx_int > lowx_int) {
+               y_percent = highy_float - lowy_float;
+               percent = (1-lowx_float)*y_percent;
+
+            temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+               for (l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                            totals[k] += *(const GLshort*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLshort*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLshort*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLshort*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-            } else {
-                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+           } else {
+               percent = (highy_float-lowy_float)*(highx_float-lowx_float);
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                        totals[k] += *(const GLshort*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLshort*)temp_index * percent;
-                    }
-                }
-            }
-
-            /* this is for the pixels in the body */
-            temp0 = (const char *)datain + xindex + group_size +
+                       totals[k] += *(const GLshort*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLshort*)temp_index * percent;
+                   }
+               }
+           }
+
+           /* this is for the pixels in the body */
+           temp0 = (const char *)datain + xindex + group_size +
                 (lowy_int+1)*ysize;
-            for (m = lowy_int+1; m < highy_int; m++) {
-                temp = temp0;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+           for (m = lowy_int+1; m < highy_int; m++) {
+               temp = temp0;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_2_BYTES(temp_index);
-                            totals[k] += *(const GLshort*)&swapbuf; 
-                        } else {
-                            totals[k] += *(const GLshort*)temp_index;
-                        }
-                    }
-                    temp += group_size;
-                }
-                temp0 += ysize;
-            }
-
-            outindex = (j + (i * widthout)) * components;
-            for (k = 0; k < components; k++) {
-                dataout[outindex + k] = totals[k]/area;
-                /*printf("totals[%d] = %f\n", k, totals[k]);*/
-            }
-            lowx_int = highx_int;
-            lowx_float = highx_float;
-            highx_int += convx_int;
-            highx_float += convx_float;
-            if(highx_float > 1) {
-                highx_float -= 1.0;
-                highx_int++;
-            }
-        }
-        lowy_int = highy_int;
-        lowy_float = highy_float;
-        highy_int += convy_int;
-        highy_float += convy_float;
-        if(highy_float > 1) {
-            highy_float -= 1.0;
-            highy_int++;
-        }
+                           totals[k] += *(const GLshort*)&swapbuf;
+                       } else {
+                           totals[k] += *(const GLshort*)temp_index;
+                       }
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
+           }
+
+           outindex = (j + (i * widthout)) * components;
+           for (k = 0; k < components; k++) {
+               dataout[outindex + k] = totals[k]/area;
+               /*printf("totals[%d] = %f\n", k, totals[k]);*/
+           }
+           lowx_int = highx_int;
+           lowx_float = highx_float;
+           highx_int += convx_int;
+           highx_float += convx_float;
+           if(highx_float > 1) {
+               highx_float -= 1.0;
+               highx_int++;
+           }
+       }
+       lowy_int = highy_int;
+       lowy_float = highy_float;
+       highy_int += convy_int;
+       highy_float += convy_float;
+       if(highy_float > 1) {
+           highy_float -= 1.0;
+           highy_int++;
+       }
     }
 }
 
 static void scale_internal_uint(GLint components, GLint widthin,
-                           GLint heightin, const GLuint *datain,
-                           GLint widthout, GLint heightout,
-                           GLuint *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes)
+                          GLint heightin, const GLuint *datain,
+                          GLint widthout, GLint heightout,
+                          GLuint *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes)
 {
     float convx;
     float convy;
@@ -2388,10 +2388,10 @@ static void scale_internal_uint(GLint components, GLint widthin,
     const char *left, *right;
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-        halveImage_uint(components, widthin, heightin,
-        (const GLuint *)datain, (GLuint *)dataout,
-        element_size, ysize, group_size, myswap_bytes);
-        return;
+       halveImage_uint(components, widthin, heightin,
+       (const GLuint *)datain, (GLuint *)dataout,
+       element_size, ysize, group_size, myswap_bytes);
+       return;
     }
     convy = (float) heightin/heightout;
     convx = (float) widthin/widthout;
@@ -2407,249 +2407,542 @@ static void scale_internal_uint(GLint components, GLint widthin,
     highy_int = convy_int;
     highy_float = convy_float;
 
-    for (i = 0; i < heightout; i++) {
-        lowx_int = 0;
-        lowx_float = 0;
-        highx_int = convx_int;
-        highx_float = convx_float;
-
-        for (j = 0; j < widthout; j++) {
-            /*
-            ** Ok, now apply box filter to box that goes from (lowx, lowy)
-            ** to (highx, highy) on input data into this pixel on output
-            ** data.
-            */
-            totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
-
-            /* calculate the value for pixels in the 1st row */
-            xindex = lowx_int*group_size;
-            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
-
-                y_percent = 1-lowy_float;
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                percent = y_percent * (1-lowx_float);
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-                left = temp;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_4_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLuint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                right = temp;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the last row */
-                y_percent = highy_float;
-                percent = y_percent * (1-lowx_float);
-                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_4_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLuint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the 1st and last column */
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    left += ysize;
-                    right += ysize;
-                    for (k = 0; k < components;
-                         k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] +=
-                                __GLU_SWAP_4_BYTES(left) * (1-lowx_float)
-                              + __GLU_SWAP_4_BYTES(right) * highx_float;
-                        } else {
-                            totals[k] += *(const GLuint*)left * (1-lowx_float)
-                                       + *(const GLuint*)right * highx_float;
-                        }
-                    }
-                }
-            } else if (highy_int > lowy_int) {
-                x_percent = highx_float - lowx_float;
-                percent = (1-lowy_float)*x_percent;
-                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_4_BYTES(temp_index) * x_percent;
-                        } else {
-                            totals[k] += *(const GLuint*)temp_index * x_percent;
-                        }
-                    }
-                }
-                percent = x_percent * highy_float;
-                temp += ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-            } else if (highx_int > lowx_int) {
-                y_percent = highy_float - lowy_float;
-                percent = (1-lowx_float)*y_percent;
-   
-             temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_4_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLuint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-            } else {
-                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLuint*)temp_index * percent;
-                    }
-                }
-            }
-
-            /* this is for the pixels in the body */
-            temp0 = (const char *)datain + xindex + group_size +
+    for (i = 0; i < heightout; i++) {
+       lowx_int = 0;
+       lowx_float = 0;
+       highx_int = convx_int;
+       highx_float = convx_float;
+
+       for (j = 0; j < widthout; j++) {
+           /*
+           ** Ok, now apply box filter to box that goes from (lowx, lowy)
+           ** to (highx, highy) on input data into this pixel on output
+           ** data.
+           */
+           totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
+
+           /* calculate the value for pixels in the 1st row */
+           xindex = lowx_int*group_size;
+           if((highy_int>lowy_int) && (highx_int>lowx_int)) {
+
+               y_percent = 1-lowy_float;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               percent = y_percent * (1-lowx_float);
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+               left = temp;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_4_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLuint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               right = temp;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the last row */
+               y_percent = highy_float;
+               percent = y_percent * (1-lowx_float);
+               temp = (const char *)datain + xindex + highy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_4_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLuint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the 1st and last column */
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   left += ysize;
+                   right += ysize;
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                               __GLU_SWAP_4_BYTES(left) * (1-lowx_float)
+                             + __GLU_SWAP_4_BYTES(right) * highx_float;
+                       } else {
+                           totals[k] += *(const GLuint*)left * (1-lowx_float)
+                                      + *(const GLuint*)right * highx_float;
+                       }
+                   }
+               }
+           } else if (highy_int > lowy_int) {
+               x_percent = highx_float - lowx_float;
+               percent = (1-lowy_float)*x_percent;
+               temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   temp += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_4_BYTES(temp_index) * x_percent;
+                       } else {
+                           totals[k] += *(const GLuint*)temp_index * x_percent;
+                       }
+                   }
+               }
+               percent = x_percent * highy_float;
+               temp += ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+           } else if (highx_int > lowx_int) {
+               y_percent = highy_float - lowy_float;
+               percent = (1-lowx_float)*y_percent;
+
+            temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+               for (l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_4_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLuint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+           } else {
+               percent = (highy_float-lowy_float)*(highx_float-lowx_float);
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_4_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLuint*)temp_index * percent;
+                   }
+               }
+           }
+
+           /* this is for the pixels in the body */
+           temp0 = (const char *)datain + xindex + group_size +
+                (lowy_int+1)*ysize;
+           for (m = lowy_int+1; m < highy_int; m++) {
+               temp = temp0;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] += __GLU_SWAP_4_BYTES(temp_index);
+                       } else {
+                           totals[k] += *(const GLuint*)temp_index;
+                       }
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
+           }
+
+           outindex = (j + (i * widthout)) * components;
+           for (k = 0; k < components; k++) {
+               /* clamp at UINT_MAX */
+               float value= totals[k]/area;
+               if (value >= (float) UINT_MAX) {        /* need '=' */
+                 dataout[outindex + k] = UINT_MAX;
+               }
+               else dataout[outindex + k] = value;
+           }
+           lowx_int = highx_int;
+           lowx_float = highx_float;
+           highx_int += convx_int;
+           highx_float += convx_float;
+           if(highx_float > 1) {
+               highx_float -= 1.0;
+               highx_int++;
+           }
+       }
+       lowy_int = highy_int;
+       lowy_float = highy_float;
+       highy_int += convy_int;
+       highy_float += convy_float;
+       if(highy_float > 1) {
+           highy_float -= 1.0;
+           highy_int++;
+       }
+    }
+}
+
+
+
+static void scale_internal_int(GLint components, GLint widthin,
+                          GLint heightin, const GLint *datain,
+                          GLint widthout, GLint heightout,
+                          GLint *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes)
+{
+    float convx;
+    float convy;
+    float percent;
+    /* Max components in a format is 4, so... */
+    float totals[4];
+    float area;
+    int i,j,k,xindex;
+
+    const char *temp, *temp0;
+    const char *temp_index;
+    int outindex;
+
+    int lowx_int, highx_int, lowy_int, highy_int;
+    float x_percent, y_percent;
+    float lowx_float, highx_float, lowy_float, highy_float;
+    float convy_float, convx_float;
+    int convy_int, convx_int;
+    int l, m;
+    const char *left, *right;
+
+    GLuint swapbuf;    /* unsigned buffer */
+
+    if (widthin == widthout*2 && heightin == heightout*2) {
+       halveImage_int(components, widthin, heightin,
+       (const GLint *)datain, (GLint *)dataout,
+       element_size, ysize, group_size, myswap_bytes);
+       return;
+    }
+    convy = (float) heightin/heightout;
+    convx = (float) widthin/widthout;
+    convy_int = floor(convy);
+    convy_float = convy - convy_int;
+    convx_int = floor(convx);
+    convx_float = convx - convx_int;
+
+    area = convx * convy;
+
+    lowy_int = 0;
+    lowy_float = 0;
+    highy_int = convy_int;
+    highy_float = convy_float;
+
+    for (i = 0; i < heightout; i++) {
+       lowx_int = 0;
+       lowx_float = 0;
+       highx_int = convx_int;
+       highx_float = convx_float;
+
+       for (j = 0; j < widthout; j++) {
+           /*
+           ** Ok, now apply box filter to box that goes from (lowx, lowy)
+           ** to (highx, highy) on input data into this pixel on output
+           ** data.
+           */
+           totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
+
+           /* calculate the value for pixels in the 1st row */
+           xindex = lowx_int*group_size;
+           if((highy_int>lowy_int) && (highx_int>lowx_int)) {
+
+               y_percent = 1-lowy_float;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               percent = y_percent * (1-lowx_float);
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+               left = temp;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                           totals[k] += *(const GLint*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               right = temp;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the last row */
+               y_percent = highy_float;
+               percent = y_percent * (1-lowx_float);
+               temp = (const char *)datain + xindex + highy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf  * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                           totals[k] += *(const GLint*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the 1st and last column */
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   left += ysize;
+                   right += ysize;
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(left);
+                           totals[k] += *(const GLint*)&swapbuf * (1-lowx_float);
+                           swapbuf = __GLU_SWAP_4_BYTES(right);
+                           totals[k] += *(const GLint*)&swapbuf * highx_float;
+                       } else {
+                           totals[k] += *(const GLint*)left * (1-lowx_float)
+                                      + *(const GLint*)right * highx_float;
+                       }
+                   }
+               }
+           } else if (highy_int > lowy_int) {
+               x_percent = highx_float - lowx_float;
+               percent = (1-lowy_float)*x_percent;
+               temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   temp += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                           totals[k] += *(const GLint*)&swapbuf * x_percent;
+                       } else {
+                           totals[k] += *(const GLint*)temp_index * x_percent;
+                       }
+                   }
+               }
+               percent = x_percent * highy_float;
+               temp += ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+           } else if (highx_int > lowx_int) {
+               y_percent = highy_float - lowy_float;
+               percent = (1-lowx_float)*y_percent;
+
+                temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+               for (l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                           totals[k] += *(const GLint*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLint*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+           } else {
+               percent = (highy_float-lowy_float)*(highx_float-lowx_float);
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
+                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                       totals[k] += *(const GLint*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLint*)temp_index * percent;
+                   }
+               }
+           }
+
+           /* this is for the pixels in the body */
+           temp0 = (const char *)datain + xindex + group_size +
                 (lowy_int+1)*ysize;
-            for (m = lowy_int+1; m < highy_int; m++) {
-                temp = temp0;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += __GLU_SWAP_4_BYTES(temp_index);
-                        } else {
-                            totals[k] += *(const GLuint*)temp_index;
-                        }
-                    }
-                    temp += group_size;
-                }
-                temp0 += ysize;
-            }
-
-            outindex = (j + (i * widthout)) * components;
-            for (k = 0; k < components; k++) {
-               /* clamp at UINT_MAX */
-               float value= totals[k]/area;
-               if (value >= (float) UINT_MAX) {        /* need '=' */
-                 dataout[outindex + k] = UINT_MAX;
+           for (m = lowy_int+1; m < highy_int; m++) {
+               temp = temp0;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           swapbuf = __GLU_SWAP_4_BYTES(temp_index);
+                           totals[k] += *(const GLint*)&swapbuf;
+                       } else {
+                           totals[k] += *(const GLint*)temp_index;
+                       }
+                   }
+                   temp += group_size;
                }
-                else dataout[outindex + k] = value;
+               temp0 += ysize;
+           }
+
+           outindex = (j + (i * widthout)) * components;
+           for (k = 0; k < components; k++) {
+               dataout[outindex + k] = totals[k]/area;
+               /*printf("totals[%d] = %f\n", k, totals[k]);*/
            }
-            lowx_int = highx_int;
-            lowx_float = highx_float;
-            highx_int += convx_int;
-            highx_float += convx_float;
-            if(highx_float > 1) {
-                highx_float -= 1.0;
-                highx_int++;
-            }
-        }
-        lowy_int = highy_int;
-        lowy_float = highy_float;
-        highy_int += convy_int;
-        highy_float += convy_float;
-        if(highy_float > 1) {
-            highy_float -= 1.0;
-            highy_int++;
-        }
+           lowx_int = highx_int;
+           lowx_float = highx_float;
+           highx_int += convx_int;
+           highx_float += convx_float;
+           if(highx_float > 1) {
+               highx_float -= 1.0;
+               highx_int++;
+           }
+       }
+       lowy_int = highy_int;
+       lowy_float = highy_float;
+       highy_int += convy_int;
+       highy_float += convy_float;
+       if(highy_float > 1) {
+           highy_float -= 1.0;
+           highy_int++;
+       }
     }
 }
 
 
 
-static void scale_internal_int(GLint components, GLint widthin,
-                           GLint heightin, const GLint *datain,
-                           GLint widthout, GLint heightout,
-                           GLint *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes)
+static void scale_internal_float(GLint components, GLint widthin,
+                          GLint heightin, const GLfloat *datain,
+                          GLint widthout, GLint heightout,
+                          GLfloat *dataout, GLint element_size,
+                          GLint ysize, GLint group_size,
+                          GLint myswap_bytes)
 {
     float convx;
     float convy;
@@ -2674,10 +2967,10 @@ static void scale_internal_int(GLint components, GLint widthin,
     GLuint swapbuf;    /* unsigned buffer */
 
     if (widthin == widthout*2 && heightin == heightout*2) {
-        halveImage_int(components, widthin, heightin,
-        (const GLint *)datain, (GLint *)dataout,
-        element_size, ysize, group_size, myswap_bytes);
-        return;
+       halveImage_float(components, widthin, heightin,
+       (const GLfloat *)datain, (GLfloat *)dataout,
+       element_size, ysize, group_size, myswap_bytes);
+       return;
     }
     convy = (float) heightin/heightout;
     convx = (float) widthin/widthout;
@@ -2694,537 +2987,244 @@ static void scale_internal_int(GLint components, GLint widthin,
     highy_float = convy_float;
 
     for (i = 0; i < heightout; i++) {
-        lowx_int = 0;
-        lowx_float = 0;
-        highx_int = convx_int;
-        highx_float = convx_float;
-
-        for (j = 0; j < widthout; j++) {
-            /*
-            ** Ok, now apply box filter to box that goes from (lowx, lowy)
-            ** to (highx, highy) on input data into this pixel on output
-            ** data.
-            */
-            totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
-
-            /* calculate the value for pixels in the 1st row */
-            xindex = lowx_int*group_size;
-            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
-
-                y_percent = 1-lowy_float;
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                percent = y_percent * (1-lowx_float);
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                       swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-                left = temp;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLint*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                right = temp;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the last row */
-                y_percent = highy_float;
-                percent = y_percent * (1-lowx_float);
-                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf  * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLint*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the 1st and last column */
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    left += ysize;
-                    right += ysize;
-                    for (k = 0; k < components;
-                         k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(left);
-                            totals[k] += *(const GLint*)&swapbuf * (1-lowx_float);
-                            swapbuf = __GLU_SWAP_4_BYTES(right);
-                            totals[k] += *(const GLint*)&swapbuf * highx_float;
-                        } else {
-                            totals[k] += *(const GLint*)left * (1-lowx_float)
-                                       + *(const GLint*)right * highx_float;
-                        }
-                    }
-                }
-            } else if (highy_int > lowy_int) {
-                x_percent = highx_float - lowx_float;
-                percent = (1-lowy_float)*x_percent;
-                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLint*)&swapbuf * x_percent;
-                        } else {
-                            totals[k] += *(const GLint*)temp_index * x_percent;
-                        }
-                    }
-                }
-                percent = x_percent * highy_float;
-                temp += ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-            } else if (highx_int > lowx_int) {
-                y_percent = highy_float - lowy_float;
-                percent = (1-lowx_float)*y_percent;
-   
-                 temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLint*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLint*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-            } else {
-                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLint*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLint*)temp_index * percent;
-                    }
-                }
-            }
-
-            /* this is for the pixels in the body */
-            temp0 = (const char *)datain + xindex + group_size +
-                (lowy_int+1)*ysize;
-            for (m = lowy_int+1; m < highy_int; m++) {
-                temp = temp0;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLint*)&swapbuf;
-                        } else {
-                            totals[k] += *(const GLint*)temp_index;
-                        }
-                    }
-                    temp += group_size;
-                }
-                temp0 += ysize;
-            }
-
-            outindex = (j + (i * widthout)) * components;
-            for (k = 0; k < components; k++) {
-                dataout[outindex + k] = totals[k]/area;
-                /*printf("totals[%d] = %f\n", k, totals[k]);*/
-            }
-            lowx_int = highx_int;
-            lowx_float = highx_float;
-            highx_int += convx_int;
-            highx_float += convx_float;
-            if(highx_float > 1) {
-                highx_float -= 1.0;
-                highx_int++;
-            }
-        }
-        lowy_int = highy_int;
-        lowy_float = highy_float;
-        highy_int += convy_int;
-        highy_float += convy_float;
-        if(highy_float > 1) {
-            highy_float -= 1.0;
-            highy_int++;
-        }
-    }
-}
-
-
-
-static void scale_internal_float(GLint components, GLint widthin,
-                           GLint heightin, const GLfloat *datain,
-                           GLint widthout, GLint heightout,
-                           GLfloat *dataout, GLint element_size,
-                           GLint ysize, GLint group_size,
-                           GLint myswap_bytes)
-{
-    float convx;
-    float convy;
-    float percent;
-    /* Max components in a format is 4, so... */
-    float totals[4];
-    float area;
-    int i,j,k,xindex;
-
-    const char *temp, *temp0;
-    const char *temp_index;
-    int outindex;
-
-    int lowx_int, highx_int, lowy_int, highy_int;
-    float x_percent, y_percent;
-    float lowx_float, highx_float, lowy_float, highy_float;
-    float convy_float, convx_float;
-    int convy_int, convx_int;
-    int l, m;
-    const char *left, *right;
-
-    GLuint swapbuf;    /* unsigned buffer */
-
-    if (widthin == widthout*2 && heightin == heightout*2) {
-        halveImage_float(components, widthin, heightin,
-        (const GLfloat *)datain, (GLfloat *)dataout,
-        element_size, ysize, group_size, myswap_bytes);
-        return;
-    }
-    convy = (float) heightin/heightout;
-    convx = (float) widthin/widthout;
-    convy_int = floor(convy);
-    convy_float = convy - convy_int;
-    convx_int = floor(convx);
-    convx_float = convx - convx_int;
+       lowx_int = 0;
+       lowx_float = 0;
+       highx_int = convx_int;
+       highx_float = convx_float;
 
-    area = convx * convy;
+       for (j = 0; j < widthout; j++) {
+           /*
+           ** Ok, now apply box filter to box that goes from (lowx, lowy)
+           ** to (highx, highy) on input data into this pixel on output
+           ** data.
+           */
+           totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
 
-    lowy_int = 0;
-    lowy_float = 0;
-    highy_int = convy_int;
-    highy_float = convy_float;
+           /* calculate the value for pixels in the 1st row */
+           xindex = lowx_int*group_size;
+           if((highy_int>lowy_int) && (highx_int>lowx_int)) {
 
-    for (i = 0; i < heightout; i++) {
-        lowx_int = 0;
-        lowx_float = 0;
-        highx_int = convx_int;
-        highx_float = convx_float;
-
-        for (j = 0; j < widthout; j++) {
-            /*
-            ** Ok, now apply box filter to box that goes from (lowx, lowy)
-            ** to (highx, highy) on input data into this pixel on output
-            ** data.
-            */
-            totals[0] = totals[1] = totals[2] = totals[3] = 0.0;
-
-            /* calculate the value for pixels in the 1st row */
-            xindex = lowx_int*group_size;
-            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
-
-                y_percent = 1-lowy_float;
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                percent = y_percent * (1-lowx_float);
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+               y_percent = 1-lowy_float;
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               percent = y_percent * (1-lowx_float);
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-                left = temp;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+               left = temp;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLfloat*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLfloat*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                right = temp;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLfloat*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               right = temp;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the last row */
-                y_percent = highy_float;
-                percent = y_percent * (1-lowx_float);
-                temp = (const char *)datain + xindex + highy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the last row */
+               y_percent = highy_float;
+               percent = y_percent * (1-lowx_float);
+               temp = (const char *)datain + xindex + highy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLfloat*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLfloat*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLfloat*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-
-                /* calculate the value for pixels in the 1st and last column */
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    left += ysize;
-                    right += ysize;
-                    for (k = 0; k < components;
-                         k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+
+               /* calculate the value for pixels in the 1st and last column */
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   left += ysize;
+                   right += ysize;
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(left);
-                            totals[k] += *(const GLfloat*)&swapbuf * (1-lowx_float);
-                            swapbuf = __GLU_SWAP_4_BYTES(right);
-                            totals[k] += *(const GLfloat*)&swapbuf * highx_float;
-                        } else {
-                            totals[k] += *(const GLfloat*)left * (1-lowx_float)
-                                       + *(const GLfloat*)right * highx_float;
-                        }
-                    }
-                }
-            } else if (highy_int > lowy_int) {
-                x_percent = highx_float - lowx_float;
-                percent = (1-lowy_float)*x_percent;
-                temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLfloat*)&swapbuf * (1-lowx_float);
+                           swapbuf = __GLU_SWAP_4_BYTES(right);
+                           totals[k] += *(const GLfloat*)&swapbuf * highx_float;
+                       } else {
+                           totals[k] += *(const GLfloat*)left * (1-lowx_float)
+                                      + *(const GLfloat*)right * highx_float;
+                       }
+                   }
+               }
+           } else if (highy_int > lowy_int) {
+               x_percent = highx_float - lowx_float;
+               percent = (1-lowy_float)*x_percent;
+               temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-                for(m = lowy_int+1; m < highy_int; m++) {
-                    temp += ysize;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+               for(m = lowy_int+1; m < highy_int; m++) {
+                   temp += ysize;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLfloat*)&swapbuf * x_percent;
-                        } else {
-                            totals[k] += *(const GLfloat*)temp_index * x_percent;
-                        }
-                    }
-                }
-                percent = x_percent * highy_float;
-                temp += ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLfloat*)&swapbuf * x_percent;
+                       } else {
+                           totals[k] += *(const GLfloat*)temp_index * x_percent;
+                       }
+                   }
+               }
+               percent = x_percent * highy_float;
+               temp += ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-            } else if (highx_int > lowx_int) {
-                y_percent = highy_float - lowy_float;
-                percent = (1-lowx_float)*y_percent;
-   
-             temp = (const char *)datain + xindex + lowy_int*ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+           } else if (highx_int > lowx_int) {
+               y_percent = highy_float - lowy_float;
+               percent = (1-lowx_float)*y_percent;
+
+            temp = (const char *)datain + xindex + lowy_int*ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += group_size;
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+               for (l = lowx_int+1; l < highx_int; l++) {
+                   temp += group_size;
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLfloat*)&swapbuf * y_percent;
-                        } else {
-                            totals[k] += *(const GLfloat*)temp_index * y_percent;
-                        }
-                    }
-                }
-                temp += group_size;
-                percent = y_percent * highx_float;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                           totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+                       } else {
+                           totals[k] += *(const GLfloat*)temp_index * y_percent;
+                       }
+                   }
+               }
+               temp += group_size;
+               percent = y_percent * highx_float;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-            } else {
-                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
-                temp = (const char *)datain + xindex + lowy_int * ysize;
-                for (k = 0, temp_index = temp; k < components;
-                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+           } else {
+               percent = (highy_float-lowy_float)*(highx_float-lowx_float);
+               temp = (const char *)datain + xindex + lowy_int * ysize;
+               for (k = 0, temp_index = temp; k < components;
+                    k++, temp_index += element_size) {
+                   if (myswap_bytes) {
                        swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                        totals[k] += *(const GLfloat*)&swapbuf * percent;
-                    } else {
-                        totals[k] += *(const GLfloat*)temp_index * percent;
-                    }
-                }
-            }
-
-            /* this is for the pixels in the body */
-            temp0 = (const char *)datain + xindex + group_size +
+                       totals[k] += *(const GLfloat*)&swapbuf * percent;
+                   } else {
+                       totals[k] += *(const GLfloat*)temp_index * percent;
+                   }
+               }
+           }
+
+           /* this is for the pixels in the body */
+           temp0 = (const char *)datain + xindex + group_size +
                 (lowy_int+1)*ysize;
-            for (m = lowy_int+1; m < highy_int; m++) {
-                temp = temp0;
-                for(l = lowx_int+1; l < highx_int; l++) {
-                    for (k = 0, temp_index = temp; k < components;
-                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
+           for (m = lowy_int+1; m < highy_int; m++) {
+               temp = temp0;
+               for(l = lowx_int+1; l < highx_int; l++) {
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
                            swapbuf = __GLU_SWAP_4_BYTES(temp_index);
-                            totals[k] += *(const GLfloat*)&swapbuf;
-                        } else {
-                            totals[k] += *(const GLfloat*)temp_index;
-                        }
-                    }
-                    temp += group_size;
-                }
-                temp0 += ysize;
-            }
-
-            outindex = (j + (i * widthout)) * components;
-            for (k = 0; k < components; k++) {
-                dataout[outindex + k] = totals[k]/area;
-                /*printf("totals[%d] = %f\n", k, totals[k]);*/
-            }
-            lowx_int = highx_int;
-            lowx_float = highx_float;
-            highx_int += convx_int;
-            highx_float += convx_float;
-            if(highx_float > 1) {
-                highx_float -= 1.0;
-                highx_int++;
-            }
-        }
-        lowy_int = highy_int;
-        lowy_float = highy_float;
-        highy_int += convy_int;
-        highy_float += convy_float;
-        if(highy_float > 1) {
-            highy_float -= 1.0;
-            highy_int++;
-        }
+                           totals[k] += *(const GLfloat*)&swapbuf;
+                       } else {
+                           totals[k] += *(const GLfloat*)temp_index;
+                       }
+                   }
+                   temp += group_size;
+               }
+               temp0 += ysize;
+           }
+
+           outindex = (j + (i * widthout)) * components;
+           for (k = 0; k < components; k++) {
+               dataout[outindex + k] = totals[k]/area;
+               /*printf("totals[%d] = %f\n", k, totals[k]);*/
+           }
+           lowx_int = highx_int;
+           lowx_float = highx_float;
+           highx_int += convx_int;
+           highx_float += convx_float;
+           if(highx_float > 1) {
+               highx_float -= 1.0;
+               highx_int++;
+           }
+       }
+       lowy_int = highy_int;
+       lowy_float = highy_float;
+       highy_int += convy_int;
+       highy_float += convy_float;
+       if(highy_float > 1) {
+           highy_float -= 1.0;
+           highy_int++;
+       }
     }
 }
 
@@ -3238,7 +3238,7 @@ static int checkMipmapArgs(GLenum internalFormat, GLenum format, GLenum type)
     }
 
     if (!isLegalFormatForPackedPixelType(format, type)) {
-       return GLU_INVALID_OPERATION; 
+       return GLU_INVALID_OPERATION;
     }
 
     return 0;
@@ -3279,7 +3279,7 @@ static GLboolean legalType(GLenum type)
       case GL_UNSIGNED_INT:
       case GL_FLOAT:
       case GL_UNSIGNED_BYTE_3_3_2:
-      case GL_UNSIGNED_BYTE_2_3_3_REV: 
+      case GL_UNSIGNED_BYTE_2_3_3_REV:  
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
       case GL_UNSIGNED_SHORT_4_4_4_4:
@@ -3290,7 +3290,7 @@ static GLboolean legalType(GLenum type)
       case GL_UNSIGNED_INT_8_8_8_8_REV:
       case GL_UNSIGNED_INT_10_10_10_2:
       case GL_UNSIGNED_INT_2_10_10_10_REV:
-         return GL_TRUE;
+        return GL_TRUE;
       default:
        return GL_FALSE;
     }
@@ -3325,14 +3325,14 @@ static GLboolean isLegalFormatForPackedPixelType(GLenum format, GLenum type)
    if (!isTypePackedPixel(type)) {
       return GL_TRUE;
    }
-   
+
    /* 3_3_2/2_3_3_REV & 5_6_5/5_6_5_REV are only compatible with RGB */
-   if ((type == GL_UNSIGNED_BYTE_3_3_2 || type == GL_UNSIGNED_BYTE_2_3_3_REV|| 
+   if ((type == GL_UNSIGNED_BYTE_3_3_2 || type == GL_UNSIGNED_BYTE_2_3_3_REV||
        type == GL_UNSIGNED_SHORT_5_6_5|| type == GL_UNSIGNED_SHORT_5_6_5_REV)
        && format != GL_RGB)
       return GL_FALSE;
-   
-   /* 4_4_4_4/4_4_4_4_REV & 5_5_5_1/1_5_5_5_REV & 8_8_8_8/8_8_8_8_REV & 
+
+   /* 4_4_4_4/4_4_4_4_REV & 5_5_5_1/1_5_5_5_REV & 8_8_8_8/8_8_8_8_REV &
     * 10_10_10_2/2_10_10_10_REV are only compatible with RGBA, BGRA & ABGR_EXT.
     */
    if ((type == GL_UNSIGNED_SHORT_4_4_4_4 ||
@@ -3343,7 +3343,7 @@ static GLboolean isLegalFormatForPackedPixelType(GLenum format, GLenum type)
        type == GL_UNSIGNED_INT_8_8_8_8_REV ||
        type == GL_UNSIGNED_INT_10_10_10_2 ||
        type == GL_UNSIGNED_INT_2_10_10_10_REV) &&
-       (format != GL_RGBA && 
+       (format != GL_RGBA &&
        format != GL_BGRA)) {
       return GL_FALSE;
    }
@@ -3351,7 +3351,7 @@ static GLboolean isLegalFormatForPackedPixelType(GLenum format, GLenum type)
    return GL_TRUE;
 } /* isLegalFormatForPackedPixelType() */
 
-static GLboolean isLegalLevels(GLint userLevel,GLint baseLevel,GLint maxLevel, 
+static GLboolean isLegalLevels(GLint userLevel,GLint baseLevel,GLint maxLevel,
                               GLint totalLevels)
 {
    if (baseLevel < 0 || baseLevel < userLevel || maxLevel < baseLevel ||
@@ -3362,31 +3362,31 @@ static GLboolean isLegalLevels(GLint userLevel,GLint baseLevel,GLint maxLevel,
 
 /* Given user requested texture size, determine if it fits. If it
  * doesn't then halve both sides and make the determination again
- * until it does fit (for IR only). 
+ * until it does fit (for IR only).
  * Note that proxy textures are not implemented in RE* even though
- * they advertise the texture extension.  
+ * they advertise the texture extension.
  * Note that proxy textures are implemented but not according to spec in
  * IMPACT*.
  */
-static void closestFit(GLenum target, GLint width, GLint height, 
-                      GLint internalFormat, GLenum format, GLenum type, 
+static void closestFit(GLenum target, GLint width, GLint height,
+                      GLint internalFormat, GLenum format, GLenum type,
                       GLint *newWidth, GLint *newHeight)
 {
    /* Use proxy textures if OpenGL version is >= 1.1 */
    if ( (strtod((const char *)glGetString(GL_VERSION),NULL) >= 1.1)
        ) {
       GLint widthPowerOf2= nearestPower(width);
-      GLint heightPowerOf2= nearestPower(height);      
+      GLint heightPowerOf2= nearestPower(height);       
       GLint proxyWidth;
 
       do {
         /* compute level 1 width & height, clamping each at 1 */
         GLint widthAtLevelOne= (widthPowerOf2 > 1) ?
-                                widthPowerOf2 >> 1 :
-                                widthPowerOf2;  
+                                widthPowerOf2 >> 1 :
+                                widthPowerOf2;
         GLint heightAtLevelOne= (heightPowerOf2 > 1) ?
-                                 heightPowerOf2 >> 1 :
-                                 heightPowerOf2;  
+                                 heightPowerOf2 >> 1 :
+                                 heightPowerOf2;
         GLenum proxyTarget;
         assert(widthAtLevelOne > 0); assert(heightAtLevelOne > 0);
 
@@ -3398,19 +3398,19 @@ static void closestFit(GLenum target, GLint width, GLint height,
                         widthAtLevelOne,heightAtLevelOne,0,format,type,NULL);
         } else
 #if defined(GL_ARB_texture_cube_map)
-         if ((target == GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB) ||
-             (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB) ||
-             (target == GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB) ||
-             (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB) ||
-             (target == GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB) ||
-             (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
-             proxyTarget = GL_PROXY_TEXTURE_CUBE_MAP_ARB;
-             glTexImage2D(proxyTarget, 1, /* must be non-zero */
-                          internalFormat,
-                          widthAtLevelOne,heightAtLevelOne,0,format,type,NULL);
-         } else
+        if ((target == GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB) ||
+            (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB) ||
+            (target == GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB) ||
+            (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB) ||
+            (target == GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB) ||
+            (target == GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
+            proxyTarget = GL_PROXY_TEXTURE_CUBE_MAP_ARB;
+            glTexImage2D(proxyTarget, 1, /* must be non-zero */
+                         internalFormat,
+                         widthAtLevelOne,heightAtLevelOne,0,format,type,NULL);
+        } else
 #endif /* GL_ARB_texture_cube_map */
-         {
+        {
            assert(target == GL_TEXTURE_1D || target == GL_PROXY_TEXTURE_1D);
            proxyTarget = GL_PROXY_TEXTURE_1D;
            glTexImage1D(proxyTarget, 1, /* must be non-zero */
@@ -3424,13 +3424,13 @@ static void closestFit(GLenum target, GLint width, GLint height,
                * break out.  This should never happen. But things
                * happen.  The disadvantage with this if-statement is
                * that we will never be aware of when this happens
-               * since it will silently branch out.  
+               * since it will silently branch out.
                */
               goto noProxyTextures;
            }
            widthPowerOf2= widthAtLevelOne;
            heightPowerOf2= heightAtLevelOne;
-        } 
+        }
         /* else it does fit */
       } while (proxyWidth == 0);
       /* loop must terminate! */
@@ -3456,8 +3456,8 @@ noProxyTextures:
 } /* closestFit() */
 
 GLint GLAPIENTRY
-gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin, 
-                   GLenum typein, const void *datain, 
+gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
+                   GLenum typein, const void *datain,
                    GLsizei widthout, GLsizei heightout, GLenum typeout,
                    void *dataout)
 {
@@ -3482,7 +3482,7 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
        return GLU_INVALID_OPERATION;
     }
     beforeImage =
-       malloc(image_size(widthin, heightin, format, GL_UNSIGNED_SHORT)); 
+       malloc(image_size(widthin, heightin, format, GL_UNSIGNED_SHORT));
     afterImage =
        malloc(image_size(widthout, heightout, format, GL_UNSIGNED_SHORT));
     if (beforeImage == NULL || afterImage == NULL) {
@@ -3493,9 +3493,9 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
     fill_image(&psm,widthin, heightin, format, typein, is_index(format),
            datain, beforeImage);
     components = elements_per_group(format, 0);
-    scale_internal(components, widthin, heightin, beforeImage, 
+    scale_internal(components, widthin, heightin, beforeImage,
            widthout, heightout, afterImage);
-    empty_image(&psm,widthout, heightout, format, typeout, 
+    empty_image(&psm,widthout, heightout, format, typeout,
            is_index(format), afterImage, dataout);
     free((GLbyte *) beforeImage);
     free((GLbyte *) afterImage);
@@ -3506,7 +3506,7 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
 int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
                               GLsizei width,
                               GLsizei widthPowerOf2,
-                              GLenum format, GLenum type, 
+                              GLenum format, GLenum type,
                               GLint userLevel, GLint baseLevel,GLint maxLevel,
                               const void *data)
 {
@@ -3532,7 +3532,7 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
 
     retrieveStoreModes(&psm);
     newImage = (GLushort *)
-       malloc(image_size(width, 1, format, GL_UNSIGNED_SHORT)); 
+       malloc(image_size(width, 1, format, GL_UNSIGNED_SHORT));
     newImage_width = width;
     if (newImage == NULL) {
        return GLU_OUT_OF_MEMORY;
@@ -3553,7 +3553,7 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
        if (newImage_width == newwidth) {
            /* Use newImage for this level */
            if (baseLevel <= level && level <= maxLevel) {
-           glTexImage1D(target, level, internalFormat, newImage_width, 
+           glTexImage1D(target, level, internalFormat, newImage_width,
                    0, format, GL_UNSIGNED_SHORT, (void *) newImage);
            }
        } else {
@@ -3569,10 +3569,10 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
                    return GLU_OUT_OF_MEMORY;
                }
            }
-           scale_internal(cmpts, newImage_width, 1, newImage, 
+           scale_internal(cmpts, newImage_width, 1, newImage,
                    newwidth, 1, otherImage);
            /* Swap newImage and otherImage */
-           imageTemp = otherImage; 
+           imageTemp = otherImage;
            otherImage = newImage;
            newImage = imageTemp;
 
@@ -3598,9 +3598,9 @@ int gluBuild1DMipmapLevelsCore(GLenum target, GLint internalFormat,
 }
 
 GLint GLAPIENTRY
-gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, 
+gluBuild1DMipmapLevels(GLenum target, GLint internalFormat,
                             GLsizei width,
-                            GLenum format, GLenum type, 
+                            GLenum format, GLenum type,
                             GLint userLevel, GLint baseLevel, GLint maxLevel,
                             const void *data)
 {
@@ -3616,19 +3616,19 @@ gluBuild1DMipmapLevels(GLenum target, GLint internalFormat,
    levels = computeLog(width);
 
    levels+= userLevel;
-   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels)) 
+   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
       return GLU_INVALID_VALUE;
 
-   return gluBuild1DMipmapLevelsCore(target, internalFormat, 
+   return gluBuild1DMipmapLevelsCore(target, internalFormat,
                                     width,
-                                    width,format, type, 
+                                    width,format, type,
                                     userLevel, baseLevel, maxLevel,
                                     data);
 } /* gluBuild1DMipmapLevels() */
 
 GLint GLAPIENTRY
 gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width,
-                       GLenum format, GLenum type, 
+                       GLenum format, GLenum type,
                        const void *data)
 {
    GLint widthPowerOf2;
@@ -3653,7 +3653,7 @@ gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width,
 
 static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
                     GLint width, GLint height, GLenum format,
-                     GLenum type, const void *data)
+                    GLenum type, const void *data)
 {
     GLint newwidth, newheight;
     GLint level, levels;
@@ -3684,15 +3684,15 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
 
     otherImage = NULL;
     newImage = (GLushort *)
-        malloc(image_size(width, height, format, GL_UNSIGNED_SHORT));
+       malloc(image_size(width, height, format, GL_UNSIGNED_SHORT));
     newImage_width = width;
     newImage_height = height;
     if (newImage == NULL) {
-        return GLU_OUT_OF_MEMORY;
+       return GLU_OUT_OF_MEMORY;
     }
 
     fill_image(&psm,width, height, format, type, is_index(format),
-          data, newImage);
+         data, newImage);
 
     cmpts = elements_per_group(format,type);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
@@ -3705,39 +3705,39 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
     glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
 
     for (level = 0; level <= levels; level++) {
-        if (newImage_width == newwidth && newImage_height == newheight) {            /* Use newImage for this level */
-            glTexImage2D(target, level, internalFormat, newImage_width,
-                    newImage_height, 0, format, GL_UNSIGNED_SHORT,
-                    (void *) newImage);
-        } else {
-            if (otherImage == NULL) {
-                memreq =
-                    image_size(newwidth, newheight, format, GL_UNSIGNED_SHORT);
-                otherImage = (GLushort *) malloc(memreq);
-                if (otherImage == NULL) {
-                    glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment);
-                    glPixelStorei(GL_UNPACK_SKIP_ROWS, psm.unpack_skip_rows);
-                    glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
-                    glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
-                    glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
-                    return GLU_OUT_OF_MEMORY;
-                }
-            }
-            scale_internal(cmpts, newImage_width, newImage_height, newImage,
-                    newwidth, newheight, otherImage);
-            /* Swap newImage and otherImage */
-            imageTemp = otherImage;
-            otherImage = newImage;
-            newImage = imageTemp;
-
-            newImage_width = newwidth;
-            newImage_height = newheight;
-            glTexImage2D(target, level, internalFormat, newImage_width,
-                    newImage_height, 0, format, GL_UNSIGNED_SHORT,
-                    (void *) newImage);
-        }
-        if (newwidth > 1) newwidth /= 2;
-        if (newheight > 1) newheight /= 2;
+       if (newImage_width == newwidth && newImage_height == newheight) {            /* Use newImage for this level */
+           glTexImage2D(target, level, internalFormat, newImage_width,
+                   newImage_height, 0, format, GL_UNSIGNED_SHORT,
+                   (void *) newImage);
+       } else {
+           if (otherImage == NULL) {
+               memreq =
+                   image_size(newwidth, newheight, format, GL_UNSIGNED_SHORT);
+               otherImage = (GLushort *) malloc(memreq);
+               if (otherImage == NULL) {
+                   glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment);
+                   glPixelStorei(GL_UNPACK_SKIP_ROWS, psm.unpack_skip_rows);
+                   glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
+                   glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
+                   glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+                   return GLU_OUT_OF_MEMORY;
+               }
+           }
+           scale_internal(cmpts, newImage_width, newImage_height, newImage,
+                   newwidth, newheight, otherImage);
+           /* Swap newImage and otherImage */
+           imageTemp = otherImage;
+           otherImage = newImage;
+           newImage = imageTemp;
+
+           newImage_width = newwidth;
+           newImage_height = newheight;
+           glTexImage2D(target, level, internalFormat, newImage_width,
+                   newImage_height, 0, format, GL_UNSIGNED_SHORT,
+                   (void *) newImage);
+       }
+       if (newwidth > 1) newwidth /= 2;
+       if (newheight > 1) newheight /= 2;
     }
     glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment);
     glPixelStorei(GL_UNPACK_SKIP_ROWS, psm.unpack_skip_rows);
@@ -3747,7 +3747,7 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
 
     free((GLbyte *) newImage);
     if (otherImage) {
-        free((GLbyte *) otherImage);
+       free((GLbyte *) otherImage);
     }
     return 0;
 }
@@ -3756,12 +3756,12 @@ static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat,
 #define __GLU_INIT_SWAP_IMAGE void *tmpImage
 #define __GLU_SWAP_IMAGE(a,b) tmpImage = a; a = b; b = tmpImage;
 
-static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, 
-                                     GLsizei width, GLsizei height, 
-                                     GLsizei widthPowerOf2, 
-                                     GLsizei heightPowerOf2, 
-                                     GLenum format, GLenum type, 
-                                     GLint userLevel, 
+static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
+                                     GLsizei width, GLsizei height,
+                                     GLsizei widthPowerOf2,
+                                     GLsizei heightPowerOf2,
+                                     GLenum format, GLenum type,
+                                     GLint userLevel,
                                      GLint baseLevel,GLint maxLevel,
                                      const void *data)
 {
@@ -3782,7 +3782,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
 
     if(type == GL_BITMAP) {
        return bitmapBuild2DMipmaps(target, internalFormat, width, height,
-                format, type, data);
+               format, type, data);
     }
 
     srcImage = dstImage = NULL;
@@ -3813,7 +3813,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
     if (padding) {
        rowsize += psm.unpack_alignment - padding;
     }
-    usersImage = (const GLubyte *) data + psm.unpack_skip_rows * rowsize + 
+    usersImage = (const GLubyte *) data + psm.unpack_skip_rows * rowsize +
        psm.unpack_skip_pixels * group_size;
 
     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
@@ -3825,8 +3825,8 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
     /* already power-of-two square */
     if (width == newwidth && height == newheight) {
        /* Use usersImage for level userLevel */
-        if (baseLevel <= level && level <= maxLevel) { 
-       glTexImage2D(target, level, internalFormat, width, 
+       if (baseLevel <= level && level <= maxLevel) {
+       glTexImage2D(target, level, internalFormat, width,
                height, 0, format, type,
                usersImage);
        }
@@ -3846,7 +3846,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
           if (nextWidth < 1) nextWidth= 1;
           if (nextHeight < 1) nextHeight= 1;
        memreq = image_size(nextWidth, nextHeight, format, type);
-        }
+       }
 
        switch(type) {
        case GL_UNSIGNED_BYTE:
@@ -3870,23 +3870,23 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
        case GL_FLOAT:
          dstImage = (GLfloat *)malloc(memreq);
          break;
-        case GL_UNSIGNED_BYTE_3_3_2: 
-        case GL_UNSIGNED_BYTE_2_3_3_REV: 
+       case GL_UNSIGNED_BYTE_3_3_2:
+       case GL_UNSIGNED_BYTE_2_3_3_REV:
          dstImage = (GLubyte *)malloc(memreq);
          break;
-        case GL_UNSIGNED_SHORT_5_6_5:
-        case GL_UNSIGNED_SHORT_5_6_5_REV:
-        case GL_UNSIGNED_SHORT_4_4_4_4:
-        case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        case GL_UNSIGNED_SHORT_5_5_5_1:
-        case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+       case GL_UNSIGNED_SHORT_5_6_5:
+       case GL_UNSIGNED_SHORT_5_6_5_REV:
+       case GL_UNSIGNED_SHORT_4_4_4_4:
+       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+       case GL_UNSIGNED_SHORT_5_5_5_1:
+       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
          dstImage = (GLushort *)malloc(memreq);
-          break;
-        case GL_UNSIGNED_INT_8_8_8_8:
-        case GL_UNSIGNED_INT_8_8_8_8_REV:
-        case GL_UNSIGNED_INT_10_10_10_2:
-        case GL_UNSIGNED_INT_2_10_10_10_REV:
-         dstImage = (GLuint *)malloc(memreq);    
+         break;
+       case GL_UNSIGNED_INT_8_8_8_8:
+       case GL_UNSIGNED_INT_8_8_8_8_REV:
+       case GL_UNSIGNED_INT_10_10_10_2:
+       case GL_UNSIGNED_INT_2_10_10_10_REV:
+         dstImage = (GLuint *)malloc(memreq);  
          break;
        default:
          return GLU_INVALID_ENUM;
@@ -3903,12 +3903,12 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          switch(type) {
          case GL_UNSIGNED_BYTE:
            halveImage_ubyte(cmpts, width, height,
-                            (const GLubyte *)usersImage, (GLubyte *)dstImage, 
+                            (const GLubyte *)usersImage, (GLubyte *)dstImage,
                             element_size, rowsize, group_size);
            break;
          case GL_BYTE:
            halveImage_byte(cmpts, width, height,
-                           (const GLbyte *)usersImage, (GLbyte *)dstImage, 
+                           (const GLbyte *)usersImage, (GLbyte *)dstImage,
                            element_size, rowsize, group_size);
            break;
          case GL_UNSIGNED_SHORT:
@@ -3918,17 +3918,17 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            break;
          case GL_SHORT:
            halveImage_short(cmpts, width, height,
-                            (const GLshort *)usersImage, (GLshort *)dstImage, 
+                            (const GLshort *)usersImage, (GLshort *)dstImage,
                             element_size, rowsize, group_size, myswap_bytes);
            break;
          case GL_UNSIGNED_INT:
            halveImage_uint(cmpts, width, height,
-                           (const GLuint *)usersImage, (GLuint *)dstImage, 
+                           (const GLuint *)usersImage, (GLuint *)dstImage,
                            element_size, rowsize, group_size, myswap_bytes);
            break;
          case GL_INT:
            halveImage_int(cmpts, width, height,
-                          (const GLint *)usersImage, (GLint *)dstImage, 
+                          (const GLint *)usersImage, (GLint *)dstImage,
                           element_size, rowsize, group_size, myswap_bytes);
            break;
          case GL_FLOAT:
@@ -3936,69 +3936,69 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
                             (const GLfloat *)usersImage, (GLfloat *)dstImage,
                             element_size, rowsize, group_size, myswap_bytes);
            break;
-         case GL_UNSIGNED_BYTE_3_3_2: 
+         case GL_UNSIGNED_BYTE_3_3_2:
            assert(format == GL_RGB);
            halveImagePackedPixel(3,extract332,shove332,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
            break;
-          case GL_UNSIGNED_BYTE_2_3_3_REV:
+         case GL_UNSIGNED_BYTE_2_3_3_REV:
            assert(format == GL_RGB);
            halveImagePackedPixel(3,extract233rev,shove233rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
            break;
-          case GL_UNSIGNED_SHORT_5_6_5:
+         case GL_UNSIGNED_SHORT_5_6_5:
            halveImagePackedPixel(3,extract565,shove565,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;
-          case GL_UNSIGNED_SHORT_5_6_5_REV:
+           break;
+         case GL_UNSIGNED_SHORT_5_6_5_REV:
            halveImagePackedPixel(3,extract565rev,shove565rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;
-          case GL_UNSIGNED_SHORT_4_4_4_4:
+           break;
+         case GL_UNSIGNED_SHORT_4_4_4_4:
            halveImagePackedPixel(4,extract4444,shove4444,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+           break;
+         case GL_UNSIGNED_SHORT_4_4_4_4_REV:
            halveImagePackedPixel(4,extract4444rev,shove4444rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_SHORT_5_5_5_1:
+           break;
+         case GL_UNSIGNED_SHORT_5_5_5_1:
            halveImagePackedPixel(4,extract5551,shove5551,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+           break;
+         case GL_UNSIGNED_SHORT_1_5_5_5_REV:
            halveImagePackedPixel(4,extract1555rev,shove1555rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_INT_8_8_8_8:
+           break;
+         case GL_UNSIGNED_INT_8_8_8_8:
            halveImagePackedPixel(4,extract8888,shove8888,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_INT_8_8_8_8_REV:
+           break;
+         case GL_UNSIGNED_INT_8_8_8_8_REV:
            halveImagePackedPixel(4,extract8888rev,shove8888rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_INT_10_10_10_2:
+           break;
+         case GL_UNSIGNED_INT_10_10_10_2:
            halveImagePackedPixel(4,extract1010102,shove1010102,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          case GL_UNSIGNED_INT_2_10_10_10_REV:
+           break;
+         case GL_UNSIGNED_INT_2_10_10_10_REV:
            halveImagePackedPixel(4,extract2101010rev,shove2101010rev,
                                  width,height,usersImage,dstImage,
                                  element_size,rowsize,myswap_bytes);
-           break;          
-          default:
+           break;
+         default:
            assert(0);
            break;
          }
@@ -4006,7 +4006,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
        newheight = height/2;
        /* clamp to 1 */
        if (newwidth < 1) newwidth= 1;
-       if (newheight < 1) newheight= 1; 
+       if (newheight < 1) newheight= 1;
 
        myswap_bytes = 0;
        rowsize = newwidth * group_size;
@@ -4035,22 +4035,22 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
        case GL_FLOAT:
          dstImage = (GLfloat *)malloc(memreq);
          break;
-        case GL_UNSIGNED_BYTE_3_3_2:
-        case GL_UNSIGNED_BYTE_2_3_3_REV:
+       case GL_UNSIGNED_BYTE_3_3_2:
+       case GL_UNSIGNED_BYTE_2_3_3_REV:
          dstImage = (GLubyte *)malloc(memreq);
          break;
-        case GL_UNSIGNED_SHORT_5_6_5:
-        case GL_UNSIGNED_SHORT_5_6_5_REV:
-        case GL_UNSIGNED_SHORT_4_4_4_4:
-        case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-        case GL_UNSIGNED_SHORT_5_5_5_1:
-        case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+       case GL_UNSIGNED_SHORT_5_6_5:
+       case GL_UNSIGNED_SHORT_5_6_5_REV:
+       case GL_UNSIGNED_SHORT_4_4_4_4:
+       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+       case GL_UNSIGNED_SHORT_5_5_5_1:
+       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
          dstImage = (GLushort *)malloc(memreq);
          break;
-        case GL_UNSIGNED_INT_8_8_8_8:
-        case GL_UNSIGNED_INT_8_8_8_8_REV:
-        case GL_UNSIGNED_INT_10_10_10_2:
-        case GL_UNSIGNED_INT_2_10_10_10_REV:
+       case GL_UNSIGNED_INT_8_8_8_8:
+       case GL_UNSIGNED_INT_8_8_8_8_REV:
+       case GL_UNSIGNED_INT_10_10_10_2:
+       case GL_UNSIGNED_INT_2_10_10_10_REV:
          dstImage = (GLuint *)malloc(memreq);
          break;
        default:
@@ -4069,30 +4069,30 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
     } else { /* user's image is *not* nice power-of-2 sized square */
        memreq = image_size(newwidth, newheight, format, type);
        switch(type) {
-            case GL_UNSIGNED_BYTE:
-                dstImage = (GLubyte *)malloc(memreq);
-                break;
-            case GL_BYTE:
-                dstImage = (GLbyte *)malloc(memreq);
-                break;
-            case GL_UNSIGNED_SHORT:
-                dstImage = (GLushort *)malloc(memreq);
-                break;
-            case GL_SHORT:
-                dstImage = (GLshort *)malloc(memreq);
-                break;
-            case GL_UNSIGNED_INT:
-                dstImage = (GLuint *)malloc(memreq);
-                break;
-            case GL_INT:
-                dstImage = (GLint *)malloc(memreq);
-                break;
-            case GL_FLOAT:
-                dstImage = (GLfloat *)malloc(memreq);
-                break;
-            case GL_UNSIGNED_BYTE_3_3_2:
-            case GL_UNSIGNED_BYTE_2_3_3_REV:
-                dstImage = (GLubyte *)malloc(memreq);
+           case GL_UNSIGNED_BYTE:
+               dstImage = (GLubyte *)malloc(memreq);
+               break;
+           case GL_BYTE:
+               dstImage = (GLbyte *)malloc(memreq);
+               break;
+           case GL_UNSIGNED_SHORT:
+               dstImage = (GLushort *)malloc(memreq);
+               break;
+           case GL_SHORT:
+               dstImage = (GLshort *)malloc(memreq);
+               break;
+           case GL_UNSIGNED_INT:
+               dstImage = (GLuint *)malloc(memreq);
+               break;
+           case GL_INT:
+               dstImage = (GLint *)malloc(memreq);
+               break;
+           case GL_FLOAT:
+               dstImage = (GLfloat *)malloc(memreq);
+               break;
+           case GL_UNSIGNED_BYTE_3_3_2:
+           case GL_UNSIGNED_BYTE_2_3_3_REV:
+               dstImage = (GLubyte *)malloc(memreq);
                break;
            case GL_UNSIGNED_SHORT_5_6_5:
            case GL_UNSIGNED_SHORT_5_6_5_REV:
@@ -4108,9 +4108,9 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            case GL_UNSIGNED_INT_2_10_10_10_REV:
                dstImage = (GLuint *)malloc(memreq);
                break;
-            default:
-                return GLU_INVALID_ENUM;
-        }
+           default:
+               return GLU_INVALID_ENUM;
+       }
 
        if (dstImage == NULL) {
            glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment);
@@ -4130,7 +4130,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            break;
        case GL_BYTE:
            scale_internal_byte(cmpts, width, height,
-                               (const GLbyte *)usersImage, newwidth, newheight, 
+                               (const GLbyte *)usersImage, newwidth, newheight,
                                (GLbyte *)dstImage, element_size,
                                rowsize, group_size);
            break;
@@ -4154,89 +4154,89 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
            break;
        case GL_INT:
            scale_internal_int(cmpts, width, height,
-                              (const GLint *)usersImage, newwidth, newheight, 
+                              (const GLint *)usersImage, newwidth, newheight,
                               (GLint *)dstImage, element_size,
                               rowsize, group_size, myswap_bytes);
            break;
        case GL_FLOAT:
            scale_internal_float(cmpts, width, height,
-                                (const GLfloat *)usersImage, newwidth, newheight, 
+                                (const GLfloat *)usersImage, newwidth, newheight,
                                 (GLfloat *)dstImage, element_size,
                                 rowsize, group_size, myswap_bytes);
            break;
-        case GL_UNSIGNED_BYTE_3_3_2:
+       case GL_UNSIGNED_BYTE_3_3_2:
            scaleInternalPackedPixel(3,extract332,shove332,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_BYTE_2_3_3_REV:
+       case GL_UNSIGNED_BYTE_2_3_3_REV:
            scaleInternalPackedPixel(3,extract233rev,shove233rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_5_6_5:
+       case GL_UNSIGNED_SHORT_5_6_5:
            scaleInternalPackedPixel(3,extract565,shove565,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_5_6_5_REV:
+       case GL_UNSIGNED_SHORT_5_6_5_REV:
            scaleInternalPackedPixel(3,extract565rev,shove565rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_4_4_4_4:
+       case GL_UNSIGNED_SHORT_4_4_4_4:
            scaleInternalPackedPixel(4,extract4444,shove4444,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+       case GL_UNSIGNED_SHORT_4_4_4_4_REV:
            scaleInternalPackedPixel(4,extract4444rev,shove4444rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_5_5_5_1:
+       case GL_UNSIGNED_SHORT_5_5_5_1:
            scaleInternalPackedPixel(4,extract5551,shove5551,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+       case GL_UNSIGNED_SHORT_1_5_5_5_REV:
            scaleInternalPackedPixel(4,extract1555rev,shove1555rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_INT_8_8_8_8:
+       case GL_UNSIGNED_INT_8_8_8_8:
            scaleInternalPackedPixel(4,extract8888,shove8888,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_INT_8_8_8_8_REV:
+       case GL_UNSIGNED_INT_8_8_8_8_REV:
            scaleInternalPackedPixel(4,extract8888rev,shove8888rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_INT_10_10_10_2:
+       case GL_UNSIGNED_INT_10_10_10_2:
            scaleInternalPackedPixel(4,extract1010102,shove1010102,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        case GL_UNSIGNED_INT_2_10_10_10_REV:
+       case GL_UNSIGNED_INT_2_10_10_10_REV:
            scaleInternalPackedPixel(4,extract2101010rev,shove2101010rev,
                                     width, height,usersImage,
                                     newwidth,newheight,(void *)dstImage,
                                     element_size,rowsize,myswap_bytes);
            break;
-        default:
+       default:
            assert(0);
            break;
        }
@@ -4246,14 +4246,14 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
        __GLU_SWAP_IMAGE(srcImage,dstImage);
 
        if(levels != 0) { /* use as little memory as possible */
-          {
+         {
             int nextWidth= newwidth/2;
             int nextHeight= newheight/2;
             if (nextWidth < 1) nextWidth= 1;
-            if (nextHeight < 1) nextHeight= 1;      
+            if (nextHeight < 1) nextHeight= 1; 
 
          memreq = image_size(nextWidth, nextHeight, format, type);
-          }
+         }
 
          switch(type) {
          case GL_UNSIGNED_BYTE:
@@ -4277,12 +4277,12 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          case GL_FLOAT:
            dstImage = (GLfloat *)malloc(memreq);
            break;
-          case GL_UNSIGNED_BYTE_3_3_2:
-          case GL_UNSIGNED_BYTE_2_3_3_REV:
+         case GL_UNSIGNED_BYTE_3_3_2:
+         case GL_UNSIGNED_BYTE_2_3_3_REV:
            dstImage = (GLubyte *)malloc(memreq);
            break;
-          case GL_UNSIGNED_SHORT_5_6_5:
-          case GL_UNSIGNED_SHORT_5_6_5_REV:
+         case GL_UNSIGNED_SHORT_5_6_5:
+         case GL_UNSIGNED_SHORT_5_6_5_REV:
          case GL_UNSIGNED_SHORT_4_4_4_4:
          case GL_UNSIGNED_SHORT_4_4_4_4_REV:
          case GL_UNSIGNED_SHORT_5_5_5_1:
@@ -4308,12 +4308,12 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          }
        }
        /* level userLevel is in srcImage; nothing saved yet */
-       level = userLevel; 
+       level = userLevel;
     }
 
     glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
     if (baseLevel <= level && level <= maxLevel) {
-    glTexImage2D(target, level, internalFormat, newwidth, newheight, 0, 
+    glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
                 format, type, (void *)srcImage);
     }
 
@@ -4355,96 +4355,96 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
                (GLfloat *)srcImage, (GLfloat *)dstImage, element_size,
                rowsize, group_size, myswap_bytes);
                break;
-            case GL_UNSIGNED_BYTE_3_3_2:
-               halveImagePackedPixel(3,extract332,shove332,
+           case GL_UNSIGNED_BYTE_3_3_2:
+               halveImagePackedPixel(3,extract332,shove332,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_BYTE_2_3_3_REV:
-               halveImagePackedPixel(3,extract233rev,shove233rev,
+           case GL_UNSIGNED_BYTE_2_3_3_REV:
+               halveImagePackedPixel(3,extract233rev,shove233rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
            case GL_UNSIGNED_SHORT_5_6_5:
-               halveImagePackedPixel(3,extract565,shove565,
+               halveImagePackedPixel(3,extract565,shove565,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
-               break;
+               break;
            case GL_UNSIGNED_SHORT_5_6_5_REV:
-               halveImagePackedPixel(3,extract565rev,shove565rev,
+               halveImagePackedPixel(3,extract565rev,shove565rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
-               break;
-            case GL_UNSIGNED_SHORT_4_4_4_4:
-               halveImagePackedPixel(4,extract4444,shove4444,
+               break;
+           case GL_UNSIGNED_SHORT_4_4_4_4:
+               halveImagePackedPixel(4,extract4444,shove4444,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-               halveImagePackedPixel(4,extract4444rev,shove4444rev,
+           case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+               halveImagePackedPixel(4,extract4444rev,shove4444rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_SHORT_5_5_5_1:            
-               halveImagePackedPixel(4,extract5551,shove5551,
+           case GL_UNSIGNED_SHORT_5_5_5_1:             
+               halveImagePackedPixel(4,extract5551,shove5551,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_SHORT_1_5_5_5_REV:                
-               halveImagePackedPixel(4,extract1555rev,shove1555rev,
+           case GL_UNSIGNED_SHORT_1_5_5_5_REV:                 
+               halveImagePackedPixel(4,extract1555rev,shove1555rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_INT_8_8_8_8:
-               halveImagePackedPixel(4,extract8888,shove8888,
+           case GL_UNSIGNED_INT_8_8_8_8:
+               halveImagePackedPixel(4,extract8888,shove8888,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_INT_8_8_8_8_REV:
-               halveImagePackedPixel(4,extract8888rev,shove8888rev,
+           case GL_UNSIGNED_INT_8_8_8_8_REV:
+               halveImagePackedPixel(4,extract8888rev,shove8888rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_INT_10_10_10_2:
-               halveImagePackedPixel(4,extract1010102,shove1010102,
+           case GL_UNSIGNED_INT_10_10_10_2:
+               halveImagePackedPixel(4,extract1010102,shove1010102,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-            case GL_UNSIGNED_INT_2_10_10_10_REV:
-               halveImagePackedPixel(4,extract2101010rev,shove2101010rev,
+           case GL_UNSIGNED_INT_2_10_10_10_REV:
+               halveImagePackedPixel(4,extract2101010rev,shove2101010rev,
                                      newwidth,newheight,
                                      srcImage,dstImage,element_size,rowsize,
                                      myswap_bytes);
                break;
-           default:
-               assert(0);
+           default:
+               assert(0);
                break;
        }
 
        __GLU_SWAP_IMAGE(srcImage,dstImage);
 
-       if (newwidth > 1) { newwidth /= 2; rowsize /= 2;}
-       if (newheight > 1) newheight /= 2;
+       if (newwidth > 1) { newwidth /= 2; rowsize /= 2;}
+       if (newheight > 1) newheight /= 2;
       {
        /* compute amount to pad per row, if any */
-       int rowPad= rowsize % psm.unpack_alignment; 
+       int rowPad= rowsize % psm.unpack_alignment;
 
        /* should row be padded? */
        if (rowPad == 0) {      /* nope, row should not be padded */
           /* call tex image with srcImage untouched since it's not padded */
           if (baseLevel <= level && level <= maxLevel) {
-          glTexImage2D(target, level, internalFormat, newwidth, newheight, 0, 
+          glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
           format, type, (void *) srcImage);
           }
        }
@@ -4469,7 +4469,7 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
          for (ii= 0,
               dstTrav= (unsigned char *) newMipmapImage,
               srcTrav= (unsigned char *) srcImage;
-              ii< newheight; 
+              ii< newheight;
               ii++,
               dstTrav+= newRowLength, /* make sure the correct distance... */
               srcTrav+= rowsize) {    /* ...is skipped */
@@ -4477,14 +4477,14 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
             /* note that the pad bytes are not visited and will contain
              * garbage, which is ok.
              */
-         } 
+         }
 
-         /* ...and use this new image for mipmapping instead */ 
+         /* ...and use this new image for mipmapping instead */
          if (baseLevel <= level && level <= maxLevel) {
-         glTexImage2D(target, level, internalFormat, newwidth, newheight, 0, 
+         glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
                       format, type, newMipmapImage);
          }
-         free(newMipmapImage); /* don't forget to free it! */
+         free(newMipmapImage); /* don't forget to free it! */
        } /* else */
       }
     } /* for level */
@@ -4502,9 +4502,9 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat,
 } /* gluBuild2DMipmapLevelsCore() */
 
 GLint GLAPIENTRY
-gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, 
-                            GLsizei width, GLsizei height, 
-                            GLenum format, GLenum type, 
+gluBuild2DMipmapLevels(GLenum target, GLint internalFormat,
+                            GLsizei width, GLsizei height,
+                            GLenum format, GLenum type,
                             GLint userLevel, GLint baseLevel, GLint maxLevel,
                             const void *data)
 {
@@ -4522,21 +4522,21 @@ gluBuild2DMipmapLevels(GLenum target, GLint internalFormat,
    if (level > levels) levels=level;
 
    levels+= userLevel;
-   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels)) 
+   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
       return GLU_INVALID_VALUE;
 
-   return gluBuild2DMipmapLevelsCore(target, internalFormat, 
+   return gluBuild2DMipmapLevelsCore(target, internalFormat,
                                     width, height,
                                     width, height,
-                                    format, type, 
+                                    format, type,
                                     userLevel, baseLevel, maxLevel,
                                     data);
 } /* gluBuild2DMipmapLevels() */
 
 GLint GLAPIENTRY
-gluBuild2DMipmaps(GLenum target, GLint internalFormat, 
-                       GLsizei width, GLsizei height, 
-                       GLenum format, GLenum type, 
+gluBuild2DMipmaps(GLenum target, GLint internalFormat,
+                       GLsizei width, GLsizei height,
+                       GLenum format, GLenum type,
                        const void *data)
 {
    GLint widthPowerOf2, heightPowerOf2;
@@ -4563,16 +4563,17 @@ gluBuild2DMipmaps(GLenum target, GLint internalFormat,
                                     0,0,levels,data);
 }  /* gluBuild2DMipmaps() */
 
+#if 0
 /*
 ** This routine is for the limited case in which
-**     type == GL_UNSIGNED_BYTE && format != index  && 
+**     type == GL_UNSIGNED_BYTE && format != index  &&
 **     unpack_alignment = 1 && unpack_swap_bytes == false
 **
 ** so all of the work data can be kept as ubytes instead of shorts.
 */
 static int fastBuild2DMipmaps(const PixelStorageModes *psm,
-                      GLenum target, GLint components, GLint width, 
-                    GLint height, GLenum format, 
+                      GLenum target, GLint components, GLint width,
+                    GLint height, GLenum format,
                     GLenum type, void *data)
 {
     GLint newwidth, newheight;
@@ -4620,8 +4621,8 @@ static int fastBuild2DMipmaps(const PixelStorageModes *psm,
        GLubyte *iter2;
        GLint i, j;
 
-       newImage = (GLubyte *) 
-           malloc(image_size(width, height, format, GL_UNSIGNED_BYTE)); 
+       newImage = (GLubyte *)
+           malloc(image_size(width, height, format, GL_UNSIGNED_BYTE));
        newImage_width = width;
        newImage_height = height;
        if (newImage == NULL) {
@@ -4638,7 +4639,7 @@ static int fastBuild2DMipmaps(const PixelStorageModes *psm,
        }
        rowsize = groups_per_line * cmpts;
        elements_per_line = width * cmpts;
-       start = (const GLubyte *) data + psm->unpack_skip_rows * rowsize + 
+       start = (const GLubyte *) data + psm->unpack_skip_rows * rowsize +
                psm->unpack_skip_pixels * cmpts;
        iter2 = newImage;
 
@@ -4663,12 +4664,12 @@ static int fastBuild2DMipmaps(const PixelStorageModes *psm,
     for (level = 0; level <= levels; level++) {
        if (newImage_width == newwidth && newImage_height == newheight) {
            /* Use newImage for this level */
-           glTexImage2D(target, level, components, newImage_width, 
-                   newImage_height, 0, format, GL_UNSIGNED_BYTE, 
+           glTexImage2D(target, level, components, newImage_width,
+                   newImage_height, 0, format, GL_UNSIGNED_BYTE,
                    (void *) newImage);
        } else {
            if (otherImage == NULL) {
-               memreq = 
+               memreq =
                    image_size(newwidth, newheight, format, GL_UNSIGNED_BYTE);
                otherImage = (GLubyte *) malloc(memreq);
                if (otherImage == NULL) {
@@ -4681,18 +4682,18 @@ static int fastBuild2DMipmaps(const PixelStorageModes *psm,
                }
            }
 /*
-           scale_internal_ubyte(cmpts, newImage_width, newImage_height, 
+           scale_internal_ubyte(cmpts, newImage_width, newImage_height,
                    newImage, newwidth, newheight, otherImage);
 */
            /* Swap newImage and otherImage */
-           imageTemp = otherImage; 
+           imageTemp = otherImage;
            otherImage = newImage;
            newImage = imageTemp;
 
            newImage_width = newwidth;
            newImage_height = newheight;
-           glTexImage2D(target, level, components, newImage_width, 
-                   newImage_height, 0, format, GL_UNSIGNED_BYTE, 
+           glTexImage2D(target, level, components, newImage_width,
+                   newImage_height, 0, format, GL_UNSIGNED_BYTE,
                    (void *) newImage);
        }
        if (newwidth > 1) newwidth /= 2;
@@ -4712,18 +4713,19 @@ static int fastBuild2DMipmaps(const PixelStorageModes *psm,
     }
     return 0;
 }
+#endif
 
 /*
  * Utility Routines
  */
-static GLint elements_per_group(GLenum format, GLenum type) 
+static GLint elements_per_group(GLenum format, GLenum type)
 {
     /*
      * Return the number of elements per group of a specified format
      */
 
     /* If the type is packedpixels then answer is 1 (ignore format) */
-    if (type == GL_UNSIGNED_BYTE_3_3_2 || 
+    if (type == GL_UNSIGNED_BYTE_3_3_2 ||
        type == GL_UNSIGNED_BYTE_2_3_3_REV ||
        type == GL_UNSIGNED_SHORT_5_6_5 ||
        type == GL_UNSIGNED_SHORT_5_6_5_REV ||
@@ -4735,7 +4737,7 @@ static GLint elements_per_group(GLenum format, GLenum type)
        type == GL_UNSIGNED_INT_8_8_8_8_REV ||
        type == GL_UNSIGNED_INT_10_10_10_2 ||
        type == GL_UNSIGNED_INT_2_10_10_10_REV) {
-        return 1;
+       return 1;
     }
 
     /* Types are not packed pixels, so get elements per group */
@@ -4753,7 +4755,7 @@ static GLint elements_per_group(GLenum format, GLenum type)
     }
 }
 
-static GLfloat bytes_per_element(GLenum type) 
+static GLfloat bytes_per_element(GLenum type)
 {
     /*
      * Return the number of bytes per element, based on the element type
@@ -4776,7 +4778,7 @@ static GLfloat bytes_per_element(GLenum type)
       case GL_FLOAT:
        return(sizeof(GLfloat));
       case GL_UNSIGNED_BYTE_3_3_2:
-      case GL_UNSIGNED_BYTE_2_3_3_REV: 
+      case GL_UNSIGNED_BYTE_2_3_3_REV:  
        return(sizeof(GLubyte));
       case GL_UNSIGNED_SHORT_5_6_5:
       case GL_UNSIGNED_SHORT_5_6_5_REV:
@@ -4795,7 +4797,7 @@ static GLfloat bytes_per_element(GLenum type)
     }
 }
 
-static GLint is_index(GLenum format) 
+static GLint is_index(GLenum format)
 {
     return format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX;
 }
@@ -4804,7 +4806,7 @@ static GLint is_index(GLenum format)
 ** Compute memory required for internal packed array of data of given type
 ** and format.
 */
-static GLint image_size(GLint width, GLint height, GLenum format, GLenum type) 
+static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
 {
     int bytes_per_row;
     int components;
@@ -4825,8 +4827,8 @@ assert(height > 0);
 ** The internal format used is an array of unsigned shorts.
 */
 static void fill_image(const PixelStorageModes *psm,
-                      GLint width, GLint height, GLenum format, 
-                      GLenum type, GLboolean index_format, 
+                      GLint width, GLint height, GLenum format,
+                      GLenum type, GLboolean index_format,
                       const void *userdata, GLushort *newimage)
 {
     GLint components;
@@ -4860,7 +4862,7 @@ static void fill_image(const PixelStorageModes *psm,
        if (padding) {
            rowsize += psm->unpack_alignment - padding;
        }
-       start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize + 
+       start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize +
                (psm->unpack_skip_pixels * components / 8);
        elements_per_line = width * components;
        iter2 = newimage;
@@ -4902,7 +4904,7 @@ static void fill_image(const PixelStorageModes *psm,
        if (padding) {
            rowsize += psm->unpack_alignment - padding;
        }
-       start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize + 
+       start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize +
                psm->unpack_skip_pixels * group_size;
        elements_per_line = width * components;
 
@@ -4920,7 +4922,7 @@ static void fill_image(const PixelStorageModes *psm,
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                 case GL_UNSIGNED_BYTE_2_3_3_REV:  
+                 case GL_UNSIGNED_BYTE_2_3_3_REV:
                    extract233rev(0,iter,extractComponents);
                    for (k = 0; k < 3; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
@@ -4941,37 +4943,37 @@ static void fill_image(const PixelStorageModes *psm,
                        *iter2++ = (*((const GLbyte *) iter)) * 516;
                    }
                    break;
-                 case GL_UNSIGNED_SHORT_5_6_5:                             
+                 case GL_UNSIGNED_SHORT_5_6_5:                         
                    extract565(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 3; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                 case GL_UNSIGNED_SHORT_5_6_5_REV:                         
+                 case GL_UNSIGNED_SHORT_5_6_5_REV:                     
                    extract565rev(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 3; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                  case GL_UNSIGNED_SHORT_4_4_4_4:                  
+                 case GL_UNSIGNED_SHORT_4_4_4_4:               
                    extract4444(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                  case GL_UNSIGNED_SHORT_4_4_4_4_REV:              
+                 case GL_UNSIGNED_SHORT_4_4_4_4_REV:           
                    extract4444rev(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                  case GL_UNSIGNED_SHORT_5_5_5_1:                  
+                 case GL_UNSIGNED_SHORT_5_5_5_1:               
                    extract5551(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+                 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
                    extract1555rev(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
@@ -4997,19 +4999,19 @@ static void fill_image(const PixelStorageModes *psm,
                        *iter2++ = widget.us[0];
                    }
                    break;
-                  case GL_UNSIGNED_INT_8_8_8_8:                    
+                 case GL_UNSIGNED_INT_8_8_8_8:         
                    extract8888(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                  case GL_UNSIGNED_INT_8_8_8_8_REV:                
+                 case GL_UNSIGNED_INT_8_8_8_8_REV:             
                    extract8888rev(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
                    }
                    break;
-                  case GL_UNSIGNED_INT_10_10_10_2:                 
+                 case GL_UNSIGNED_INT_10_10_10_2:              
                    extract1010102(myswap_bytes,iter,extractComponents);
                    for (k = 0; k < 4; k++) {
                      *iter2++ = (GLushort)(extractComponents[k]*65535);
@@ -5063,7 +5065,7 @@ static void fill_image(const PixelStorageModes *psm,
            /* want 'iter' pointing at start, not within, row for assertion
             * purposes
             */
-           iter= start;        
+           iter= start;        
 #endif
        } /* for i */
 
@@ -5076,7 +5078,7 @@ static void fill_image(const PixelStorageModes *psm,
                                    elements_per_group(format,0)]);
        }
        assert( iter == &((const GLubyte *)userdata)[rowsize*height +
-                                       psm->unpack_skip_rows * rowsize + 
+                                       psm->unpack_skip_rows * rowsize +
                                        psm->unpack_skip_pixels * group_size] );
 
     } /* else */
@@ -5088,8 +5090,8 @@ static void fill_image(const PixelStorageModes *psm,
 ** empty_image() because it is the opposite of fill_image().
 */
 static void empty_image(const PixelStorageModes *psm,
-                       GLint width, GLint height, GLenum format, 
-                       GLenum type, GLboolean index_format, 
+                       GLint width, GLint height, GLenum format,
+                       GLenum type, GLboolean index_format,
                        const GLushort *oldimage, void *userdata)
 {
     GLint components;
@@ -5123,7 +5125,7 @@ static void empty_image(const PixelStorageModes *psm,
        if (padding) {
            rowsize += psm->pack_alignment - padding;
        }
-       start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize + 
+       start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize +
                (psm->pack_skip_pixels * components / 8);
        elements_per_line = width * components;
        iter2 = oldimage;
@@ -5165,7 +5167,7 @@ static void empty_image(const PixelStorageModes *psm,
            start += rowsize;
        }
     } else {
-        float shoveComponents[4];
+       float shoveComponents[4];
 
        element_size = bytes_per_element(type);
        group_size = element_size * components;
@@ -5176,7 +5178,7 @@ static void empty_image(const PixelStorageModes *psm,
        if (padding) {
            rowsize += psm->pack_alignment - padding;
        }
-       start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize + 
+       start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize +
                psm->pack_skip_pixels * group_size;
        elements_per_line = width * components;
 
@@ -5187,18 +5189,18 @@ static void empty_image(const PixelStorageModes *psm,
                Type_Widget widget;
 
                switch(type) {
-                 case GL_UNSIGNED_BYTE_3_3_2: 
+                 case GL_UNSIGNED_BYTE_3_3_2:
                    for (k = 0; k < 3; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove332(shoveComponents,0,(void *)iter);
                    break;
                  case GL_UNSIGNED_BYTE_2_3_3_REV:
                    for (k = 0; k < 3; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove233rev(shoveComponents,0,(void *)iter);
-                   break; 
+                   break;
                  case GL_UNSIGNED_BYTE:
                    if (index_format) {
                        *iter = *iter2++;
@@ -5213,10 +5215,10 @@ static void empty_image(const PixelStorageModes *psm,
                        *((GLbyte *) iter) = *iter2++ >> 9;
                    }
                    break;
-                 case GL_UNSIGNED_SHORT_5_6_5:             
+                 case GL_UNSIGNED_SHORT_5_6_5:         
                    for (k = 0; k < 3; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove565(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5226,10 +5228,10 @@ static void empty_image(const PixelStorageModes *psm,
                       *(GLushort *)iter = widget.us[0];
                    }
                    break;
-                 case GL_UNSIGNED_SHORT_5_6_5_REV:                 
+                 case GL_UNSIGNED_SHORT_5_6_5_REV:             
                    for (k = 0; k < 3; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove565rev(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5239,10 +5241,10 @@ static void empty_image(const PixelStorageModes *psm,
                       *(GLushort *)iter = widget.us[0];
                    }
                    break;
-                  case GL_UNSIGNED_SHORT_4_4_4_4:
+                 case GL_UNSIGNED_SHORT_4_4_4_4:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove4444(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5251,10 +5253,10 @@ static void empty_image(const PixelStorageModes *psm,
                       *(GLushort *)iter = widget.us[0];
                    }
                    break;
-                  case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+                 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove4444rev(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5266,7 +5268,7 @@ static void empty_image(const PixelStorageModes *psm,
                  case GL_UNSIGNED_SHORT_5_5_5_1:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove5551(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5278,7 +5280,7 @@ static void empty_image(const PixelStorageModes *psm,
                  case GL_UNSIGNED_SHORT_1_5_5_5_REV:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove1555rev(shoveComponents,0,(void *)&widget.us[0]);
                    if (myswap_bytes) {
                       iter[0] = widget.ub[1];
@@ -5306,10 +5308,10 @@ static void empty_image(const PixelStorageModes *psm,
                        iter[1] = widget.ub[1];
                    }
                    break;
-                 case GL_UNSIGNED_INT_8_8_8_8:  
+                 case GL_UNSIGNED_INT_8_8_8_8:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove8888(shoveComponents,0,(void *)&widget.ui);
                    if (myswap_bytes) {
                        iter[3] = widget.ub[0];
@@ -5317,14 +5319,14 @@ static void empty_image(const PixelStorageModes *psm,
                        iter[1] = widget.ub[2];
                        iter[0] = widget.ub[3];
                    } else {
-                       *(GLuint *)iter= widget.ui;
+                       *(GLuint *)iter= widget.ui;
                    }
 
                    break;
-                 case GL_UNSIGNED_INT_8_8_8_8_REV:  
+                 case GL_UNSIGNED_INT_8_8_8_8_REV:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove8888rev(shoveComponents,0,(void *)&widget.ui);
                    if (myswap_bytes) {
                        iter[3] = widget.ub[0];
@@ -5332,13 +5334,13 @@ static void empty_image(const PixelStorageModes *psm,
                        iter[1] = widget.ub[2];
                        iter[0] = widget.ub[3];
                    } else {
-                       *(GLuint *)iter= widget.ui;
+                       *(GLuint *)iter= widget.ui;
                    }
                    break;
-                 case GL_UNSIGNED_INT_10_10_10_2:  
+                 case GL_UNSIGNED_INT_10_10_10_2:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove1010102(shoveComponents,0,(void *)&widget.ui);
                    if (myswap_bytes) {
                        iter[3] = widget.ub[0];
@@ -5346,13 +5348,13 @@ static void empty_image(const PixelStorageModes *psm,
                        iter[1] = widget.ub[2];
                        iter[0] = widget.ub[3];
                    } else {
-                       *(GLuint *)iter= widget.ui;
+                       *(GLuint *)iter= widget.ui;
                    }
                    break;
                  case GL_UNSIGNED_INT_2_10_10_10_REV:
                    for (k = 0; k < 4; k++) {
                       shoveComponents[k]= *iter2++ / 65535.0;
-                   } 
+                   }
                    shove2101010rev(shoveComponents,0,(void *)&widget.ui);
                    if (myswap_bytes) {
                        iter[3] = widget.ub[0];
@@ -5360,7 +5362,7 @@ static void empty_image(const PixelStorageModes *psm,
                        iter[1] = widget.ub[2];
                        iter[0] = widget.ub[3];
                    } else {
-                       *(GLuint *)iter= widget.ui;
+                       *(GLuint *)iter= widget.ui;
                    }
                    break;
                  case GL_INT:
@@ -5405,7 +5407,7 @@ static void empty_image(const PixelStorageModes *psm,
            /* want 'iter' pointing at start, not within, row for assertion
             * purposes
             */
-           iter= start;        
+           iter= start;        
 #endif
        } /* for i */
 
@@ -5418,16 +5420,16 @@ static void empty_image(const PixelStorageModes *psm,
                                     elements_per_group(format,0)]);
        }
        assert( iter == &((GLubyte *)userdata)[rowsize*height +
-                                       psm->pack_skip_rows * rowsize + 
+                                       psm->pack_skip_rows * rowsize +
                                        psm->pack_skip_pixels * group_size] );
 
     } /* else */
 } /* empty_image() */
 
 /*--------------------------------------------------------------------------
- * Decimation of packed pixel types 
+ * Decimation of packed pixel types
  *--------------------------------------------------------------------------
- */ 
+ */
 static void extract332(int isSwap,
                       const void *packedPixel, GLfloat extractComponents[])
 {
@@ -5441,11 +5443,11 @@ static void extract332(int isSwap,
 
    extractComponents[0]=   (float)((ubyte & 0xe0)  >> 5) / 7.0;
    extractComponents[1]=   (float)((ubyte & 0x1c)  >> 2) / 7.0; /* 7 = 2^3-1 */
-   extractComponents[2]=   (float)((ubyte & 0x03)      ) / 3.0;        /* 3 = 2^2-1 */
+   extractComponents[2]=   (float)((ubyte & 0x03)      ) / 3.0; /* 3 = 2^2-1 */
 } /* extract332() */
 
-static void shove332(const GLfloat shoveComponents[], 
-                    int index, void *packedPixel)             
+static void shove332(const GLfloat shoveComponents[],
+                    int index, void *packedPixel)      
 {
    /* 11100000 == 0xe0 */
    /* 00011100 == 0x1c */
@@ -5456,12 +5458,12 @@ static void shove332(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[2] && shoveComponents[2] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLubyte *)packedPixel)[index]  = 
+   ((GLubyte *)packedPixel)[index]  =
      ((GLubyte)((shoveComponents[0] * 7)+0.5)  << 5) & 0xe0;
-   ((GLubyte *)packedPixel)[index] |= 
+   ((GLubyte *)packedPixel)[index] |=
      ((GLubyte)((shoveComponents[1] * 7)+0.5)  << 2) & 0x1c;
    ((GLubyte *)packedPixel)[index]  |=
-     ((GLubyte)((shoveComponents[2] * 3)+0.5)      ) & 0x03;
+     ((GLubyte)((shoveComponents[2] * 3)+0.5)     ) & 0x03;
 } /* shove332() */
 
 static void extract233rev(int isSwap,
@@ -5472,7 +5474,7 @@ static void extract233rev(int isSwap,
    isSwap= isSwap;             /* turn off warnings */
 
    /* 0000,0111 == 0x07 */
-   /* 0011,1000 == 0x38 */  
+   /* 0011,1000 == 0x38 */
    /* 1100,0000 == 0xC0 */
 
    extractComponents[0]= (float)((ubyte & 0x07)     ) / 7.0;
@@ -5480,11 +5482,11 @@ static void extract233rev(int isSwap,
    extractComponents[2]= (float)((ubyte & 0xC0) >> 6) / 3.0;
 } /* extract233rev() */
 
-static void shove233rev(const GLfloat shoveComponents[], 
-                       int index, void *packedPixel)          
+static void shove233rev(const GLfloat shoveComponents[],
+                       int index, void *packedPixel)   
 {
    /* 0000,0111 == 0x07 */
-   /* 0011,1000 == 0x38 */  
+   /* 0011,1000 == 0x38 */
    /* 1100,0000 == 0xC0 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
@@ -5492,18 +5494,18 @@ static void shove233rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[2] && shoveComponents[2] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLubyte *)packedPixel)[index] = 
+   ((GLubyte *)packedPixel)[index] =
      ((GLubyte)((shoveComponents[0] * 7.0)+0.5)     ) & 0x07;
-   ((GLubyte *)packedPixel)[index]|= 
+   ((GLubyte *)packedPixel)[index]|=
      ((GLubyte)((shoveComponents[1] * 7.0)+0.5) << 3) & 0x38;
-   ((GLubyte *)packedPixel)[index]|= 
+   ((GLubyte *)packedPixel)[index]|=
      ((GLubyte)((shoveComponents[2] * 3.0)+0.5) << 6) & 0xC0;
 } /* shove233rev() */
 
 static void extract565(int isSwap,
                       const void *packedPixel, GLfloat extractComponents[])
 {
-   GLushort ushort= *(const GLushort *)packedPixel; 
+   GLushort ushort= *(const GLushort *)packedPixel;
 
    if (isSwap) {
      ushort= __GLU_SWAP_2_BYTES(packedPixel);
@@ -5533,18 +5535,18 @@ static void shove565(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[2] && shoveComponents[2] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index] = 
+   ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 31)+0.5) << 11) & 0xf800;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 63)+0.5) <<  5) & 0x07e0;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 31)+0.5)      ) & 0x001f;
 } /* shove565() */
 
 static void extract565rev(int isSwap,
                          const void *packedPixel, GLfloat extractComponents[])
 {
-   GLushort ushort= *(const GLushort *)packedPixel; 
+   GLushort ushort= *(const GLushort *)packedPixel;
 
    if (isSwap) {
      ushort= __GLU_SWAP_2_BYTES(packedPixel);
@@ -5557,7 +5559,7 @@ static void extract565rev(int isSwap,
    /* 00000111,11100000 == 0x07e0 */
    /* 11111000,00000000 == 0xf800 */
 
-   extractComponents[0]= (float)((ushort & 0x001F)      ) / 31.0;
+   extractComponents[0]= (float)((ushort & 0x001F)     ) / 31.0;
    extractComponents[1]= (float)((ushort & 0x07E0) >>  5) / 63.0;
    extractComponents[2]= (float)((ushort & 0xF800) >> 11) / 31.0;
 } /* extract565rev() */
@@ -5574,15 +5576,15 @@ static void shove565rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[2] && shoveComponents[2] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index] = 
+   ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 31.0)+0.5)      ) & 0x001F;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 63.0)+0.5) <<  5) & 0x07E0;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 31.0)+0.5) << 11) & 0xF800;
 } /* shove565rev() */
 
-static void extract4444(int isSwap,const void *packedPixel, 
+static void extract4444(int isSwap,const void *packedPixel,
                        GLfloat extractComponents[])
 {
    GLushort ushort;
@@ -5594,15 +5596,15 @@ static void extract4444(int isSwap,const void *packedPixel,
      ushort= *(const GLushort *)packedPixel;
    }
 
-   /* 11110000,00000000 == 0xf000 */  
-   /* 00001111,00000000 == 0x0f00 */  
-   /* 00000000,11110000 == 0x00f0 */  
-   /* 00000000,00001111 == 0x000f */  
+   /* 11110000,00000000 == 0xf000 */
+   /* 00001111,00000000 == 0x0f00 */
+   /* 00000000,11110000 == 0x00f0 */
+   /* 00000000,00001111 == 0x000f */
 
    extractComponents[0]= (float)((ushort & 0xf000) >> 12) / 15.0;/* 15=2^4-1 */
    extractComponents[1]= (float)((ushort & 0x0f00) >>  8) / 15.0;
    extractComponents[2]= (float)((ushort & 0x00f0) >>  4) / 15.0;
-   extractComponents[3]= (float)((ushort & 0x000f)      ) / 15.0;
+   extractComponents[3]= (float)((ushort & 0x000f)     ) / 15.0;
 } /* extract4444() */
 
 static void shove4444(const GLfloat shoveComponents[],
@@ -5614,17 +5616,17 @@ static void shove4444(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index] = 
+   ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 15)+0.5) << 12) & 0xf000;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 15)+0.5) <<  8) & 0x0f00;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 15)+0.5) <<  4) & 0x00f0;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[3] * 15)+0.5)      ) & 0x000f;
 } /* shove4444() */
 
-static void extract4444rev(int isSwap,const void *packedPixel, 
+static void extract4444rev(int isSwap,const void *packedPixel,
                           GLfloat extractComponents[])
 {
    GLushort ushort;
@@ -5636,13 +5638,13 @@ static void extract4444rev(int isSwap,const void *packedPixel,
      ushort= *(const GLushort *)packedPixel;
    }
 
-   /* 00000000,00001111 == 0x000f */  
-   /* 00000000,11110000 == 0x00f0 */  
-   /* 00001111,00000000 == 0x0f00 */  
-   /* 11110000,00000000 == 0xf000 */  
+   /* 00000000,00001111 == 0x000f */
+   /* 00000000,11110000 == 0x00f0 */
+   /* 00001111,00000000 == 0x0f00 */
+   /* 11110000,00000000 == 0xf000 */
 
    /* 15 = 2^4-1 */
-   extractComponents[0]= (float)((ushort & 0x000F)      ) / 15.0;
+   extractComponents[0]= (float)((ushort & 0x000F)     ) / 15.0;
    extractComponents[1]= (float)((ushort & 0x00F0) >>  4) / 15.0;
    extractComponents[2]= (float)((ushort & 0x0F00) >>  8) / 15.0;
    extractComponents[3]= (float)((ushort & 0xF000) >> 12) / 15.0;
@@ -5651,10 +5653,10 @@ static void extract4444rev(int isSwap,const void *packedPixel,
 static void shove4444rev(const GLfloat shoveComponents[],
                         int index,void *packedPixel)
 {
-   /* 00000000,00001111 == 0x000f */  
-   /* 00000000,11110000 == 0x00f0 */  
-   /* 00001111,00000000 == 0x0f00 */  
-   /* 11110000,00000000 == 0xf000 */  
+   /* 00000000,00001111 == 0x000f */
+   /* 00000000,11110000 == 0x00f0 */
+   /* 00001111,00000000 == 0x0f00 */
+   /* 11110000,00000000 == 0xf000 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5662,17 +5664,17 @@ static void shove4444rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index] =   
+   ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 15)+0.5)      ) & 0x000F;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 15)+0.5) <<  4) & 0x00F0;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 15)+0.5) <<  8) & 0x0F00;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[3] * 15)+0.5) << 12) & 0xF000;
 } /* shove4444rev() */
 
-static void extract5551(int isSwap,const void *packedPixel, 
+static void extract5551(int isSwap,const void *packedPixel,
                        GLfloat extractComponents[])
 {
    GLushort ushort;
@@ -5684,10 +5686,10 @@ static void extract5551(int isSwap,const void *packedPixel,
      ushort= *(const GLushort *)packedPixel;
    }
 
-   /* 11111000,00000000 == 0xf800 */  
-   /* 00000111,11000000 == 0x07c0 */  
-   /* 00000000,00111110 == 0x003e */  
-   /* 00000000,00000001 == 0x0001 */  
+   /* 11111000,00000000 == 0xf800 */
+   /* 00000111,11000000 == 0x07c0 */
+   /* 00000000,00111110 == 0x003e */
+   /* 00000000,00000001 == 0x0001 */
 
    extractComponents[0]=(float)((ushort & 0xf800) >> 11) / 31.0;/* 31 = 2^5-1*/
    extractComponents[1]=(float)((ushort & 0x07c0) >>  6) / 31.0;
@@ -5698,10 +5700,10 @@ static void extract5551(int isSwap,const void *packedPixel,
 static void shove5551(const GLfloat shoveComponents[],
                      int index,void *packedPixel)
 {
-   /* 11111000,00000000 == 0xf800 */  
-   /* 00000111,11000000 == 0x07c0 */  
-   /* 00000000,00111110 == 0x003e */  
-   /* 00000000,00000001 == 0x0001 */  
+   /* 11111000,00000000 == 0xf800 */
+   /* 00000111,11000000 == 0x07c0 */
+   /* 00000000,00111110 == 0x003e */
+   /* 00000000,00000001 == 0x0001 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5709,17 +5711,17 @@ static void shove5551(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index]  = 
+   ((GLushort *)packedPixel)[index]  =
      ((GLushort)((shoveComponents[0] * 31)+0.5) << 11) & 0xf800;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 31)+0.5) <<  6) & 0x07c0;
-   ((GLushort *)packedPixel)[index]|= 
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 31)+0.5) <<  1) & 0x003e;
-   ((GLushort *)packedPixel)[index]|= 
-     ((GLushort)((shoveComponents[3])+0.5)           ) & 0x0001;
+   ((GLushort *)packedPixel)[index]|=
+     ((GLushort)((shoveComponents[3])+0.5)          ) & 0x0001;
 } /* shove5551() */
 
-static void extract1555rev(int isSwap,const void *packedPixel, 
+static void extract1555rev(int isSwap,const void *packedPixel,
                           GLfloat extractComponents[])
 {
    GLushort ushort;
@@ -5731,13 +5733,13 @@ static void extract1555rev(int isSwap,const void *packedPixel,
      ushort= *(const GLushort *)packedPixel;
    }
 
-   /* 00000000,00011111 == 0x001F */  
-   /* 00000011,11100000 == 0x03E0 */  
-   /* 01111100,00000000 == 0x7C00 */  
-   /* 10000000,00000000 == 0x8000 */  
+   /* 00000000,00011111 == 0x001F */
+   /* 00000011,11100000 == 0x03E0 */
+   /* 01111100,00000000 == 0x7C00 */
+   /* 10000000,00000000 == 0x8000 */
 
    /* 31 = 2^5-1 */
-   extractComponents[0]= (float)((ushort & 0x001F)      ) / 31.0;  
+   extractComponents[0]= (float)((ushort & 0x001F)     ) / 31.0;
    extractComponents[1]= (float)((ushort & 0x03E0) >>  5) / 31.0;
    extractComponents[2]= (float)((ushort & 0x7C00) >> 10) / 31.0;
    extractComponents[3]= (float)((ushort & 0x8000) >> 15);
@@ -5746,10 +5748,10 @@ static void extract1555rev(int isSwap,const void *packedPixel,
 static void shove1555rev(const GLfloat shoveComponents[],
                         int index,void *packedPixel)
 {
-   /* 00000000,00011111 == 0x001F */  
-   /* 00000011,11100000 == 0x03E0 */  
-   /* 01111100,00000000 == 0x7C00 */  
-   /* 10000000,00000000 == 0x8000 */  
+   /* 00000000,00011111 == 0x001F */
+   /* 00000011,11100000 == 0x03E0 */
+   /* 01111100,00000000 == 0x7C00 */
+   /* 10000000,00000000 == 0x8000 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5757,15 +5759,15 @@ static void shove1555rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLushort *)packedPixel)[index] =   
+   ((GLushort *)packedPixel)[index] =
      ((GLushort)((shoveComponents[0] * 31)+0.5)      ) & 0x001F;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[1] * 31)+0.5) <<  5) & 0x03E0;
-   ((GLushort *)packedPixel)[index]|=   
+   ((GLushort *)packedPixel)[index]|=
      ((GLushort)((shoveComponents[2] * 31)+0.5) << 10) & 0x7C00;
-   ((GLushort *)packedPixel)[index]|=   
-     ((GLushort)((shoveComponents[3])+0.5)      << 15) & 0x8000;
-} /* shove1555rev() */ 
+   ((GLushort *)packedPixel)[index]|=
+     ((GLushort)((shoveComponents[3])+0.5)     << 15) & 0x8000;
+} /* shove1555rev() */
 
 static void extract8888(int isSwap,
                        const void *packedPixel, GLfloat extractComponents[])
@@ -5779,25 +5781,25 @@ static void extract8888(int isSwap,
      uint= *(const GLuint *)packedPixel;
    }
 
-   /* 11111111,00000000,00000000,00000000 == 0xff000000 */  
-   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */  
-   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */  
-   /* 00000000,00000000,00000000,11111111 == 0x000000ff */  
+   /* 11111111,00000000,00000000,00000000 == 0xff000000 */
+   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
+   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
+   /* 00000000,00000000,00000000,11111111 == 0x000000ff */
 
    /* 255 = 2^8-1 */
    extractComponents[0]= (float)((uint & 0xff000000) >> 24) / 255.0;
    extractComponents[1]= (float)((uint & 0x00ff0000) >> 16) / 255.0;
    extractComponents[2]= (float)((uint & 0x0000ff00) >>  8) / 255.0;
-   extractComponents[3]= (float)((uint & 0x000000ff)      ) / 255.0;
+   extractComponents[3]= (float)((uint & 0x000000ff)     ) / 255.0;
 } /* extract8888() */
 
 static void shove8888(const GLfloat shoveComponents[],
                      int index,void *packedPixel)
 {
-   /* 11111111,00000000,00000000,00000000 == 0xff000000 */  
-   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */  
-   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */  
-   /* 00000000,00000000,00000000,11111111 == 0x000000ff */  
+   /* 11111111,00000000,00000000,00000000 == 0xff000000 */
+   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
+   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
+   /* 00000000,00000000,00000000,11111111 == 0x000000ff */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5805,14 +5807,14 @@ static void shove8888(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLuint *)packedPixel)[index] = 
+   ((GLuint *)packedPixel)[index] =
      ((GLuint)((shoveComponents[0] * 255)+0.5) << 24) & 0xff000000;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[1] * 255)+0.5) << 16) & 0x00ff0000;
-   ((GLuint *)packedPixel)[index]|=    
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[2] * 255)+0.5) <<  8) & 0x0000ff00;
-   ((GLuint *)packedPixel)[index]|=    
-     ((GLuint)((shoveComponents[3] * 255)+0.5)      ) & 0x000000ff;
+   ((GLuint *)packedPixel)[index]|=
+     ((GLuint)((shoveComponents[3] * 255)+0.5)     ) & 0x000000ff;
 } /* shove8888() */
 
 static void extract8888rev(int isSwap,
@@ -5827,13 +5829,13 @@ static void extract8888rev(int isSwap,
      uint= *(const GLuint *)packedPixel;
    }
 
-   /* 00000000,00000000,00000000,11111111 == 0x000000ff */  
-   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */  
-   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */  
-   /* 11111111,00000000,00000000,00000000 == 0xff000000 */  
+   /* 00000000,00000000,00000000,11111111 == 0x000000ff */
+   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
+   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
+   /* 11111111,00000000,00000000,00000000 == 0xff000000 */
 
    /* 255 = 2^8-1 */
-   extractComponents[0]= (float)((uint & 0x000000FF)      ) / 255.0; 
+   extractComponents[0]= (float)((uint & 0x000000FF)     ) / 255.0;
    extractComponents[1]= (float)((uint & 0x0000FF00) >>  8) / 255.0;
    extractComponents[2]= (float)((uint & 0x00FF0000) >> 16) / 255.0;
    extractComponents[3]= (float)((uint & 0xFF000000) >> 24) / 255.0;
@@ -5842,10 +5844,10 @@ static void extract8888rev(int isSwap,
 static void shove8888rev(const GLfloat shoveComponents[],
                         int index,void *packedPixel)
 {
-   /* 00000000,00000000,00000000,11111111 == 0x000000ff */  
-   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */  
-   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */  
-   /* 11111111,00000000,00000000,00000000 == 0xff000000 */  
+   /* 00000000,00000000,00000000,11111111 == 0x000000ff */
+   /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
+   /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
+   /* 11111111,00000000,00000000,00000000 == 0xff000000 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5853,13 +5855,13 @@ static void shove8888rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLuint *)packedPixel)[index] = 
-     ((GLuint)((shoveComponents[0] * 255)+0.5)      ) & 0x000000FF;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index] =
+     ((GLuint)((shoveComponents[0] * 255)+0.5)     ) & 0x000000FF;
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[1] * 255)+0.5) <<  8) & 0x0000FF00;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[2] * 255)+0.5) << 16) & 0x00FF0000;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[3] * 255)+0.5) << 24) & 0xFF000000;
 } /* shove8888rev() */
 
@@ -5875,25 +5877,25 @@ static void extract1010102(int isSwap,
      uint= *(const GLuint *)packedPixel;
    }
 
-   /* 11111111,11000000,00000000,00000000 == 0xffc00000 */  
-   /* 00000000,00111111,11110000,00000000 == 0x003ff000 */  
-   /* 00000000,00000000,00001111,11111100 == 0x00000ffc */  
-   /* 00000000,00000000,00000000,00000011 == 0x00000003 */  
+   /* 11111111,11000000,00000000,00000000 == 0xffc00000 */
+   /* 00000000,00111111,11110000,00000000 == 0x003ff000 */
+   /* 00000000,00000000,00001111,11111100 == 0x00000ffc */
+   /* 00000000,00000000,00000000,00000011 == 0x00000003 */
 
    /* 1023 = 2^10-1 */
-   extractComponents[0]= (float)((uint & 0xffc00000) >> 22) / 1023.0; 
+   extractComponents[0]= (float)((uint & 0xffc00000) >> 22) / 1023.0;
    extractComponents[1]= (float)((uint & 0x003ff000) >> 12) / 1023.0;
    extractComponents[2]= (float)((uint & 0x00000ffc) >>  2) / 1023.0;
-   extractComponents[3]= (float)((uint & 0x00000003)      ) / 3.0;
+   extractComponents[3]= (float)((uint & 0x00000003)     ) / 3.0;
 } /* extract1010102() */
 
 static void shove1010102(const GLfloat shoveComponents[],
                         int index,void *packedPixel)
 {
-   /* 11111111,11000000,00000000,00000000 == 0xffc00000 */  
-   /* 00000000,00111111,11110000,00000000 == 0x003ff000 */  
-   /* 00000000,00000000,00001111,11111100 == 0x00000ffc */  
-   /* 00000000,00000000,00000000,00000011 == 0x00000003 */  
+   /* 11111111,11000000,00000000,00000000 == 0xffc00000 */
+   /* 00000000,00111111,11110000,00000000 == 0x003ff000 */
+   /* 00000000,00000000,00001111,11111100 == 0x00000ffc */
+   /* 00000000,00000000,00000000,00000011 == 0x00000003 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5901,15 +5903,15 @@ static void shove1010102(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLuint *)packedPixel)[index] = 
+   ((GLuint *)packedPixel)[index] =
      ((GLuint)((shoveComponents[0] * 1023)+0.5) << 22) & 0xffc00000;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[1] * 1023)+0.5) << 12) & 0x003ff000;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[2] * 1023)+0.5) <<  2) & 0x00000ffc;
-   ((GLuint *)packedPixel)[index]|= 
-     ((GLuint)((shoveComponents[3] * 3)+0.5)         ) & 0x00000003;
-} /* shove1010102() */ 
+   ((GLuint *)packedPixel)[index]|=
+     ((GLuint)((shoveComponents[3] * 3)+0.5)        ) & 0x00000003;
+} /* shove1010102() */
 
 static void extract2101010rev(int isSwap,
                              const void *packedPixel,
@@ -5924,26 +5926,26 @@ static void extract2101010rev(int isSwap,
      uint= *(const GLuint *)packedPixel;
    }
 
-   /* 00000000,00000000,00000011,11111111 == 0x000003FF */  
-   /* 00000000,00001111,11111100,00000000 == 0x000FFC00 */  
-   /* 00111111,11110000,00000000,00000000 == 0x3FF00000 */  
-   /* 11000000,00000000,00000000,00000000 == 0xC0000000 */  
+   /* 00000000,00000000,00000011,11111111 == 0x000003FF */
+   /* 00000000,00001111,11111100,00000000 == 0x000FFC00 */
+   /* 00111111,11110000,00000000,00000000 == 0x3FF00000 */
+   /* 11000000,00000000,00000000,00000000 == 0xC0000000 */
 
    /* 1023 = 2^10-1 */
-   extractComponents[0]= (float)((uint & 0x000003FF)      ) / 1023.0;  
+   extractComponents[0]= (float)((uint & 0x000003FF)     ) / 1023.0;
    extractComponents[1]= (float)((uint & 0x000FFC00) >> 10) / 1023.0;
    extractComponents[2]= (float)((uint & 0x3FF00000) >> 20) / 1023.0;
-   extractComponents[3]= (float)((uint & 0xC0000000) >> 30) / 3.0;  
+   extractComponents[3]= (float)((uint & 0xC0000000) >> 30) / 3.0;
    /* 3 = 2^2-1 */
 } /* extract2101010rev() */
 
 static void shove2101010rev(const GLfloat shoveComponents[],
                            int index,void *packedPixel)
 {
-   /* 00000000,00000000,00000011,11111111 == 0x000003FF */  
-   /* 00000000,00001111,11111100,00000000 == 0x000FFC00 */  
-   /* 00111111,11110000,00000000,00000000 == 0x3FF00000 */  
-   /* 11000000,00000000,00000000,00000000 == 0xC0000000 */  
+   /* 00000000,00000000,00000011,11111111 == 0x000003FF */
+   /* 00000000,00001111,11111100,00000000 == 0x000FFC00 */
+   /* 00111111,11110000,00000000,00000000 == 0x3FF00000 */
+   /* 11000000,00000000,00000000,00000000 == 0xC0000000 */
 
    assert(0.0 <= shoveComponents[0] && shoveComponents[0] <= 1.0);
    assert(0.0 <= shoveComponents[1] && shoveComponents[1] <= 1.0);
@@ -5951,14 +5953,14 @@ static void shove2101010rev(const GLfloat shoveComponents[],
    assert(0.0 <= shoveComponents[3] && shoveComponents[3] <= 1.0);
 
    /* due to limited precision, need to round before shoving */
-   ((GLuint *)packedPixel)[index] = 
+   ((GLuint *)packedPixel)[index] =
      ((GLuint)((shoveComponents[0] * 1023)+0.5)      ) & 0x000003FF;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[1] * 1023)+0.5) << 10) & 0x000FFC00;
-   ((GLuint *)packedPixel)[index]|= 
+   ((GLuint *)packedPixel)[index]|=
      ((GLuint)((shoveComponents[2] * 1023)+0.5) << 20) & 0x3FF00000;
-   ((GLuint *)packedPixel)[index]|= 
-     ((GLuint)((shoveComponents[3] * 3)+0.5)    << 30) & 0xC0000000;
+   ((GLuint *)packedPixel)[index]|=
+     ((GLuint)((shoveComponents[3] * 3)+0.5)   << 30) & 0xC0000000;
 } /* shove2101010rev() */
 
 static void scaleInternalPackedPixel(int components,
@@ -5966,7 +5968,7 @@ static void scaleInternalPackedPixel(int components,
                                     (int, const void *,GLfloat []),
                                     void (*shovePackedPixel)
                                     (const GLfloat [], int, void *),
-                                    GLint widthIn,GLint heightIn, 
+                                    GLint widthIn,GLint heightIn,
                                     const void *dataIn,
                                     GLint widthOut,GLint heightOut,
                                     void *dataOut,
@@ -6007,7 +6009,7 @@ static void scaleInternalPackedPixel(int components,
     convy_float = convy - convy_int;
     convx_int = floor(convx);
     convx_float = convx - convx_int;
-   
+
     area = convx * convy;
 
     lowy_int = 0;
@@ -6034,118 +6036,118 @@ static void scaleInternalPackedPixel(int components,
            if((highy_int>lowy_int) && (highx_int>lowx_int)) {
 
                y_percent = 1-lowy_float;
-               temp = (const char *)dataIn + xindex + lowy_int * rowSizeInBytes;
+               temp = (const char *)dataIn + xindex + lowy_int * rowSizeInBytes;
                percent = y_percent * (1-lowx_float);
 #if 0
-               for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
                    if (myswap_bytes) {
                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
                    } else {
-                       totals[k] += *(const GLushort*)temp_index * percent;
+                       totals[k] += *(const GLushort*)temp_index * percent;
                    }
-               }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
                left = temp;
-               for(l = lowx_int+1; l < highx_int; l++) {
+               for(l = lowx_int+1; l < highx_int; l++) {
                    temp += pixelSizeInBytes;
 #if 0
-                   for (k = 0, temp_index = temp; k < components; 
+                   for (k = 0, temp_index = temp; k < components;
                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
                    }
 #else
                    (*extractPackedPixel)(isSwap,temp,extractTotals);
                    for (k = 0; k < components; k++) {
                       totals[k]+= extractTotals[k] * y_percent;
-                   } 
+                   }
 #endif
-               }
+               }
                temp += pixelSizeInBytes;
                right = temp;
                percent = y_percent * highx_float;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
 
                /* calculate the value for pixels in the last row */
-               
+               
                y_percent = highy_float;
                percent = y_percent * (1-lowx_float);
                temp = (const char *)dataIn + xindex + highy_int * rowSizeInBytes;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
                for(l = lowx_int+1; l < highx_int; l++) {
-                    temp += pixelSizeInBytes;
+                   temp += pixelSizeInBytes;
 #if 0
-                    for (k = 0, temp_index = temp; k < components; 
+                   for (k = 0, temp_index = temp; k < components;
                         k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                                 __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
-                    }
+                       if (myswap_bytes) {
+                           totals[k] +=
+                                __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
+                   }
 #else
                    (*extractPackedPixel)(isSwap,temp,extractTotals);
                    for (k = 0; k < components; k++) {
                       totals[k]+= extractTotals[k] * y_percent;
-                   } 
+                   }
 #endif
 
-                }
-                temp += pixelSizeInBytes;
+               }
+               temp += pixelSizeInBytes;
                percent = y_percent * highx_float;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
 
                /* calculate the value for pixels in the 1st and last column */
@@ -6153,23 +6155,23 @@ static void scaleInternalPackedPixel(int components,
                    left += rowSizeInBytes;
                    right += rowSizeInBytes;
 #if 0
-                    for (k = 0; k < components; 
-                        k++, left += element_size, right += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                               __GLU_SWAP_2_BYTES(left) * (1-lowx_float) +
-                               __GLU_SWAP_2_BYTES(right) * highx_float;
-                        } else {
-                            totals[k] += *(const GLushort*)left * (1-lowx_float)
-                                       + *(const GLushort*)right * highx_float;
-                        }
+                   for (k = 0; k < components;
+                        k++, left += element_size, right += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                               __GLU_SWAP_2_BYTES(left) * (1-lowx_float) +
+                               __GLU_SWAP_2_BYTES(right) * highx_float;
+                       } else {
+                           totals[k] += *(const GLushort*)left * (1-lowx_float)
+                                      + *(const GLushort*)right * highx_float;
+                       }
                    }
 #else
                    (*extractPackedPixel)(isSwap,left,extractTotals);
                    (*extractPackedPixel)(isSwap,right,extractMoreTotals);
                    for (k = 0; k < components; k++) {
                       totals[k]+= (extractTotals[k]*(1-lowx_float) +
-                                  extractMoreTotals[k]*highx_float);
+                                  extractMoreTotals[k]*highx_float);
                    }
 #endif
                }
@@ -6178,128 +6180,128 @@ static void scaleInternalPackedPixel(int components,
                percent = (1-lowy_float)*x_percent;
                temp = (const char *)dataIn + xindex + lowy_int*rowSizeInBytes;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-               }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
                for(m = lowy_int+1; m < highy_int; m++) {
                    temp += rowSizeInBytes;
 #if 0
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
                                __GLU_SWAP_2_BYTES(temp_index) * x_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * x_percent;
-                        }
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * x_percent;
+                       }
                    }
 #else
                    (*extractPackedPixel)(isSwap,temp,extractTotals);
                    for (k = 0; k < components; k++) {
                       totals[k]+= extractTotals[k] * x_percent;
-                   } 
+                   }
 #endif
                }
                percent = x_percent * highy_float;
                temp += rowSizeInBytes;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
            } else if (highx_int > lowx_int) {
                y_percent = highy_float - lowy_float;
                percent = (1-lowx_float)*y_percent;
                temp = (const char *)dataIn + xindex + lowy_int*rowSizeInBytes;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
                for (l = lowx_int+1; l < highx_int; l++) {
-                    temp += pixelSizeInBytes;
+                   temp += pixelSizeInBytes;
 #if 0
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += 
-                               __GLU_SWAP_2_BYTES(temp_index) * y_percent;
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index * y_percent;
-                        }
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] +=
+                               __GLU_SWAP_2_BYTES(temp_index) * y_percent;
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index * y_percent;
+                       }
                    }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * y_percent;
-               } 
+               }
 #endif
                }
                temp += pixelSizeInBytes;
                percent = y_percent * highx_float;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
                }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
            } else {
                percent = (highy_float-lowy_float)*(highx_float-lowx_float);
                temp = (const char *)dataIn + xindex + lowy_int * rowSizeInBytes;
 #if 0
-                for (k = 0, temp_index = temp; k < components; 
+               for (k = 0, temp_index = temp; k < components;
                     k++, temp_index += element_size) {
-                    if (myswap_bytes) {
-                        totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
-                    } else {
-                        totals[k] += *(const GLushort*)temp_index * percent;
-                    }
-                }
+                   if (myswap_bytes) {
+                       totals[k] += __GLU_SWAP_2_BYTES(temp_index) * percent;
+                   } else {
+                       totals[k] += *(const GLushort*)temp_index * percent;
+                   }
+               }
 #else
                (*extractPackedPixel)(isSwap,temp,extractTotals);
                for (k = 0; k < components; k++) {
                   totals[k]+= extractTotals[k] * percent;
-               } 
+               }
 #endif
            }
 
@@ -6309,23 +6311,23 @@ static void scaleInternalPackedPixel(int components,
                temp = temp0;
                for(l = lowx_int+1; l < highx_int; l++) {
 #if 0
-                    for (k = 0, temp_index = temp; k < components; 
-                        k++, temp_index += element_size) {
-                        if (myswap_bytes) {
-                            totals[k] += __GLU_SWAP_2_BYTES(temp_index);
-                        } else {
-                            totals[k] += *(const GLushort*)temp_index;
-                        }
-                    }
+                   for (k = 0, temp_index = temp; k < components;
+                        k++, temp_index += element_size) {
+                       if (myswap_bytes) {
+                           totals[k] += __GLU_SWAP_2_BYTES(temp_index);
+                       } else {
+                           totals[k] += *(const GLushort*)temp_index;
+                       }
+                   }
 #else
                    (*extractPackedPixel)(isSwap,temp,extractTotals);
                    for (k = 0; k < components; k++) {
                       totals[k]+= extractTotals[k];
-                   } 
+                   }
 #endif
-                    temp += pixelSizeInBytes;
-                }
-               temp0 += rowSizeInBytes;
+                   temp += pixelSizeInBytes;
+               }
+               temp0 += rowSizeInBytes;
            }
 
            outindex = (j + (i * widthOut)); /* * (components == 1) */
@@ -6336,14 +6338,14 @@ static void scaleInternalPackedPixel(int components,
            }
 #else
            for (k = 0; k < components; k++) {
-               shoveTotals[k]= totals[k]/area;
+               shoveTotals[k]= totals[k]/area;
            }
            (*shovePackedPixel)(shoveTotals,outindex,(void *)dataOut);
 #endif
            lowx_int = highx_int;
            lowx_float = highx_float;
            highx_int += convx_int;
-           highx_float += convx_float;
+           highx_float += convx_float;
            if(highx_float > 1) {
                highx_float -= 1.0;
                highx_int++;
@@ -6362,17 +6364,17 @@ static void scaleInternalPackedPixel(int components,
     assert(outindex == (widthOut*heightOut - 1));
 } /* scaleInternalPackedPixel() */
 
-/* rowSizeInBytes is at least the width (in bytes) due to padding on 
- *  inputs; not always equal. Output NEVER has row padding.  
+/* rowSizeInBytes is at least the width (in bytes) due to padding on
+ *  inputs; not always equal. Output NEVER has row padding.
  */
 static void halveImagePackedPixel(int components,
                                  void (*extractPackedPixel)
                                  (int, const void *,GLfloat []),
                                  void (*shovePackedPixel)
                                  (const GLfloat [],int, void *),
-                                 GLint width, GLint height, 
+                                 GLint width, GLint height,
                                  const void *dataIn, void *dataOut,
-                                 GLint pixelSizeInBytes, 
+                                 GLint pixelSizeInBytes,
                                  GLint rowSizeInBytes, GLint isSwap)
 {
    /* handle case where there is only 1 column/row */
@@ -6409,13 +6411,13 @@ static void halveImagePackedPixel(int components,
            (*extractPackedPixel)(isSwap,
                                  (src+rowSizeInBytes+pixelSizeInBytes),
                                  &extractTotals[3][0]);
-           for (cc = 0; cc < components; cc++) { 
+           for (cc = 0; cc < components; cc++) {
               int kk;
 
               /* grab 4 pixels to average */
               totals[cc]= 0.0;
               /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-               *              extractTotals[2][RED]+extractTotals[3][RED];
+               *              extractTotals[2][RED]+extractTotals[3][RED];
                * totals[RED]/= 4.0;
                */
               for (kk = 0; kk < BOX4; kk++) {
@@ -6434,13 +6436,13 @@ static void halveImagePackedPixel(int components,
 
         /* src is at beginning of a row here, but it's the second row of
          * the square block of 4 pixels that we just worked on so we
-         * need to go one more row.  
-         * i.e.,             
-         *                   OO... 
-         *           here -->OO...
-         *       but want -->OO...
-         *                   OO... 
-         *                   ...
+         * need to go one more row.
+         * i.e.,
+         *                   OO...
+         *           here -->OO...
+         *       but want -->OO...
+         *                   OO...
+         *                   ...
          */
         src+= rowSizeInBytes;
       }
@@ -6456,9 +6458,9 @@ static void halve1DimagePackedPixel(int components,
                                    (int, const void *,GLfloat []),
                                    void (*shovePackedPixel)
                                    (const GLfloat [],int, void *),
-                                   GLint width, GLint height, 
+                                   GLint width, GLint height,
                                    const void *dataIn, void *dataOut,
-                                   GLint pixelSizeInBytes, 
+                                   GLint pixelSizeInBytes,
                                    GLint rowSizeInBytes, GLint isSwap)
 {
    int halfWidth= width / 2;
@@ -6487,8 +6489,8 @@ static void halve1DimagePackedPixel(int components,
         (*extractPackedPixel)(isSwap,src,
                               &extractTotals[0][0]);
         (*extractPackedPixel)(isSwap,(src+pixelSizeInBytes),
-                              &extractTotals[1][0]);                          
-        for (cc = 0; cc < components; cc++) { 
+                              &extractTotals[1][0]);                   
+        for (cc = 0; cc < components; cc++) {
            int kk;
 
            /* grab 2 pixels to average */
@@ -6509,7 +6511,7 @@ static void halve1DimagePackedPixel(int components,
       }
 
       {
-        int padBytes= rowSizeInBytes - (width*pixelSizeInBytes); 
+        int padBytes= rowSizeInBytes - (width*pixelSizeInBytes);
         src+= padBytes;        /* for assertion only */
       }
       assert(src == &((const char *)dataIn)[rowSizeInBytes]);
@@ -6533,8 +6535,8 @@ static void halve1DimagePackedPixel(int components,
         (*extractPackedPixel)(isSwap,src,
                               &extractTotals[0][0]);
         (*extractPackedPixel)(isSwap,(src+rowSizeInBytes),
-                              &extractTotals[1][0]);                          
-        for (cc = 0; cc < components; cc++) { 
+                              &extractTotals[1][0]);                   
+        for (cc = 0; cc < components; cc++) {
            int kk;
 
            /* grab 2 pixels to average */
@@ -6568,13 +6570,13 @@ static void halve1DimagePackedPixel(int components,
  * Or is it might be supported as an extension.
  * Contributed by Gerk Huisma <gerk@five-d.demon.nl>.
  */
+
 typedef GLAPI void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,
-                                                 GLenum internalFormat,
-                                                 GLsizei width, GLsizei height,
-                                                 GLsizei depth, GLint border,
-                                                 GLenum format, GLenum type,
-                                                 const GLvoid *pixels );
+                                                GLenum internalFormat,
+                                                GLsizei width, GLsizei height,
+                                                GLsizei depth, GLint border,
+                                                GLenum format, GLenum type,
+                                                const GLvoid *pixels );
 
 static TexImage3Dproc pTexImage3D;
 
@@ -6586,30 +6588,30 @@ static TexImage3Dproc pTexImage3D;
 #endif
 
 static void gluTexImage3D( GLenum target, GLint level,
-                           GLenum internalFormat,
-                           GLsizei width, GLsizei height,
-                           GLsizei depth, GLint border,
-                           GLenum format, GLenum type,
-                           const GLvoid *pixels )
+                          GLenum internalFormat,
+                          GLsizei width, GLsizei height,
+                          GLsizei depth, GLint border,
+                          GLenum format, GLenum type,
+                          const GLvoid *pixels )
 {
    if (!pTexImage3D) {
 #ifdef WIN32
       pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D");
-      if (!pTexImage3D) 
-         pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");
+      if (!pTexImage3D)
+        pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");
 #else
       void *libHandle = dlopen("libgl.so", RTLD_LAZY);
       pTexImage3D = TexImage3Dproc) dlsym(libHandle, "glTexImage3D" );
-      if (!pTexImage3D) 
-         pTexImage3D = (TexImage3Dproc) dlsym(libHandle,"glTexImage3DEXT");
+      if (!pTexImage3D)
+        pTexImage3D = (TexImage3Dproc) dlsym(libHandle,"glTexImage3DEXT");
       dlclose(libHandle);
 #endif
    }
 
    /* Now call glTexImage3D */
-   if (pTexImage3D) 
-      pTexImage3D(target, level, internalFormat, width, height, 
-                  depth, border, format, type, pixels);
+   if (pTexImage3D)
+      pTexImage3D(target, level, internalFormat, width, height,
+                 depth, border, format, type, pixels);
 }
 
 #else
@@ -6620,10 +6622,10 @@ static void gluTexImage3D( GLenum target, GLint level,
 #endif
 
 static GLint imageSize3D(GLint width, GLint height, GLint depth,
-                        GLenum format, GLenum type) 
+                        GLenum format, GLenum type)
 {
     int components= elements_per_group(format,type);
-    int bytes_per_row=  bytes_per_element(type) * width;
+    int bytes_per_row= bytes_per_element(type) * width;
 
 assert(width > 0 && height > 0 && depth > 0);
 assert(type != GL_BITMAP);
@@ -6631,9 +6633,9 @@ assert(type != GL_BITMAP);
     return bytes_per_row * height * depth * components;
 } /* imageSize3D() */
 
-static void fillImage3D(const PixelStorageModes *psm, 
-                       GLint width, GLint height, GLint depth, GLenum format, 
-                       GLenum type, GLboolean indexFormat, 
+static void fillImage3D(const PixelStorageModes *psm,
+                       GLint width, GLint height, GLint depth, GLenum format,
+                       GLenum type, GLboolean indexFormat,
                        const void *userImage, GLushort *newImage)
 {
    int myswapBytes;
@@ -6646,10 +6648,10 @@ static void fillImage3D(const PixelStorageModes *psm,
    int elementsPerLine;
    int rowsPerImage;
    int imageSize;
-   const GLubyte *start, *rowStart, *iter; 
+   const GLubyte *start, *rowStart, *iter;
    GLushort *iter2;
-   int ww, hh, dd, k; 
-   
+   int ww, hh, dd, k;
+
    myswapBytes= psm->unpack_swap_bytes;
    components= elements_per_group(format,type);
    if (psm->unpack_row_length > 0) {
@@ -6663,8 +6665,8 @@ static void fillImage3D(const PixelStorageModes *psm,
    if (elementSize == 1) myswapBytes= 0;
 
    /* 3dstuff begin */
-   if (psm->unpack_image_height > 0) { 
-      rowsPerImage= psm->unpack_image_height; 
+   if (psm->unpack_image_height > 0) {
+      rowsPerImage= psm->unpack_image_height;
    }
    else {
       rowsPerImage= height;
@@ -6679,10 +6681,10 @@ static void fillImage3D(const PixelStorageModes *psm,
 
    imageSize= rowsPerImage * rowSize; /* 3dstuff */
 
-   start= (const GLubyte *)userImage + psm->unpack_skip_rows * rowSize + 
-                                 psm->unpack_skip_pixels * groupSize +
-                                 /*3dstuff*/
-                                 psm->unpack_skip_images * imageSize;
+   start= (const GLubyte *)userImage + psm->unpack_skip_rows * rowSize +
+                                psm->unpack_skip_pixels * groupSize +
+                                /*3dstuff*/
+                                psm->unpack_skip_images * imageSize;
    elementsPerLine = width * components;
 
    iter2= newImage;
@@ -6718,37 +6720,37 @@ static void fillImage3D(const PixelStorageModes *psm,
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_BYTE_2_3_3_REV:  
+           case GL_UNSIGNED_BYTE_2_3_3_REV:
              extract233rev(0,iter,extractComponents);
              for (k = 0; k < 3; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_SHORT_5_6_5:                                   
+           case GL_UNSIGNED_SHORT_5_6_5:                               
              extract565(myswapBytes,iter,extractComponents);
              for (k = 0; k < 3; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_SHORT_5_6_5_REV:                               
+           case GL_UNSIGNED_SHORT_5_6_5_REV:                           
              extract565rev(myswapBytes,iter,extractComponents);
              for (k = 0; k < 3; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_SHORT_4_4_4_4:                 
+           case GL_UNSIGNED_SHORT_4_4_4_4:             
              extract4444(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_SHORT_4_4_4_4_REV:             
+           case GL_UNSIGNED_SHORT_4_4_4_4_REV:         
              extract4444rev(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_SHORT_5_5_5_1:                 
+           case GL_UNSIGNED_SHORT_5_5_5_1:             
              extract5551(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
@@ -6780,19 +6782,19 @@ static void fillImage3D(const PixelStorageModes *psm,
                  *iter2++ = widget.us[0];
              }
              break;
-           case GL_UNSIGNED_INT_8_8_8_8:                   
+           case GL_UNSIGNED_INT_8_8_8_8:               
              extract8888(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_INT_8_8_8_8_REV:               
+           case GL_UNSIGNED_INT_8_8_8_8_REV:           
              extract8888rev(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
              }
              break;
-           case GL_UNSIGNED_INT_10_10_10_2:                
+           case GL_UNSIGNED_INT_10_10_10_2:            
              extract1010102(myswapBytes,iter,extractComponents);
              for (k = 0; k < 4; k++) {
                *iter2++ = (GLushort)(extractComponents[k]*65535);
@@ -6838,8 +6840,8 @@ static void fillImage3D(const PixelStorageModes *psm,
                  }
              }
              break;
-            default:
-             assert(0);
+           default:
+             assert(0);
            }
 
            iter+= elementSize;
@@ -6861,13 +6863,13 @@ static void fillImage3D(const PixelStorageModes *psm,
                                elements_per_group(format,0)]);
    }
    assert( iter == &((const GLubyte *)userImage)[rowSize*height*depth +
-                                       psm->unpack_skip_rows * rowSize + 
+                                       psm->unpack_skip_rows * rowSize +
                                        psm->unpack_skip_pixels * groupSize +
                                        /*3dstuff*/
                                        psm->unpack_skip_images * imageSize] );
 } /* fillImage3D () */
 
-static void scaleInternal3D(GLint components, 
+static void scaleInternal3D(GLint components,
                            GLint widthIn, GLint heightIn, GLint depthIn,
                            const GLushort *dataIn,
                            GLint widthOut, GLint heightOut, GLint depthOut,
@@ -6876,7 +6878,7 @@ static void scaleInternal3D(GLint components,
     float x, lowx, highx, convx, halfconvx;
     float y, lowy, highy, convy, halfconvy;
     float z, lowz, highz, convz, halfconvz;
-    float xpercent,ypercent,zpercent; 
+    float xpercent,ypercent,zpercent;
     float percent;
     /* Max components in a format is 4, so... */
     float totals[4];
@@ -6890,7 +6892,7 @@ static void scaleInternal3D(GLint components,
     halfconvx = convx/2;
     halfconvy = convy/2;
     halfconvz = convz/2;
-    for (d = 0; d < depthOut; d++) { 
+    for (d = 0; d < depthOut; d++) {
        z = convz * (d+0.5);
        if (depthIn > depthOut) {
           highz = z + halfconvz;
@@ -6960,11 +6962,11 @@ static void scaleInternal3D(GLint components,
                          percent = xpercent * ypercent * zpercent;
                          volume += percent;
 
-                         temp = (xindex + (yindex*widthIn) + 
+                         temp = (xindex + (yindex*widthIn) +
                                  (zindex*widthIn*heightIn)) * components;
                          for (k = 0; k < components; k++) {
-                             assert(0 <= (temp+k) && 
-                                    (temp+k) < 
+                             assert(0 <= (temp+k) &&
+                                    (temp+k) <
                                     (widthIn*heightIn*depthIn*components));
                              totals[k] += dataIn[temp + k] * percent;
                          }
@@ -6981,13 +6983,13 @@ static void scaleInternal3D(GLint components,
                  z = zint;
               } /* while z */
 
-              temp = (j + (i * widthOut) + 
+              temp = (j + (i * widthOut) +
                       (d*widthOut*heightOut)) * components;
               for (k = 0; k < components; k++) {
-                  /* totals[] should be rounded in the case of enlarging an 
+                  /* totals[] should be rounded in the case of enlarging an
                    * RGB ramp when the type is 332 or 4444
                    */
-                  assert(0 <= (temp+k) && 
+                  assert(0 <= (temp+k) &&
                          (temp+k) < (widthOut*heightOut*depthOut*components));
                   dataOut[temp + k] = (totals[k]+0.5)/volume;
               }
@@ -7027,7 +7029,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
    elementSize= bytes_per_element(type);
    groupSize= elementSize * components;
    if (elementSize == 1) myswapBytes= 0;
-   
+
    /* 3dstuff begin */
    if (psm->pack_image_height > 0) {
       rowsPerImage= psm->pack_image_height;
@@ -7036,24 +7038,24 @@ static void emptyImage3D(const PixelStorageModes *psm,
       rowsPerImage= height;
    }
 
-   /* 3dstuff end */   
+   /* 3dstuff end */
 
    rowSize = groupsPerLine * groupSize;
    padding = rowSize % psm->pack_alignment;
    if (padding) {
       rowSize+= psm->pack_alignment - padding;
    }
-   
+
    imageSize= rowsPerImage * rowSize; /* 3dstuff */
 
    start = (GLubyte *)userImage + psm->pack_skip_rows * rowSize +
-                                  psm->pack_skip_pixels * groupSize +
-                                  /*3dstuff*/
-                                  psm->pack_skip_images * imageSize;
+                                 psm->pack_skip_pixels * groupSize +
+                                 /*3dstuff*/
+                                 psm->pack_skip_images * imageSize;
    elementsPerLine= width * components;
 
    iter2 = oldImage;
-   for (dd= 0; dd < depth; dd++) { 
+   for (dd= 0; dd < depth; dd++) {
       rowStart= start;
 
       for (ii= 0; ii< height; ii++) {
@@ -7078,22 +7080,22 @@ static void emptyImage3D(const PixelStorageModes *psm,
                  *((GLbyte *) iter) = *iter2++ >> 9;
              }
              break;
-           case GL_UNSIGNED_BYTE_3_3_2: 
+           case GL_UNSIGNED_BYTE_3_3_2:
              for (k = 0; k < 3; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove332(shoveComponents,0,(void *)iter);
              break;
            case GL_UNSIGNED_BYTE_2_3_3_REV:
              for (k = 0; k < 3; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove233rev(shoveComponents,0,(void *)iter);
-             break; 
-           case GL_UNSIGNED_SHORT_5_6_5:                   
+             break;
+           case GL_UNSIGNED_SHORT_5_6_5:               
              for (k = 0; k < 3; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove565(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7103,10 +7105,10 @@ static void emptyImage3D(const PixelStorageModes *psm,
                 *(GLushort *)iter = widget.us[0];
              }
              break;
-           case GL_UNSIGNED_SHORT_5_6_5_REV:               
+           case GL_UNSIGNED_SHORT_5_6_5_REV:           
              for (k = 0; k < 3; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove565rev(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7119,7 +7121,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_SHORT_4_4_4_4:
              for (k = 0; k < 4; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove4444(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7131,7 +7133,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_SHORT_4_4_4_4_REV:
              for (k = 0; k < 4; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove4444rev(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7143,7 +7145,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_SHORT_5_5_5_1:
              for (k = 0; k < 4; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove5551(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7155,7 +7157,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_SHORT_1_5_5_5_REV:
              for (k = 0; k < 4; k++) {
                 shoveComponents[k]= *iter2++ / 65535.0;
-             } 
+             }
              shove1555rev(shoveComponents,0,(void *)&widget.us[0]);
              if (myswapBytes) {
                 iter[0] = widget.ub[1];
@@ -7186,7 +7188,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_INT_8_8_8_8:
               for (k = 0; k < 4; k++) {
                  shoveComponents[k]= *iter2++ / 65535.0;
-              } 
+              }
               shove8888(shoveComponents,0,(void *)&widget.ui);
               if (myswapBytes) {
                   iter[3] = widget.ub[0];
@@ -7200,7 +7202,7 @@ static void emptyImage3D(const PixelStorageModes *psm,
            case GL_UNSIGNED_INT_8_8_8_8_REV:
               for (k = 0; k < 4; k++) {
                  shoveComponents[k]= *iter2++ / 65535.0;
-              } 
+              }
               shove8888rev(shoveComponents,0,(void *)&widget.ui);
               if (myswapBytes) {
                   iter[3] = widget.ub[0];
@@ -7211,10 +7213,10 @@ static void emptyImage3D(const PixelStorageModes *psm,
                   *(GLuint *)iter= widget.ui;
               }
               break;
-           case GL_UNSIGNED_INT_10_10_10_2:  
+           case GL_UNSIGNED_INT_10_10_10_2:
               for (k = 0; k < 4; k++) {
                  shoveComponents[k]= *iter2++ / 65535.0;
-              } 
+              }
               shove1010102(shoveComponents,0,(void *)&widget.ui);
               if (myswapBytes) {
                   iter[3] = widget.ub[0];
@@ -7225,10 +7227,10 @@ static void emptyImage3D(const PixelStorageModes *psm,
                   *(GLuint *)iter= widget.ui;
               }
               break;
-           case GL_UNSIGNED_INT_2_10_10_10_REV:  
+           case GL_UNSIGNED_INT_2_10_10_10_REV:
               for (k = 0; k < 4; k++) {
                  shoveComponents[k]= *iter2++ / 65535.0;
-              } 
+              }
               shove2101010rev(shoveComponents,0,(void *)&widget.ui);
               if (myswapBytes) {
                   iter[3] = widget.ub[0];
@@ -7295,16 +7297,16 @@ static void emptyImage3D(const PixelStorageModes *psm,
                                elements_per_group(format,0)]);
    }
    assert( iter == &((GLubyte *)userImage)[rowSize*height*depth +
-                                       psm->unpack_skip_rows * rowSize + 
+                                       psm->unpack_skip_rows * rowSize +
                                        psm->unpack_skip_pixels * groupSize +
                                        /*3dstuff*/
                                        psm->unpack_skip_images * imageSize] );
 } /* emptyImage3D() */
 
-static 
-int gluScaleImage3D(GLenum format, 
+static
+int gluScaleImage3D(GLenum format,
                    GLint widthIn, GLint heightIn, GLint depthIn,
-                   GLenum typeIn, const void *dataIn, 
+                   GLenum typeIn, const void *dataIn,
                    GLint widthOut, GLint heightOut, GLint depthOut,
                    GLenum typeOut, void *dataOut)
 {
@@ -7312,16 +7314,16 @@ int gluScaleImage3D(GLenum format,
    GLushort *beforeImage, *afterImage;
    PixelStorageModes psm;
 
-   if (widthIn == 0 || heightIn == 0 || depthIn == 0 || 
+   if (widthIn == 0 || heightIn == 0 || depthIn == 0 ||
        widthOut == 0 || heightOut == 0 || depthOut == 0) {
       return 0;
    }
 
-   if (widthIn < 0 || heightIn < 0 || depthIn < 0 || 
+   if (widthIn < 0 || heightIn < 0 || depthIn < 0 ||
        widthOut < 0 || heightOut < 0 || depthOut < 0) {
       return GLU_INVALID_VALUE;
    }
-      
+
    if (!legalFormat(format) || !legalType(typeIn) || !legalType(typeOut) ||
        typeIn == GL_BITMAP || typeOut == GL_BITMAP) {
       return GLU_INVALID_ENUM;
@@ -7334,12 +7336,12 @@ int gluScaleImage3D(GLenum format,
    }
 
    beforeImage = malloc(imageSize3D(widthIn, heightIn, depthIn, format,
-                                   GL_UNSIGNED_SHORT)); 
-   afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format, 
+                                   GL_UNSIGNED_SHORT));
+   afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format,
                                   GL_UNSIGNED_SHORT));
    if (beforeImage == NULL || afterImage == NULL) {
        return GLU_OUT_OF_MEMORY;
-   } 
+   }
    retrieveStoreModes3D(&psm);
 
    fillImage3D(&psm,widthIn,heightIn,depthIn,format,typeIn, is_index(format),
@@ -7357,11 +7359,11 @@ int gluScaleImage3D(GLenum format,
 
 
 static void closestFit3D(GLenum target, GLint width, GLint height, GLint depth,
-                        GLint internalFormat, GLenum format, GLenum type, 
+                        GLint internalFormat, GLenum format, GLenum type,
                         GLint *newWidth, GLint *newHeight, GLint *newDepth)
 {
    GLint widthPowerOf2= nearestPower(width);
-   GLint heightPowerOf2= nearestPower(height);         
+   GLint heightPowerOf2= nearestPower(height);         
    GLint depthPowerOf2= nearestPower(depth);
    GLint proxyWidth;
 
@@ -7369,15 +7371,15 @@ static void closestFit3D(GLenum target, GLint width, GLint height, GLint depth,
       /* compute level 1 width & height & depth, clamping each at 1 */
       GLint widthAtLevelOne= (widthPowerOf2 > 1) ?
                              widthPowerOf2 >> 1 :
-                             widthPowerOf2;  
+                             widthPowerOf2;
       GLint heightAtLevelOne= (heightPowerOf2 > 1) ?
                               heightPowerOf2 >> 1 :
-                              heightPowerOf2;  
+                              heightPowerOf2;
       GLint depthAtLevelOne= (depthPowerOf2 > 1) ?
                              depthPowerOf2 >> 1 :
-                             depthPowerOf2;  
+                             depthPowerOf2;
       GLenum proxyTarget;
-      assert(widthAtLevelOne > 0); 
+      assert(widthAtLevelOne > 0);
       assert(heightAtLevelOne > 0);
       assert(depthAtLevelOne > 0);
 
@@ -7400,7 +7402,7 @@ static void closestFit3D(GLenum target, GLint width, GLint height, GLint depth,
         widthPowerOf2= widthAtLevelOne;
         heightPowerOf2= heightAtLevelOne;
         depthPowerOf2= depthAtLevelOne;
-      } 
+      }
       /* else it does fit */
    } while (proxyWidth == 0);
    /* loop must terminate! */
@@ -7419,8 +7421,8 @@ static void halveImagePackedPixelSlice(int components,
                                       (const GLfloat [],int, void *),
                                       GLint width, GLint height, GLint depth,
                                       const void *dataIn, void *dataOut,
-                                      GLint pixelSizeInBytes, 
-                                      GLint rowSizeInBytes, 
+                                      GLint pixelSizeInBytes,
+                                      GLint rowSizeInBytes,
                                       GLint imageSizeInBytes,
                                       GLint isSwap)
 {
@@ -7458,7 +7460,7 @@ static void halveImagePackedPixelSlice(int components,
            }
            totals[cc]/= (float)BOX2;
         } /* for cc */
-        
+        
         (*shovePackedPixel)(totals,outIndex,dataOut);
         outIndex++;
         /* skip over to next group of 2 */
@@ -7471,7 +7473,7 @@ static void halveImagePackedPixelSlice(int components,
       for (ii= 0; ii< halfDepth; ii++) {
         for (jj= 0; jj< halfWidth; jj++) {
             float totals[4];
-            float extractTotals[BOX4][4]; 
+            float extractTotals[BOX4][4];
             int cc;
 
             (*extractPackedPixel)(isSwap,src,
@@ -7484,12 +7486,12 @@ static void halveImagePackedPixelSlice(int components,
                                   (src+imageSizeInBytes+pixelSizeInBytes),
                                   &extractTotals[3][0]);
             for (cc = 0; cc < components; cc++) {
-               int kk;
+               int kk;
 
                /* grab 4 pixels to average */
                totals[cc]= 0.0;
                /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-                *              extractTotals[2][RED]+extractTotals[3][RED];
+                *              extractTotals[2][RED]+extractTotals[3][RED];
                 * totals[RED]/= 4.0;
                 */
                for (kk = 0; kk < BOX4; kk++) {
@@ -7531,7 +7533,7 @@ static void halveImagePackedPixelSlice(int components,
               /* grab 4 pixels to average */
               totals[cc]= 0.0;
               /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-               *              extractTotals[2][RED]+extractTotals[3][RED];
+               *              extractTotals[2][RED]+extractTotals[3][RED];
                * totals[RED]/= 4.0;
                */
               for (kk = 0; kk < BOX4; kk++) {
@@ -7546,7 +7548,7 @@ static void halveImagePackedPixelSlice(int components,
            /* skip over to next vertical square of 4 */
            src+= imageSizeInBytes + imageSizeInBytes;
         }
-      } 
+      }
       /* assert() */
    }
 
@@ -7559,8 +7561,8 @@ static void halveImagePackedPixel3D(int components,
                                    (const GLfloat [],int, void *),
                                    GLint width, GLint height, GLint depth,
                                    const void *dataIn, void *dataOut,
-                                   GLint pixelSizeInBytes, 
-                                   GLint rowSizeInBytes, 
+                                   GLint pixelSizeInBytes,
+                                   GLint rowSizeInBytes,
                                    GLint imageSizeInBytes,
                                    GLint isSwap)
 {
@@ -7573,13 +7575,13 @@ static void halveImagePackedPixel3D(int components,
       return;
    }
    /* a horizontal or vertical slice viewed from top */
-   else if (width == 1 || height == 1) { 
+   else if (width == 1 || height == 1) {
       assert(1 <= depth);
 
       halveImagePackedPixelSlice(components,
                                 extractPackedPixel,shovePackedPixel,
                                 width, height, depth, dataIn, dataOut,
-                                pixelSizeInBytes, rowSizeInBytes, 
+                                pixelSizeInBytes, rowSizeInBytes,
                                 imageSizeInBytes, isSwap);
       return;
    }
@@ -7588,7 +7590,7 @@ static void halveImagePackedPixel3D(int components,
 
       int halfWidth= width / 2;
       int halfHeight= height / 2;
-      int halfDepth= depth / 2;  
+      int halfDepth= depth / 2;
       const char *src= (const char *) dataIn;
       int padBytes= rowSizeInBytes - (width*pixelSizeInBytes);
       int outIndex= 0;
@@ -7597,7 +7599,7 @@ static void halveImagePackedPixel3D(int components,
         for (ii= 0; ii< halfHeight; ii++) {
            for (jj= 0; jj< halfWidth; jj++) {
 #define BOX8 8
-              float totals[4]; /* 4 is maximum components */
+              float totals[4]; /* 4 is maximum components */
               float extractTotals[BOX8][4]; /* 4 is maximum components */
               int cc;
 
@@ -7620,15 +7622,15 @@ static void halveImagePackedPixel3D(int components,
               (*extractPackedPixel)(isSwap,
                                     (src+rowSizeInBytes+pixelSizeInBytes+imageSizeInBytes),
                                     &extractTotals[7][0]);
-              for (cc = 0; cc < components; cc++) { 
+              for (cc = 0; cc < components; cc++) {
                  int kk;
 
                  /* grab 8 pixels to average */
                  totals[cc]= 0.0;
                  /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-                  *              extractTotals[2][RED]+extractTotals[3][RED]+
-                  *              extractTotals[4][RED]+extractTotals[5][RED]+
-                  *              extractTotals[6][RED]+extractTotals[7][RED];
+                  *              extractTotals[2][RED]+extractTotals[3][RED]+
+                  *              extractTotals[4][RED]+extractTotals[5][RED]+
+                  *              extractTotals[6][RED]+extractTotals[7][RED];
                   * totals[RED]/= 8.0;
                   */
                  for (kk = 0; kk < BOX8; kk++) {
@@ -7647,18 +7649,18 @@ static void halveImagePackedPixel3D(int components,
 
            /* src is at beginning of a row here, but it's the second row of
             * the square block of 4 pixels that we just worked on so we
-            * need to go one more row.  
-            * i.e.,             
-            *                   OO... 
-            *           here -->OO...
-            *       but want -->OO...
-            *                   OO... 
-            *                   ...
+            * need to go one more row.
+            * i.e.,
+            *                   OO...
+            *           here -->OO...
+            *       but want -->OO...
+            *                   OO...
+            *                   ...
             */
            src+= rowSizeInBytes;
         }
 
-        src+= imageSizeInBytes; 
+        src+= imageSizeInBytes;
       } /* for dd */
 
       /* both pointers must reach one byte after the end */
@@ -7668,14 +7670,14 @@ static void halveImagePackedPixel3D(int components,
 
 } /* halveImagePackedPixel3D() */
 
-static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat, 
-                                     GLsizei width, 
-                                     GLsizei height, 
+static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
+                                     GLsizei width,
+                                     GLsizei height,
                                      GLsizei depth,
-                                     GLsizei widthPowerOf2, 
-                                     GLsizei heightPowerOf2, 
+                                     GLsizei widthPowerOf2,
+                                     GLsizei heightPowerOf2,
                                      GLsizei depthPowerOf2,
-                                     GLenum format, GLenum type, 
+                                     GLenum format, GLenum type,
                                      GLint userLevel,
                                      GLint baseLevel,GLint maxLevel,
                                      const void *data)
@@ -7724,8 +7726,8 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
    if (elementSize == 1) myswapBytes = 0;
 
    /* 3dstuff begin */
-   if (psm.unpack_image_height > 0) { 
-      rowsPerImage= psm.unpack_image_height; 
+   if (psm.unpack_image_height > 0) {
+      rowsPerImage= psm.unpack_image_height;
    }
    else {
       rowsPerImage= height;
@@ -7740,10 +7742,10 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
 
    imageSize= rowsPerImage * rowSize; /* 3dstuff */
 
-   usersImage = (const GLubyte *)data + psm.unpack_skip_rows * rowSize + 
+   usersImage = (const GLubyte *)data + psm.unpack_skip_rows * rowSize +
                                  psm.unpack_skip_pixels * groupSize +
                                  /* 3dstuff */
-                                 psm.unpack_skip_images * imageSize;      
+                                 psm.unpack_skip_images * imageSize;
 
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
@@ -7756,7 +7758,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
    if (width == newWidth && height == newHeight && depth == newDepth) {
        /* Use usersImage for level userLevel */
        if (baseLevel <= level && level <= maxLevel) {
-          gluTexImage3D(target, level, internalFormat, width, 
+         gluTexImage3D(target, level, internalFormat, width,
                       height, depth, 0, format, type,
                       usersImage);
        }
@@ -7778,7 +7780,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
          /* clamp to 1 */
          if (nextWidth < 1) nextWidth= 1;
          if (nextHeight < 1) nextHeight= 1;
-         if (nextDepth < 1) nextDepth= 1;         
+         if (nextDepth < 1) nextDepth= 1;      
        memReq = imageSize3D(nextWidth, nextHeight, nextDepth, format, type);
        }
        switch(type) {
@@ -7803,8 +7805,8 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
        case GL_FLOAT:
         dstImage = (GLfloat *)malloc(memReq);
         break;
-       case GL_UNSIGNED_BYTE_3_3_2: 
-       case GL_UNSIGNED_BYTE_2_3_3_REV: 
+       case GL_UNSIGNED_BYTE_3_3_2:
+       case GL_UNSIGNED_BYTE_2_3_3_REV:
         dstImage = (GLubyte *)malloc(memReq);
         break;
        case GL_UNSIGNED_SHORT_5_6_5:
@@ -7819,7 +7821,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
        case GL_UNSIGNED_INT_8_8_8_8_REV:
        case GL_UNSIGNED_INT_10_10_10_2:
        case GL_UNSIGNED_INT_2_10_10_10_REV:
-        dstImage = (GLuint *)malloc(memReq);     
+        dstImage = (GLuint *)malloc(memReq);   
         break;
        default:
         return GLU_INVALID_ENUM; /* assertion */
@@ -7873,7 +7875,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           }
           break;
         case GL_SHORT:
-           if (depth > 1) { 
+          if (depth > 1) {
           halveImage3D(cmpts,extractSshort,shoveSshort,
                        width,height,depth,
                        usersImage,dstImage,elementSize,groupSize,rowSize,
@@ -7885,7 +7887,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           }
           break;
         case GL_UNSIGNED_INT:
-          if (depth > 1) { 
+          if (depth > 1) {
           halveImage3D(cmpts,extractUint,shoveUint,
                        width,height,depth,
                        usersImage,dstImage,elementSize,groupSize,rowSize,
@@ -7897,7 +7899,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           }
           break;
         case GL_INT:
-          if (depth > 1) { 
+          if (depth > 1) {
           halveImage3D(cmpts,extractSint,shoveSint,
                        width,height,depth,
                        usersImage,dstImage,elementSize,groupSize,rowSize,
@@ -7920,7 +7922,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
                              elementSize,rowSize,groupSize,myswapBytes);
           }
           break;
-        case GL_UNSIGNED_BYTE_3_3_2: 
+        case GL_UNSIGNED_BYTE_3_3_2:
           assert(format == GL_RGB);
           halveImagePackedPixel3D(3,extract332,shove332,
                                   width,height,depth,usersImage,dstImage,
@@ -7946,42 +7948,42 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
           halveImagePackedPixel3D(4,extract4444,shove4444,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_SHORT_4_4_4_4_REV:
           halveImagePackedPixel3D(4,extract4444rev,shove4444rev,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_SHORT_5_5_5_1:
           halveImagePackedPixel3D(4,extract5551,shove5551,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_SHORT_1_5_5_5_REV:
           halveImagePackedPixel3D(4,extract1555rev,shove1555rev,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_INT_8_8_8_8:
           halveImagePackedPixel3D(4,extract8888,shove8888,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_INT_8_8_8_8_REV:
           halveImagePackedPixel3D(4,extract8888rev,shove8888rev,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_INT_10_10_10_2:
           halveImagePackedPixel3D(4,extract1010102,shove1010102,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         case GL_UNSIGNED_INT_2_10_10_10_REV:
           halveImagePackedPixel3D(4,extract2101010rev,shove2101010rev,
                                   width,height,depth,usersImage,dstImage,
                                   elementSize,rowSize,imageSize,myswapBytes);
-          break;          
+          break;
         default:
           assert(0);
           break;
@@ -7991,7 +7993,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
        newDepth = depth/2;
        /* clamp to 1 */
        if (newWidth < 1) newWidth= 1;
-       if (newHeight < 1) newHeight= 1; 
+       if (newHeight < 1) newHeight= 1;
        if (newDepth < 1) newDepth= 1;
 
        myswapBytes = 0;
@@ -8054,7 +8056,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
         return GLU_OUT_OF_MEMORY;
        }
        /* level userLevel+1 is in srcImage; level userLevel already saved */
-       level = userLevel+1; 
+       level = userLevel+1;
    } else {/* user's image is *not* nice power-of-2 sized square */
        memReq = imageSize3D(newWidth, newHeight, newDepth, format, type);
        switch(type) {
@@ -8098,7 +8100,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
               dstImage = (GLuint *)malloc(memReq);
               break;
           default:
-              return GLU_INVALID_ENUM; /* assertion */
+              return GLU_INVALID_ENUM; /* assertion */
        }
 
        if (dstImage == NULL) {
@@ -8129,8 +8131,8 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
            int nextHeight= newHeight/2;
            int nextDepth= newDepth/2;
            if (nextWidth < 1) nextWidth= 1;
-           if (nextHeight < 1) nextHeight= 1;       
-           if (nextDepth < 1) nextDepth= 1;         
+           if (nextHeight < 1) nextHeight= 1;  
+           if (nextDepth < 1) nextDepth= 1;    
 
         memReq = imageSize3D(nextWidth, nextHeight, nextDepth, format, type);
         }
@@ -8189,7 +8191,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
         }
        }
        /* level userLevel is in srcImage; nothing saved yet */
-       level = userLevel;      
+       level = userLevel;       
    }
 
    glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
@@ -8225,7 +8227,7 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
               }
               break;
           case GL_UNSIGNED_SHORT:
-              if (newDepth > 1) { 
+              if (newDepth > 1) {
               halveImage3D(cmpts,extractUshort,shoveUshort,
                            newWidth,newHeight,newDepth,
                            srcImage,dstImage,elementSize,groupSize,rowSize,
@@ -8320,13 +8322,13 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
                                       srcImage,dstImage,elementSize,rowSize,
                                       imageSize,myswapBytes);
               break;
-          case GL_UNSIGNED_SHORT_5_5_5_1:              
+          case GL_UNSIGNED_SHORT_5_5_5_1:              
               halveImagePackedPixel3D(4,extract5551,shove5551,
                                       newWidth,newHeight,newDepth,
                                       srcImage,dstImage,elementSize,rowSize,
                                       imageSize,myswapBytes);
               break;
-          case GL_UNSIGNED_SHORT_1_5_5_5_REV:          
+          case GL_UNSIGNED_SHORT_1_5_5_5_REV:          
               halveImagePackedPixel3D(4,extract1555rev,shove1555rev,
                                       newWidth,newHeight,newDepth,
                                       srcImage,dstImage,elementSize,rowSize,
@@ -8390,9 +8392,9 @@ static int gluBuild3DMipmapLevelsCore(GLenum target, GLint internalFormat,
 } /* gluBuild3DMipmapLevelsCore() */
 
 GLint GLAPIENTRY
-gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, 
+gluBuild3DMipmapLevels(GLenum target, GLint internalFormat,
                             GLsizei width, GLsizei height, GLsizei depth,
-                            GLenum format, GLenum type, 
+                            GLenum format, GLenum type,
                             GLint userLevel, GLint baseLevel, GLint maxLevel,
                             const void *data)
 {
@@ -8416,19 +8418,19 @@ gluBuild3DMipmapLevels(GLenum target, GLint internalFormat,
    if (level > levels) levels=level;
 
    levels+= userLevel;
-   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels)) 
+   if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
       return GLU_INVALID_VALUE;
 
-   return gluBuild3DMipmapLevelsCore(target, internalFormat, 
+   return gluBuild3DMipmapLevelsCore(target, internalFormat,
                                     width, height, depth,
                                     width, height, depth,
-                                    format, type, 
+                                    format, type,
                                     userLevel, baseLevel, maxLevel,
                                     data);
 } /* gluBuild3DMipmapLevels() */
 
 GLint GLAPIENTRY
-gluBuild3DMipmaps(GLenum target, GLint internalFormat, 
+gluBuild3DMipmaps(GLenum target, GLint internalFormat,
                        GLsizei width, GLsizei height, GLsizei depth,
                        GLenum format, GLenum type, const void *data)
 {
@@ -8455,9 +8457,9 @@ gluBuild3DMipmaps(GLenum target, GLint internalFormat,
    level = computeLog(depthPowerOf2);
    if (level > levels) levels=level;
 
-   return gluBuild3DMipmapLevelsCore(target, internalFormat, 
+   return gluBuild3DMipmapLevelsCore(target, internalFormat,
                                     width, height, depth,
-                                    widthPowerOf2, heightPowerOf2, 
+                                    widthPowerOf2, heightPowerOf2,
                                     depthPowerOf2,
                                     format, type, 0, 0, levels,
                                     data);
@@ -8504,7 +8506,7 @@ static GLdouble extractUshort(int isSwap, const void *uitem)
      ushort= *(const GLushort *)uitem;
    }
 
-   assert(ushort <= 65535);  
+   assert(ushort <= 65535);
 
    return (GLdouble)ushort;
 } /* extractUshort() */
@@ -8527,7 +8529,7 @@ static GLdouble extractSshort(int isSwap, const void *sitem)
      sshort= *(const GLshort *)sitem;
    }
 
-   assert(sshort <= 32767);  
+   assert(sshort <= 32767);
 
    return (GLdouble)sshort;
 } /* extractSshort() */
@@ -8550,14 +8552,14 @@ static GLdouble extractUint(int isSwap, const void *uitem)
      uint= *(const GLuint *)uitem;
    }
 
-   assert(uint <= 0xffffffff);  
+   assert(uint <= 0xffffffff);
 
    return (GLdouble)uint;
 } /* extractUint() */
 
 static void shoveUint(GLdouble value, int index, void *data)
 {
-   assert(0.0 <= value && value <= (GLdouble) UINT_MAX); 
+   assert(0.0 <= value && value <= (GLdouble) UINT_MAX);
 
    ((GLuint *)data)[index]= (GLuint)value;
 } /* shoveUint() */
@@ -8573,14 +8575,14 @@ static GLdouble extractSint(int isSwap, const void *sitem)
      sint= *(const GLint *)sitem;
    }
 
-   assert(sint <= 0x7fffffff);  
+   assert(sint <= 0x7fffffff);
 
    return (GLdouble)sint;
 } /* extractSint() */
 
 static void shoveSint(GLdouble value, int index, void *data)
 {
-   assert(0.0 <= value && value <= (GLdouble) INT_MAX); 
+   assert(0.0 <= value && value <= (GLdouble) INT_MAX);
 
    ((GLint *)data)[index]= (GLint)value;
 } /* shoveSint() */
@@ -8596,7 +8598,7 @@ static GLdouble extractFloat(int isSwap, const void *item)
      ffloat= *(const GLfloat *)item;
    }
 
-   assert(ffloat <= 1.0);  
+   assert(ffloat <= 1.0);
 
    return (GLdouble)ffloat;
 } /* extractFloat() */
@@ -8614,8 +8616,8 @@ static void halveImageSlice(int components,
                            GLint width, GLint height, GLint depth,
                            const void *dataIn, void *dataOut,
                            GLint elementSizeInBytes,
-                           GLint groupSizeInBytes, 
-                           GLint rowSizeInBytes, 
+                           GLint groupSizeInBytes,
+                           GLint rowSizeInBytes,
                            GLint imageSizeInBytes,
                            GLint isSwap)
 {
@@ -8678,7 +8680,7 @@ static void halveImageSlice(int components,
            for (cc = 0; cc < components; cc++) {
               int kk;
               double totals[4];
-              double extractTotals[BOX4][4]; 
+              double extractTotals[BOX4][4];
 
               extractTotals[0][cc]=(*extract)(isSwap,src);
               extractTotals[1][cc]=(*extract)(isSwap,
@@ -8691,7 +8693,7 @@ static void halveImageSlice(int components,
               /* grab 4 pixels to average */
               totals[cc]= 0.0;
               /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-               *              extractTotals[2][RED]+extractTotals[3][RED];
+               *              extractTotals[2][RED]+extractTotals[3][RED];
                * totals[RED]/= 4.0;
                */
               for (kk = 0; kk < BOX4; kk++) {
@@ -8703,7 +8705,7 @@ static void halveImageSlice(int components,
               outIndex++;
 
               src+= elementSizeInBytes;
-           } /* for cc */ 
+           } /* for cc */
 
            /* skip over to next horizontal square of 4 */
            src+= groupSizeInBytes;
@@ -8715,7 +8717,7 @@ static void halveImageSlice(int components,
 
       assert(src == &((const char *)dataIn)[rowSizeInBytes*height*depth]);
       assert(outIndex == halfWidth * halfDepth * components);
-   } 
+   }
    else if (width == 1) {      /* vertical slice viewed from top */
       /* printf("vertical slice\n"); */
       assert(height != 1);
@@ -8740,7 +8742,7 @@ static void halveImageSlice(int components,
               /* grab 4 pixels to average */
               totals[cc]= 0.0;
               /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-               *              extractTotals[2][RED]+extractTotals[3][RED];
+               *              extractTotals[2][RED]+extractTotals[3][RED];
                * totals[RED]/= 4.0;
                */
               for (kk = 0; kk < BOX4; kk++) {
@@ -8760,7 +8762,7 @@ static void halveImageSlice(int components,
         } /* for jj */
 
         src+= imageSizeInBytes;
-      } /* for ii */ 
+      } /* for ii */
 
       assert(src == &((const char *)dataIn)[rowSizeInBytes*height*depth]);
       assert(outIndex == halfHeight * halfDepth * components);
@@ -8774,19 +8776,19 @@ static void halveImage3D(int components,
                         GLint width, GLint height, GLint depth,
                         const void *dataIn, void *dataOut,
                         GLint elementSizeInBytes,
-                        GLint groupSizeInBytes, 
-                        GLint rowSizeInBytes, 
+                        GLint groupSizeInBytes,
+                        GLint rowSizeInBytes,
                         GLint imageSizeInBytes,
                         GLint isSwap)
 {
-   assert(depth > 1); 
+   assert(depth > 1);
 
    /* a horizontal/vertical/one-column slice viewed from top */
-   if (width == 1 || height == 1) { 
+   if (width == 1 || height == 1) {
       assert(1 <= depth);
 
-      halveImageSlice(components,extract,shove, width, height, depth, 
-                     dataIn, dataOut, elementSizeInBytes, groupSizeInBytes, 
+      halveImageSlice(components,extract,shove, width, height, depth,
+                     dataIn, dataOut, elementSizeInBytes, groupSizeInBytes,
                      rowSizeInBytes, imageSizeInBytes, isSwap);
       return;
    }
@@ -8795,7 +8797,7 @@ static void halveImage3D(int components,
 
       int halfWidth= width / 2;
       int halfHeight= height / 2;
-      int halfDepth= depth / 2;  
+      int halfDepth= depth / 2;
       const char *src= (const char *) dataIn;
       int padBytes= rowSizeInBytes - (width*groupSizeInBytes);
       int outIndex= 0;
@@ -8832,9 +8834,9 @@ static void halveImage3D(int components,
                  totals[cc]= 0.0;
 
                  /* totals[RED]= extractTotals[0][RED]+extractTotals[1][RED]+
-                  *              extractTotals[2][RED]+extractTotals[3][RED]+
-                  *              extractTotals[4][RED]+extractTotals[5][RED]+
-                  *              extractTotals[6][RED]+extractTotals[7][RED];
+                  *              extractTotals[2][RED]+extractTotals[3][RED]+
+                  *              extractTotals[4][RED]+extractTotals[5][RED]+
+                  *              extractTotals[6][RED]+extractTotals[7][RED];
                   * totals[RED]/= 8.0;
                   */
                  for (kk = 0; kk < BOX8; kk++) {
@@ -8857,18 +8859,18 @@ static void halveImage3D(int components,
 
            /* src is at beginning of a row here, but it's the second row of
             * the square block of 4 pixels that we just worked on so we
-            * need to go one more row.  
-            * i.e.,             
-            *                   OO... 
-            *           here -->OO...
-            *       but want -->OO...
-            *                   OO... 
-            *                   ...
+            * need to go one more row.
+            * i.e.,
+            *                   OO...
+            *           here -->OO...
+            *       but want -->OO...
+            *                   OO...
+            *                   ...
             */
            src+= rowSizeInBytes;
         } /* for ii */
 
-        src+= imageSizeInBytes; 
+        src+= imageSizeInBytes;
       } /* for dd */
 
       /* both pointers must reach one byte after the end */
index 57e3f2636fb6e7d64fb38e401bbee2e279e008a8..1939b0f7d053d6dfee570bb3e09e4201b93a1295 100644 (file)
@@ -6,21 +6,21 @@
 ** this file except in compliance with the License. You may obtain a copy
 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-** 
+**
 ** http://oss.sgi.com/projects/FreeB
-** 
+**
 ** Note that, as provided in the License, the Software is distributed on an
 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-** 
+**
 ** Original Code. The Original Code is: OpenGL Sample Implementation,
 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
 ** Copyright in any portions created by third parties is as indicated
 ** elsewhere herein. All Rights Reserved.
-** 
+**
 ** Additional Notice Provisions: The application programming interfaces
 ** established by SGI in conjunction with the Original Code are The
 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -31,8 +31,8 @@
 ** published by SGI, but has not been independently verified as being
 ** compliant with the OpenGL(R) version 1.2.1 Specification.
 **
-** $Date: 2002/11/01 23:45:31 $ $Revision: 1.3 $
-** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libutil/quad.c,v 1.3 2002/11/01 23:45:31 brianp Exp $
+** $Date: 2003/10/14 23:48:58 $ $Revision: 1.4 $
+** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libutil/quad.c,v 1.4 2003/10/14 23:48:58 kendallb Exp $
 */
 
 #include "gluos.h"
 /* Make it not a power of two to avoid cache thrashing on the chip */
 #define CACHE_SIZE     240
 
-#define PI            3.14159265358979323846
+#undef PI
+#define PI           3.14159265358979323846
 
 struct GLUquadric {
-    GLint      normals;
+    GLint      normals;
     GLboolean  textureCoords;
     GLint      orientation;
     GLint      drawStyle;
@@ -70,7 +71,7 @@ gluNewQuadric(void)
     newstate->textureCoords = GL_FALSE;
     newstate->orientation = GLU_OUTSIDE;
     newstate->drawStyle = GLU_FILL;
-    newstate->errorCallback = NULL; 
+    newstate->errorCallback = NULL;
     return newstate;
 }
 
@@ -153,7 +154,7 @@ gluQuadricDrawStyle(GLUquadric *qobj, GLenum drawStyle)
 }
 
 void GLAPIENTRY
-gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius, 
+gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                GLdouble height, GLint slices, GLint stacks)
 {
     GLint i,j;
@@ -219,7 +220,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                sinCache2[i] = -xyNormalRatio * SIN(angle);
                cosCache2[i] = -xyNormalRatio * COS(angle);
            }
-       } 
+       }
        sinCache[i] = SIN(angle);
        cosCache[i] = COS(angle);
     }
@@ -235,7 +236,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                cosCache3[i] = -xyNormalRatio * COS(angle);
            }
        }
-    } 
+    }
 
     sinCache[slices] = sinCache[0];
     cosCache[slices] = cosCache[0];
@@ -252,8 +253,8 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
       case GLU_FILL:
        /* Note:
        ** An argument could be made for using a TRIANGLE_FAN for the end
-       ** of the cylinder of either radii is 0.0 (a cone).  However, a 
-       ** TRIANGLE_FAN would not work in smooth shading mode (the common 
+       ** of the cylinder of either radii is 0.0 (a cone).  However, a
+       ** TRIANGLE_FAN would not work in smooth shading mode (the common
        ** case) because the normal for the apex is different for every
        ** triangle (and TRIANGLE_FAN doesn't let me respecify that normal).
        ** Now, my choice is GL_TRIANGLES, or leave the GL_QUAD_STRIP and
@@ -285,26 +286,26 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                        glTexCoord2f(1 - (float) i / slices,
                                (float) j / stacks);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], zLow);
                    if (qobj->textureCoords) {
                        glTexCoord2f(1 - (float) i / slices,
                                (float) (j+1) / stacks);
                    }
-                   glVertex3f(radiusHigh * sinCache[i], 
+                   glVertex3f(radiusHigh * sinCache[i],
                            radiusHigh * cosCache[i], zHigh);
                } else {
                    if (qobj->textureCoords) {
                        glTexCoord2f(1 - (float) i / slices,
                                (float) (j+1) / stacks);
                    }
-                   glVertex3f(radiusHigh * sinCache[i], 
+                   glVertex3f(radiusHigh * sinCache[i],
                            radiusHigh * cosCache[i], zHigh);
                    if (qobj->textureCoords) {
                        glTexCoord2f(1 - (float) i / slices,
                                (float) j / stacks);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], zLow);
                }
            }
@@ -333,7 +334,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                    glTexCoord2f(1 - (float) i / slices,
                            (float) j / stacks);
                }
-               glVertex3f(radiusLow * sintemp, 
+               glVertex3f(radiusLow * sintemp,
                        radiusLow * costemp, zLow);
            }
        }
@@ -361,7 +362,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                    glTexCoord2f(1 - (float) i / slices,
                            (float) j / stacks);
                }
-               glVertex3f(radiusLow * sinCache[i], 
+               glVertex3f(radiusLow * sinCache[i],
                        radiusLow * cosCache[i], zLow);
            }
            glEnd();
@@ -389,7 +390,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                    glTexCoord2f(1 - (float) i / slices,
                            (float) j / stacks);
                }
-               glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i], 
+               glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i],
                        zLow);
            }
            glEnd();
@@ -415,7 +416,7 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
                    glTexCoord2f(1 - (float) i / slices,
                            (float) j / stacks);
                }
-               glVertex3f(radiusLow * sintemp, 
+               glVertex3f(radiusLow * sintemp,
                        radiusLow * costemp, zLow);
            }
            glEnd();
@@ -427,14 +428,14 @@ gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
 }
 
 void GLAPIENTRY
-gluDisk(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius, 
+gluDisk(GLUquadric *qobj, GLdouble innerRadius, GLdouble outerRadius,
            GLint slices, GLint loops)
 {
     gluPartialDisk(qobj, innerRadius, outerRadius, slices, loops, 0.0, 360.0);
 }
 
 void GLAPIENTRY
-gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius, 
+gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                   GLdouble outerRadius, GLint slices, GLint loops,
                   GLdouble startAngle, GLdouble sweepAngle)
 {
@@ -511,7 +512,7 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                glTexCoord2f(0.5, 0.5);
            }
            glVertex3f(0.0, 0.0, 0.0);
-           radiusLow = outerRadius - 
+           radiusLow = outerRadius -
                    deltaRadius * ((float) (loops-1) / loops);
            if (qobj->textureCoords) {
                texLow = radiusLow / outerRadius / 2;
@@ -523,7 +524,7 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                        glTexCoord2f(texLow * sinCache[i] + 0.5,
                                texLow * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], 0.0);
                }
            } else {
@@ -532,7 +533,7 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                        glTexCoord2f(texLow * sinCache[i] + 0.5,
                                texLow * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], 0.0);
                }
            }
@@ -555,28 +556,28 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                        glTexCoord2f(texLow * sinCache[i] + 0.5,
                                texLow * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], 0.0);
 
                    if (qobj->textureCoords) {
                        glTexCoord2f(texHigh * sinCache[i] + 0.5,
                                texHigh * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusHigh * sinCache[i], 
+                   glVertex3f(radiusHigh * sinCache[i],
                            radiusHigh * cosCache[i], 0.0);
                } else {
                    if (qobj->textureCoords) {
                        glTexCoord2f(texHigh * sinCache[i] + 0.5,
                                texHigh * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusHigh * sinCache[i], 
+                   glVertex3f(radiusHigh * sinCache[i],
                            radiusHigh * cosCache[i], 0.0);
 
                    if (qobj->textureCoords) {
                        glTexCoord2f(texLow * sinCache[i] + 0.5,
                                texLow * cosCache[i] + 0.5);
                    }
-                   glVertex3f(radiusLow * sinCache[i], 
+                   glVertex3f(radiusLow * sinCache[i],
                            radiusLow * cosCache[i], 0.0);
                }
            }
@@ -629,7 +630,7 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                    glTexCoord2f(texLow * sinCache[i] + 0.5,
                            texLow * cosCache[i] + 0.5);
                }
-               glVertex3f(radiusLow * sinCache[i], 
+               glVertex3f(radiusLow * sinCache[i],
                        radiusLow * cosCache[i], 0.0);
            }
            glEnd();
@@ -684,7 +685,7 @@ gluPartialDisk(GLUquadric *qobj, GLdouble innerRadius,
                    glTexCoord2f(texLow * sinCache[i] + 0.5,
                            texLow * cosCache[i] + 0.5);
                }
-               glVertex3f(radiusLow * sinCache[i], 
+               glVertex3f(radiusLow * sinCache[i],
                        radiusLow * cosCache[i], 0.0);
            }
            glEnd();
@@ -788,7 +789,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                cosCache3b[j] = -COS(angle);
            }
        }
-    } 
+    }
 
     sinCache1a[slices] = sinCache1a[0];
     cosCache1a[slices] = cosCache1a[0];
@@ -969,7 +970,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                }
                break;
              default:
-               break;
+               break;
            }
 
            glBegin(GL_QUAD_STRIP);
@@ -1046,7 +1047,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                costemp2 = cosCache2b[j];
                break;
              default:
-               break;
+               break;
            }
            for (i = 0; i < slices; i++) {
                switch(qobj->normals) {
@@ -1067,7 +1068,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                    glTexCoord2f(1 - (float) i / slices,
                            1 - (float) j / stacks);
                }
-               glVertex3f(sintemp1 * sinCache1a[i], 
+               glVertex3f(sintemp1 * sinCache1a[i],
                        sintemp1 * cosCache1a[i], costemp1);
            }
        }
@@ -1109,7 +1110,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                    glTexCoord2f(1 - (float) i / slices,
                            1 - (float) j / stacks);
                }
-               glVertex3f(sintemp1 * sinCache1a[i], 
+               glVertex3f(sintemp1 * sinCache1a[i],
                        sintemp1 * cosCache1a[i], costemp1);
            }
            glEnd();
@@ -1149,7 +1150,7 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
                    glTexCoord2f(1 - (float) i / slices,
                            1 - (float) j / stacks);
                }
-               glVertex3f(sintemp1 * sinCache1b[j], 
+               glVertex3f(sintemp1 * sinCache1b[j],
                        costemp1 * sinCache1b[j], cosCache1b[j]);
            }
            glEnd();