1c041511dScube 2c041511dScube/* Copyright (c) Mark J. Kilgard, 1994. */ 3c041511dScube 4c041511dScube/** 5c041511dScube(c) Copyright 1993, Silicon Graphics, Inc. 6c041511dScube 7c041511dScubeALL RIGHTS RESERVED 8c041511dScube 9c041511dScubePermission to use, copy, modify, and distribute this software 10c041511dScubefor any purpose and without fee is hereby granted, provided 11c041511dScubethat the above copyright notice appear in all copies and that 12c041511dScubeboth the copyright notice and this permission notice appear in 13c041511dScubesupporting documentation, and that the name of Silicon 14c041511dScubeGraphics, Inc. not be used in advertising or publicity 15c041511dScubepertaining to distribution of the software without specific, 16c041511dScubewritten prior permission. 17c041511dScube 18c041511dScubeTHE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU 19c041511dScube"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR 20c041511dScubeOTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF 21c041511dScubeMERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO 22c041511dScubeEVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE 23c041511dScubeELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR 24c041511dScubeCONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, 25c041511dScubeINCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, 26c041511dScubeSAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR 27c041511dScubeNOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY 28c041511dScubeOF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29c041511dScubeARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR 30c041511dScubePERFORMANCE OF THIS SOFTWARE. 31c041511dScube 32c041511dScubeUS Government Users Restricted Rights 33c041511dScube 34c041511dScubeUse, duplication, or disclosure by the Government is subject to 35c041511dScuberestrictions set forth in FAR 52.227.19(c)(2) or subparagraph 36c041511dScube(c)(1)(ii) of the Rights in Technical Data and Computer 37c041511dScubeSoftware clause at DFARS 252.227-7013 and/or in similar or 38c041511dScubesuccessor clauses in the FAR or the DOD or NASA FAR 39c041511dScubeSupplement. Unpublished-- rights reserved under the copyright 40c041511dScubelaws of the United States. Contractor/manufacturer is Silicon 41c041511dScubeGraphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 42c041511dScube94039-7311. 43c041511dScube 44c041511dScubeOpenGL(TM) is a trademark of Silicon Graphics, Inc. 45c041511dScube*/ 46c041511dScube 47c041511dScube#include "glutint.h" 48c041511dScube 49c041511dScube/* Rim, body, lid, and bottom data must be reflected in x and 50c041511dScube y; handle and spout data across the y axis only. */ 51c041511dScube 52c041511dScubestatic int patchdata[][16] = 53c041511dScube{ 54c041511dScube /* rim */ 55c041511dScube {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11, 56c041511dScube 12, 13, 14, 15}, 57c041511dScube /* body */ 58c041511dScube {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 59c041511dScube 24, 25, 26, 27}, 60c041511dScube {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 61c041511dScube 37, 38, 39, 40}, 62c041511dScube /* lid */ 63c041511dScube {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101, 64c041511dScube 101, 0, 1, 2, 3,}, 65c041511dScube {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112, 66c041511dScube 113, 114, 115, 116, 117}, 67c041511dScube /* bottom */ 68c041511dScube {118, 118, 118, 118, 124, 122, 119, 121, 123, 126, 69c041511dScube 125, 120, 40, 39, 38, 37}, 70c041511dScube /* handle */ 71c041511dScube {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 72c041511dScube 53, 54, 55, 56}, 73c041511dScube {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 74c041511dScube 28, 65, 66, 67}, 75c041511dScube /* spout */ 76c041511dScube {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 77c041511dScube 80, 81, 82, 83}, 78c041511dScube {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 79c041511dScube 92, 93, 94, 95} 80c041511dScube}; 81c041511dScube/* *INDENT-OFF* */ 82c041511dScube 83c041511dScubestatic float cpdata[][3] = 84c041511dScube{ 85c041511dScube {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0, 86c041511dScube -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125}, 87c041511dScube {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375, 88c041511dScube 0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375, 89c041511dScube 2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84, 90c041511dScube 2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875}, 91c041511dScube {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75, 92c041511dScube 1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35}, 93c041511dScube {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2, 94c041511dScube 0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12, 95c041511dScube 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225}, 96c041511dScube {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225}, 97c041511dScube {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0, 98c041511dScube -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5, 99c041511dScube -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3, 100c041511dScube 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0, 101c041511dScube 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0, 102c041511dScube 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8}, 103c041511dScube {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3, 104c041511dScube -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3, 105c041511dScube 1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2, 106c041511dScube -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0, 107c041511dScube 1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0, 108c041511dScube 0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66, 109c041511dScube 0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1}, 110c041511dScube {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7, 111c041511dScube -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0, 112c041511dScube 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375}, 113c041511dScube {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475}, 114c041511dScube {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4}, 115c041511dScube {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0, 116c041511dScube 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8, 117c041511dScube 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4, 118c041511dScube -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0, 119c041511dScube 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4, 120c041511dScube 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3, 121c041511dScube 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4}, 122c041511dScube {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425, 123c041511dScube -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425, 124c041511dScube 0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075}, 125c041511dScube {0.84, -1.5, 0.075} 126c041511dScube}; 127c041511dScube 128c041511dScubestatic float tex[2][2][2] = 129c041511dScube{ 130c041511dScube { {0, 0}, 131c041511dScube {1, 0}}, 132c041511dScube { {0, 1}, 133c041511dScube {1, 1}} 134c041511dScube}; 135c041511dScube 136c041511dScube/* *INDENT-ON* */ 137c041511dScube 138c041511dScubestatic void 139c041511dScubeteapot(GLint grid, GLdouble scale, GLenum type) 140c041511dScube{ 141c041511dScube float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; 142c041511dScube long i, j, k, l; 143c041511dScube 144c041511dScube glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT); 145c041511dScube glEnable(GL_AUTO_NORMAL); 146c041511dScube glEnable(GL_NORMALIZE); 147c041511dScube glEnable(GL_MAP2_VERTEX_3); 148c041511dScube glEnable(GL_MAP2_TEXTURE_COORD_2); 149c041511dScube glPushMatrix(); 150c041511dScube glRotatef(270.0, 1.0, 0.0, 0.0); 151c041511dScube glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale); 152c041511dScube glTranslatef(0.0, 0.0, -1.5); 153c041511dScube for (i = 0; i < 10; i++) { 154c041511dScube for (j = 0; j < 4; j++) { 155c041511dScube for (k = 0; k < 4; k++) { 156c041511dScube for (l = 0; l < 3; l++) { 157c041511dScube p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; 158c041511dScube q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; 159c041511dScube if (l == 1) 160c041511dScube q[j][k][l] *= -1.0; 161c041511dScube if (i < 6) { 162c041511dScube r[j][k][l] = 163c041511dScube cpdata[patchdata[i][j * 4 + (3 - k)]][l]; 164c041511dScube if (l == 0) 165c041511dScube r[j][k][l] *= -1.0; 166c041511dScube s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; 167c041511dScube if (l == 0) 168c041511dScube s[j][k][l] *= -1.0; 169c041511dScube if (l == 1) 170c041511dScube s[j][k][l] *= -1.0; 171c041511dScube } 172c041511dScube } 173c041511dScube } 174c041511dScube } 175c041511dScube glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, 176c041511dScube &tex[0][0][0]); 177c041511dScube glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, 178c041511dScube &p[0][0][0]); 179c041511dScube glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0); 180c041511dScube glEvalMesh2(type, 0, grid, 0, grid); 181c041511dScube glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, 182c041511dScube &q[0][0][0]); 183c041511dScube glEvalMesh2(type, 0, grid, 0, grid); 184c041511dScube if (i < 6) { 185c041511dScube glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, 186c041511dScube &r[0][0][0]); 187c041511dScube glEvalMesh2(type, 0, grid, 0, grid); 188c041511dScube glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, 189c041511dScube &s[0][0][0]); 190c041511dScube glEvalMesh2(type, 0, grid, 0, grid); 191c041511dScube } 192c041511dScube } 193c041511dScube glPopMatrix(); 194c041511dScube glPopAttrib(); 195c041511dScube} 196c041511dScube 197c041511dScube/* CENTRY */ 198c041511dScubevoid GLUTAPIENTRY 199c041511dScubeglutSolidTeapot(GLdouble scale) 200c041511dScube{ 201c041511dScube teapot(7, scale, GL_FILL); 202c041511dScube} 203c041511dScube 204c041511dScubevoid GLUTAPIENTRY 205c041511dScubeglutWireTeapot(GLdouble scale) 206c041511dScube{ 207c041511dScube teapot(10, scale, GL_LINE); 208c041511dScube} 209c041511dScube 210c041511dScube/* ENDCENTRY */ 211