|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 /* 00002 * freeglut_teapot.c 00003 * 00004 * Teapot(tm) rendering code. 00005 * 00006 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. 00007 * Written by Pawel W. Olszta, <olszta@sourceforge.net> 00008 * Creation date: Fri Dec 24 1999 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining a 00011 * copy of this software and associated documentation files (the "Software"), 00012 * to deal in the Software without restriction, including without limitation 00013 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00014 * and/or sell copies of the Software, and to permit persons to whom the 00015 * Software is furnished to do so, subject to the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be included 00018 * in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00021 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00023 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 00024 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00025 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00026 */ 00027 00028 /* 00029 * Original teapot code copyright follows: 00030 */ 00031 00032 /* 00033 * (c) Copyright 1993, Silicon Graphics, Inc. 00034 * 00035 * ALL RIGHTS RESERVED 00036 * 00037 * Permission to use, copy, modify, and distribute this software 00038 * for any purpose and without fee is hereby granted, provided 00039 * that the above copyright notice appear in all copies and that 00040 * both the copyright notice and this permission notice appear in 00041 * supporting documentation, and that the name of Silicon 00042 * Graphics, Inc. not be used in advertising or publicity 00043 * pertaining to distribution of the software without specific, 00044 * written prior permission. 00045 * 00046 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU 00047 * "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR 00048 * OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF 00049 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO 00050 * EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE 00051 * ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR 00052 * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, 00053 * INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, 00054 * SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR 00055 * NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY 00056 * OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00057 * ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR 00058 * PERFORMANCE OF THIS SOFTWARE. 00059 * 00060 * US Government Users Restricted Rights 00061 * 00062 * Use, duplication, or disclosure by the Government is subject to 00063 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 00064 * (c)(1)(ii) of the Rights in Technical Data and Computer 00065 * Software clause at DFARS 252.227-7013 and/or in similar or 00066 * successor clauses in the FAR or the DOD or NASA FAR 00067 * Supplement. Unpublished-- rights reserved under the copyright 00068 * laws of the United States. Contractor/manufacturer is Silicon 00069 * Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 00070 * 94039-7311. 00071 * 00072 * OpenGL(TM) is a trademark of Silicon Graphics, Inc. 00073 */ 00074 00075 #include <FL/glut.H> 00076 #include "freeglut_teapot_data.h" 00077 00078 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ 00079 00080 00081 static void fghTeapot( GLint grid, GLdouble scale, GLenum type ) 00082 { 00083 double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; 00084 long i, j, k, l; 00085 00086 glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT ); 00087 glEnable( GL_AUTO_NORMAL ); 00088 glEnable( GL_NORMALIZE ); 00089 glEnable( GL_MAP2_VERTEX_3 ); 00090 glEnable( GL_MAP2_TEXTURE_COORD_2 ); 00091 00092 glPushMatrix(); 00093 glRotated( 270.0, 1.0, 0.0, 0.0 ); 00094 glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale ); 00095 glTranslated( 0.0, 0.0, -1.5 ); 00096 00097 for (i = 0; i < 10; i++) { 00098 for (j = 0; j < 4; j++) { 00099 for (k = 0; k < 4; k++) { 00100 for (l = 0; l < 3; l++) { 00101 p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; 00102 q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; 00103 if (l == 1) 00104 q[j][k][l] *= -1.0; 00105 if (i < 6) { 00106 r[j][k][l] = 00107 cpdata[patchdata[i][j * 4 + (3 - k)]][l]; 00108 if (l == 0) 00109 r[j][k][l] *= -1.0; 00110 s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; 00111 if (l == 0) 00112 s[j][k][l] *= -1.0; 00113 if (l == 1) 00114 s[j][k][l] *= -1.0; 00115 } 00116 } 00117 } 00118 } 00119 00120 glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2, 00121 &tex[0][0][0]); 00122 glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, 00123 &p[0][0][0]); 00124 glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0); 00125 glEvalMesh2(type, 0, grid, 0, grid); 00126 glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, 00127 &q[0][0][0]); 00128 glEvalMesh2(type, 0, grid, 0, grid); 00129 if (i < 6) { 00130 glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, 00131 &r[0][0][0]); 00132 glEvalMesh2(type, 0, grid, 0, grid); 00133 glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, 00134 &s[0][0][0]); 00135 glEvalMesh2(type, 0, grid, 0, grid); 00136 } 00137 } 00138 00139 glPopMatrix(); 00140 glPopAttrib(); 00141 } 00142 00143 00144 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ 00145 00146 /* 00147 * Renders a beautiful wired teapot... 00148 */ 00149 void glutWireTeapot( GLdouble size ) 00150 { 00151 /* We will use the general teapot rendering code */ 00152 fghTeapot( 10, size, GL_LINE ); 00153 } 00154 00155 /* 00156 * Renders a beautiful filled teapot... 00157 */ 00158 void glutSolidTeapot( GLdouble size ) 00159 { 00160 /* We will use the general teapot rendering code */ 00161 fghTeapot( 7, size, GL_FILL ); 00162 } 00163 00164 /*** END OF FILE ***/