Renamed s_nvfragprog.[ch] to s_fragprog.[ch]
[mesa.git] / progs / redbook / tess.c
index cef35dbbe9852c6f7be053a07746c00f4ce10d12..238a469aff20d759a31eb274fe0b9a79e3f70e28 100644 (file)
@@ -1,13 +1,13 @@
 /*
  * Copyright (c) 1993-1997, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED 
- * Permission to use, copy, modify, and distribute this software for 
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
  * any purpose and without fee is hereby granted, provided that the above
  * copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that 
+ * and this permission notice appear in supporting documentation, and that
  * the name of Silicon Graphics, Inc. not be used in advertising
  * or publicity pertaining to distribution of the software without specific,
- * written prior permission. 
+ * written prior permission.
  *
  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- * 
- * US Government Users Restricted Rights 
+ *
+ * US Government Users Restricted Rights
  * Use, duplication, or disclosure by the Government is subject to
  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -45,7 +45,7 @@
  *  Note the exterior rectangle is drawn with its vertices
  *  in counter-clockwise order, but its interior clockwise.
  *  Note the combineCallback is needed for the self-intersecting
- *  star.  Also note that removing the TessProperty for the 
+ *  star.  Also note that removing the TessProperty for the
  *  star will make the interior unshaded (WINDING_ODD).
  */
 #include <GL/glut.h>
@@ -79,7 +79,7 @@ void CALLBACK errorCallback(GLenum errorCode)
    const GLubyte *estring;
 
    estring = gluErrorString(errorCode);
-   fprintf(stderr, "Tessellation Error: %s\n", estring);
+   fprintf(stderr, "Tessellation Error: %s\n", (char *) estring);
    exit(0);
 }
 
@@ -94,7 +94,7 @@ void CALLBACK vertexCallback(GLvoid *vertex)
 
    pointer = (GLdouble *) vertex;
    glColor3dv(pointer+3);
-   glVertex3dv(vertex);
+   glVertex3dv(pointer);
 }
 
 /*  combineCallback is used to create a new vertex when edges
@@ -102,7 +102,7 @@ void CALLBACK vertexCallback(GLvoid *vertex)
  *  but weight[4] may be used to average color, normal, or texture
  *  coordinate data.  In this program, color is weighted.
  */
