-/*\r
- * freeglut_teapot.c\r
- *\r
- * Teapot(tm) rendering code.\r
- *\r
- * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.\r
- * Written by Pawel W. Olszta, <olszta@sourceforge.net>\r
- * Creation date: Fri Dec 24 1999\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-/*\r
- * Original teapot code copyright follows:\r
- */\r
-\r
-/*\r
- * (c) Copyright 1993, Silicon Graphics, Inc.\r
- *\r
- * ALL RIGHTS RESERVED\r
- *\r
- * Permission to use, copy, modify, and distribute this software\r
- * for any purpose and without fee is hereby granted, provided\r
- * that the above copyright notice appear in all copies and that\r
- * both the copyright notice and this permission notice appear in\r
- * supporting documentation, and that the name of Silicon\r
- * Graphics, Inc. not be used in advertising or publicity\r
- * pertaining to distribution of the software without specific,\r
- * written prior permission.\r
- *\r
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU\r
- * "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR\r
- * OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF\r
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO\r
- * EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE\r
- * ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR\r
- * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,\r
- * INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,\r
- * SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR\r
- * NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY\r
- * OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
- * ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR\r
- * PERFORMANCE OF THIS SOFTWARE.\r
- *\r
- * US Government Users Restricted Rights\r
- *\r
- * Use, duplication, or disclosure by the Government is subject to\r
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph\r
- * (c)(1)(ii) of the Rights in Technical Data and Computer\r
- * Software clause at DFARS 252.227-7013 and/or in similar or\r
- * successor clauses in the FAR or the DOD or NASA FAR\r
- * Supplement. Unpublished-- rights reserved under the copyright\r
- * laws of the United States. Contractor/manufacturer is Silicon\r
- * Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA\r
- * 94039-7311.\r
- *\r
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.\r
- */\r
-\r
-#include <GL/freeglut.h>\r
-#include "freeglut_internal.h"\r
-#include "freeglut_teapot_data.h"\r
-\r
-/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */\r
-\r
-\r
-static void fghTeapot( GLint grid, GLdouble scale, GLenum type )\r
-{\r
-#if defined(_WIN32_WCE)\r
- int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;\r
-#else\r
- double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];\r
- long i, j, k, l;\r
-#endif\r
-\r
- glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );\r
- glEnable( GL_AUTO_NORMAL );\r
- glEnable( GL_NORMALIZE );\r
- glEnable( GL_MAP2_VERTEX_3 );\r
- glEnable( GL_MAP2_TEXTURE_COORD_2 );\r
-\r
- glPushMatrix();\r
- glRotated( 270.0, 1.0, 0.0, 0.0 );\r
- glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );\r
- glTranslated( 0.0, 0.0, -1.5 );\r
-\r
-#if defined(_WIN32_WCE)\r
- glRotated( 90.0, 1.0, 0.0, 0.0 );\r
- glBegin( GL_TRIANGLE_STRIP );\r
-\r
- for( i = 0; i < numV-1; i++ )\r
- {\r
- int vidx = strip_vertices[i],\r
- nidx = strip_normals[i];\r
-\r
- if( vidx != -1 )\r
- {\r
- glNormal3fv( normals[nidx] );\r
- glVertex3fv( vertices[vidx] );\r
- }\r
- else\r
- {\r
- glEnd();\r
- glBegin( GL_TRIANGLE_STRIP );\r
- }\r
- }\r
-\r
- glEnd();\r
-#else\r
- for (i = 0; i < 10; i++) {\r
- for (j = 0; j < 4; j++) {\r
- for (k = 0; k < 4; k++) {\r
- for (l = 0; l < 3; l++) {\r
- p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];\r
- q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];\r
- if (l == 1)\r
- q[j][k][l] *= -1.0;\r
- if (i < 6) {\r
- r[j][k][l] =\r
- cpdata[patchdata[i][j * 4 + (3 - k)]][l];\r
- if (l == 0)\r
- r[j][k][l] *= -1.0;\r
- s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];\r
- if (l == 0)\r
- s[j][k][l] *= -1.0;\r
- if (l == 1)\r
- s[j][k][l] *= -1.0;\r
- }\r
- }\r
- }\r
- }\r
-\r
- glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,\r
- &tex[0][0][0]);\r
- glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,\r
- &p[0][0][0]);\r
- glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);\r
- glEvalMesh2(type, 0, grid, 0, grid);\r
- glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,\r
- &q[0][0][0]);\r
- glEvalMesh2(type, 0, grid, 0, grid);\r
- if (i < 6) {\r
- glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,\r
- &r[0][0][0]);\r
- glEvalMesh2(type, 0, grid, 0, grid);\r
- glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,\r
- &s[0][0][0]);\r
- glEvalMesh2(type, 0, grid, 0, grid);\r
- }\r
- }\r
-#endif /* defined(_WIN32_WCE) */\r
-\r
- glPopMatrix();\r
- glPopAttrib();\r
-}\r
-\r
-\r
-/* -- INTERFACE FUNCTIONS -------------------------------------------------- */\r
-\r
-/*\r
- * Renders a beautiful wired teapot...\r
- */\r
-void FGAPIENTRY glutWireTeapot( GLdouble size )\r
-{\r
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );\r
- /* We will use the general teapot rendering code */\r
- fghTeapot( 10, size, GL_LINE );\r
-}\r
-\r
-/*\r
- * Renders a beautiful filled teapot...\r
- */\r
-void FGAPIENTRY glutSolidTeapot( GLdouble size )\r
-{\r
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );\r
- /* We will use the general teapot rendering code */\r
- fghTeapot( 7, size, GL_FILL );\r
-}\r
-\r
-/*** END OF FILE ***/\r
-\r
-\r
-\r
-\r
-\r
+/*
+ * freeglut_teapot.c
+ *
+ * Teapot(tm) rendering code.
+ *
+ * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
+ * Written by Pawel W. Olszta, <olszta@sourceforge.net>
+ * Creation date: Fri Dec 24 1999
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Original teapot code copyright follows:
+ */
+
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ *
+ * 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 the name of Silicon
+ * Graphics, Inc. not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * 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, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
+ * EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
+ * ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
+ * INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
+ * SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
+ * NOT SILICON GRAPHICS, INC. HAS BEEN 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
+ *
+ * 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 clause at DFARS 252.227-7013 and/or in similar or
+ * successor clauses in the FAR or the DOD or NASA FAR
+ * Supplement. Unpublished-- rights reserved under the copyright
+ * laws of the United States. Contractor/manufacturer is Silicon
+ * Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+#include <GL/freeglut.h>
+#include "freeglut_internal.h"
+#include "freeglut_teapot_data.h"
+
+/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
+
+
+static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
+{
+#if defined(_WIN32_WCE)
+ int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;
+#else
+ double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
+ long i, j, k, l;
+#endif
+
+ glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
+ glEnable( GL_AUTO_NORMAL );
+ glEnable( GL_NORMALIZE );
+ glEnable( GL_MAP2_VERTEX_3 );
+ glEnable( GL_MAP2_TEXTURE_COORD_2 );
+
+ glPushMatrix();
+ glRotated( 270.0, 1.0, 0.0, 0.0 );
+ glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );
+ glTranslated( 0.0, 0.0, -1.5 );
+
+#if defined(_WIN32_WCE)
+ glRotated( 90.0, 1.0, 0.0, 0.0 );
+ glBegin( GL_TRIANGLE_STRIP );
+
+ for( i = 0; i < numV-1; i++ )
+ {
+ int vidx = strip_vertices[i],
+ nidx = strip_normals[i];
+
+ if( vidx != -1 )
+ {
+ glNormal3fv( normals[nidx] );
+ glVertex3fv( vertices[vidx] );
+ }
+ else
+ {
+ glEnd();
+ glBegin( GL_TRIANGLE_STRIP );
+ }
+ }
+
+ glEnd();
+#else
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 4; j++) {
+ for (k = 0; k < 4; k++) {
+ for (l = 0; l < 3; l++) {
+ p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
+ q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 1)
+ q[j][k][l] *= -1.0;
+ if (i < 6) {
+ r[j][k][l] =
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 0)
+ r[j][k][l] *= -1.0;
+ s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
+ if (l == 0)
+ s[j][k][l] *= -1.0;
+ if (l == 1)
+ s[j][k][l] *= -1.0;
+ }
+ }
+ }
+ }
+
+ glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,
+ &tex[0][0][0]);
+ glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
+ &p[0][0][0]);
+ glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
+ &q[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ if (i < 6) {
+ glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
+ &r[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
+ &s[0][0][0]);
+ glEvalMesh2(type, 0, grid, 0, grid);
+ }
+ }
+#endif /* defined(_WIN32_WCE) */
+
+ glPopMatrix();
+ glPopAttrib();
+}
+
+
+/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
+
+/*
+ * Renders a beautiful wired teapot...
+ */
+void FGAPIENTRY glutWireTeapot( GLdouble size )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );
+ /* We will use the general teapot rendering code */
+ fghTeapot( 10, size, GL_LINE );
+}
+
+/*
+ * Renders a beautiful filled teapot...
+ */
+void FGAPIENTRY glutSolidTeapot( GLdouble size )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );
+ /* We will use the general teapot rendering code */
+ fghTeapot( 7, size, GL_FILL );
+}
+
+/*** END OF FILE ***/
+
+
+
+
+