-void CALLBACK combineCallback(GLdouble coords[3], 
+void CALLBACK combineCallback(GLdouble coords[3],
                      GLdouble *vertex_data[4],
                      GLfloat weight[4], GLdouble **dataOut )
 {
@@ -114,47 +114,47 @@ void CALLBACK combineCallback(GLdouble coords[3],
    vertex[0] = coords[0];
    vertex[1] = coords[1];
    vertex[2] = coords[2];
-   for (i = 3; i < 7; i++)
-      vertex[i] = weight[0] * vertex_data[0][i] 
+   for (i = 3; i < 6; i++)
+      vertex[i] = weight[0] * vertex_data[0][i]
                   + weight[1] * vertex_data[1][i]
-                  + weight[2] * vertex_data[2][i] 
+                  + weight[2] * vertex_data[2][i]
                   + weight[3] * vertex_data[3][i];
    *dataOut = vertex;
 }
 
-void init (void) 
+void init (void)
 {
    GLUtesselator *tobj;
-   GLdouble rect[4][3] = {50.0, 50.0, 0.0,
-                          200.0, 50.0, 0.0,
-                          200.0, 200.0, 0.0,
-                          50.0, 200.0, 0.0};
-   GLdouble tri[3][3] = {75.0, 75.0, 0.0,
-                         125.0, 175.0, 0.0,
-                         175.0, 75.0, 0.0};
-   GLdouble star[5][6] = {250.0, 50.0, 0.0, 1.0, 0.0, 1.0,
-                          325.0, 200.0, 0.0, 1.0, 1.0, 0.0,
-                          400.0, 50.0, 0.0, 0.0, 1.0, 1.0,
-                          250.0, 150.0, 0.0, 1.0, 0.0, 0.0,
-                          400.0, 150.0, 0.0, 0.0, 1.0, 0.0};
+   GLdouble rect[4][3] = {{50.0, 50.0, 0.0},
+                          {200.0, 50.0, 0.0},
+                          {200.0, 200.0, 0.0},
+                          {50.0, 200.0, 0.0}};
+   GLdouble tri[3][3] = {{75.0, 75.0, 0.0},
+                         {125.0, 175.0, 0.0},
+                         {175.0, 75.0, 0.0}};
+   GLdouble star[5][6] = {{250.0, 50.0, 0.0, 1.0, 0.0, 1.0},
+                          {325.0, 200.0, 0.0, 1.0, 1.0, 0.0},
+                          {400.0, 50.0, 0.0, 0.0, 1.0, 1.0},
+                          {250.0, 150.0, 0.0, 1.0, 0.0, 0.0},
+                          {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}};
 
    glClearColor(0.0, 0.0, 0.0, 0.0);
 
    startList = glGenLists(2);
 
    tobj = gluNewTess();
-   gluTessCallback(tobj, GLU_TESS_VERTEX, 
+   gluTessCallback(tobj, GLU_TESS_VERTEX,
                    (GLvoid (CALLBACK*) ()) &glVertex3dv);
-   gluTessCallback(tobj, GLU_TESS_BEGIN, 
+   gluTessCallback(tobj, GLU_TESS_BEGIN,
                    (GLvoid (CALLBACK*) ()) &beginCallback);
-   gluTessCallback(tobj, GLU_TESS_END, 
+   gluTessCallback(tobj, GLU_TESS_END,
                    (GLvoid (CALLBACK*) ()) &endCallback);
-   gluTessCallback(tobj, GLU_TESS_ERROR, 
+   gluTessCallback(tobj, GLU_TESS_ERROR,
                    (GLvoid (CALLBACK*) ()) &errorCallback);
 
    /*  rectangle with triangular hole inside  */
    glNewList(startList, GL_COMPILE);
-   glShadeModel(GL_FLAT);    
+   glShadeModel(GL_FLAT);
    gluTessBeginPolygon(tobj, NULL);
       gluTessBeginContour(tobj);
          gluTessVertex(tobj, rect[0], rect[0]);
@@ -170,20 +170,20 @@ void init (void)
    gluTessEndPolygon(tobj);
    glEndList();
 
-   gluTessCallback(tobj, GLU_TESS_VERTEX, 
+   gluTessCallback(tobj, GLU_TESS_VERTEX,
                    (GLvoid (CALLBACK*) ()) &vertexCallback);
-   gluTessCallback(tobj, GLU_TESS_BEGIN, 
+   gluTessCallback(tobj, GLU_TESS_BEGIN,
                    (GLvoid (CALLBACK*) ()) &beginCallback);
-   gluTessCallback(tobj, GLU_TESS_END, 
+   gluTessCallback(tobj, GLU_TESS_END,
                    (GLvoid (CALLBACK*) ()) &endCallback);
-   gluTessCallback(tobj, GLU_TESS_ERROR, 
+   gluTessCallback(tobj, GLU_TESS_ERROR,
                    (GLvoid (CALLBACK*) ()) &errorCallback);
-   gluTessCallback(tobj, GLU_TESS_COMBINE, 
+   gluTessCallback(tobj, GLU_TESS_COMBINE,
                    (GLvoid (CALLBACK*) ()) &combineCallback);
 
    /*  smooth shaded, self-intersecting star  */
    glNewList(startList + 1, GL_COMPILE);
-   glShadeModel(GL_SMOOTH);    
+   glShadeModel(GL_SMOOTH);
    gluTessProperty(tobj, GLU_TESS_WINDING_RULE,
                    GLU_TESS_WINDING_POSITIVE);
    gluTessBeginPolygon(tobj, NULL);
@@ -228,7 +228,7 @@ int main(int argc, char** argv)
    glutReshapeFunc(reshape);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
-   return 0;  
+   return 0;
 }
 
 #else