4 * Freeglut geometry rendering methods.
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Creation date: Fri Dec 3 1999
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include <GL/freeglut.h>
29 #include "fg_internal.h"
32 * TODO BEFORE THE STABLE RELEASE:
36 * Following functions have been contributed by Andreas Umbach.
38 * glutWireCube() -- looks OK
39 * glutSolidCube() -- OK
41 * Those functions have been implemented by John Fay.
43 * glutWireTorus() -- looks OK
44 * glutSolidTorus() -- looks OK
45 * glutWireDodecahedron() -- looks OK
46 * glutSolidDodecahedron() -- looks OK
47 * glutWireOctahedron() -- looks OK
48 * glutSolidOctahedron() -- looks OK
49 * glutWireTetrahedron() -- looks OK
50 * glutSolidTetrahedron() -- looks OK
51 * glutWireIcosahedron() -- looks OK
52 * glutSolidIcosahedron() -- looks OK
54 * The Following functions have been updated by Nigel Stewart, based
55 * on FreeGLUT 2.0.0 implementations:
57 * glutWireSphere() -- looks OK
58 * glutSolidSphere() -- looks OK
59 * glutWireCone() -- looks OK
60 * glutSolidCone() -- looks OK
64 /* General function for drawing geometry. As for all geometry we have no
65 * redundancy (or hardly any in the case of cones and cylinders) in terms
66 * of the vertex/normal combinations, we just use glDrawArrays.
67 * useWireMode controls the drawing of solids (false) or wire frame
68 * versions (TRUE) of the geometry you pass
70 static void fghDrawGeometry(GLenum vertexMode, GLdouble* vertices, GLdouble* normals, GLsizei numVertices, GLboolean useWireMode)
74 glPushAttrib(GL_POLYGON_BIT);
75 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
80 glEnableClientState(GL_VERTEX_ARRAY);
81 glEnableClientState(GL_NORMAL_ARRAY);
83 glVertexPointer(3, GL_DOUBLE, 0, vertices);
84 glNormalPointer(GL_DOUBLE, 0, normals);
85 glDrawArrays(vertexMode, 0, numVertices);
87 glDisableClientState(GL_VERTEX_ARRAY);
88 glDisableClientState(GL_NORMAL_ARRAY);
94 for(i=0; i<numVertices; i++)
96 glNormal3dv(normals+i*3);
97 printf("n(%i) = (%1.4f,%1.4f,%1.4f)\n",i,*(normals+i*3),*(normals+i*3+1),*(normals+i*3+2));
98 glVertex3dv(vertices+i*3);
99 printf("v(%i) = (%1.4f,%1.4f,%1.4f)\n",i,*(vertices+i*3),*(vertices+i*3+1),*(vertices+i*3+2));
110 static void fghGenerateGeometry(int numFaces, int numVertPerFace, GLdouble *vertices, GLubyte* vertIndices, GLdouble *normals, GLdouble *vertOut, GLdouble *normOut)
114 * Build array with vertices from vertex coordinates and vertex indices
115 * Do same for normals.
116 * Need to do this because of different normals at shared vertices
117 * (and because normals' coordinates need to be negated).
119 for (i=0; i<numFaces; i++)
122 int faceIdxVertIdx = i*numVertPerFace;
123 for (j=0; j<numVertPerFace; j++)
125 int outIdx = i*numVertPerFace*3+j*3;
126 int vertIdx = vertIndices[faceIdxVertIdx+j]*3;
128 vertOut[outIdx ] = vertices[vertIdx ];
129 vertOut[outIdx+1] = vertices[vertIdx+1];
130 vertOut[outIdx+2] = vertices[vertIdx+2];
132 normOut[outIdx ] = normals [normIdx ];
133 normOut[outIdx+1] = normals [normIdx+1];
134 normOut[outIdx+2] = normals [normIdx+2];
140 /* -- INTERNAL SETUP OF GEOMETRY --------------------------------------- */
141 static unsigned int ipow (int x, unsigned int y)
143 return y==0? 1: y==1? x: (y%2? x: 1) * ipow(x*x, y/2);
146 /* -- stuff that can be cached -- */
147 /* Cache of input to glDrawArrays */
148 #define DECLARE_SHAPE_CACHE(name,nameICaps,nameCaps)\
149 static GLboolean name##Cached = FALSE;\
150 static GLdouble name##_verts[nameCaps##_VERT_ELEM_PER_OBJ];\
151 static GLdouble name##_norms[nameCaps##_VERT_ELEM_PER_OBJ];\
152 static void fgh##nameICaps##Generate()\
154 fghGenerateGeometry(nameCaps##_NUM_FACES, nameCaps##_NUM_VERT_PER_FACE,\
155 name##_v, name##_vi, name##_n,\
156 name##_verts, name##_norms);\
159 * In general, we build arrays with all vertices or normals.
160 * We cant compress this and use glDrawElements as all combinations of
161 * vertex and normals are unique.
165 #define CUBE_NUM_VERT 8
166 #define CUBE_NUM_FACES 6
167 #define CUBE_NUM_VERT_PER_FACE 4
168 #define CUBE_VERT_PER_OBJ CUBE_NUM_FACES*CUBE_NUM_VERT_PER_FACE
169 #define CUBE_VERT_ELEM_PER_OBJ CUBE_VERT_PER_OBJ*3
170 /* Vertex Coordinates */
171 static GLdouble cube_v[CUBE_NUM_VERT*3] =
183 static GLdouble cube_n[CUBE_NUM_FACES*3] =
194 static GLubyte cube_vi[CUBE_VERT_PER_OBJ] =
203 DECLARE_SHAPE_CACHE(cube,Cube,CUBE);
205 /* -- Octahedron -- */
206 #define OCTAHEDRON_NUM_VERT 6
207 #define OCTAHEDRON_NUM_FACES 8
208 #define OCTAHEDRON_NUM_VERT_PER_FACE 3
209 #define OCTAHEDRON_VERT_PER_OBJ OCTAHEDRON_NUM_FACES*OCTAHEDRON_NUM_VERT_PER_FACE
210 #define OCTAHEDRON_VERT_ELEM_PER_OBJ OCTAHEDRON_VERT_PER_OBJ*3
212 /* Vertex Coordinates */
213 static GLdouble octahedron_v[OCTAHEDRON_NUM_VERT*3] =
224 static GLdouble octahedron_n[OCTAHEDRON_NUM_FACES*3] =
226 0.577350269189, 0.577350269189, 0.577350269189, /* sqrt(1/3) */
227 0.577350269189, 0.577350269189,-0.577350269189,
228 0.577350269189,-0.577350269189, 0.577350269189,
229 0.577350269189,-0.577350269189,-0.577350269189,
230 -0.577350269189, 0.577350269189, 0.577350269189,
231 -0.577350269189, 0.577350269189,-0.577350269189,
232 -0.577350269189,-0.577350269189, 0.577350269189,
233 -0.577350269189,-0.577350269189,-0.577350269189
238 static GLubyte octahedron_vi[OCTAHEDRON_VERT_PER_OBJ] =
249 DECLARE_SHAPE_CACHE(octahedron,Octahedron,OCTAHEDRON);
251 /* -- Tetrahedron -- */
252 /* Magic Numbers: r0 = ( 1, 0, 0 )
253 * r1 = ( -1/3, 2 sqrt(2) / 3, 0 )
254 * r2 = ( -1/3, - sqrt(2) / 3, sqrt(6) / 3 )
255 * r3 = ( -1/3, - sqrt(2) / 3, -sqrt(6) / 3 )
256 * |r0| = |r1| = |r2| = |r3| = 1
257 * Distance between any two points is 2 sqrt(6) / 3
259 * Normals: The unit normals are simply the negative of the coordinates of the point not on the surface.
261 #define TETRAHEDRON_NUM_VERT 4
262 #define TETRAHEDRON_NUM_FACES 4
263 #define TETRAHEDRON_NUM_VERT_PER_FACE 3
264 #define TETRAHEDRON_VERT_PER_OBJ TETRAHEDRON_NUM_FACES*TETRAHEDRON_NUM_VERT_PER_FACE
265 #define TETRAHEDRON_VERT_ELEM_PER_OBJ TETRAHEDRON_VERT_PER_OBJ*3
267 /* Vertex Coordinates */
268 static GLdouble tetrahedron_v[TETRAHEDRON_NUM_VERT*3] =
271 -0.333333333333, 0.942809041582, 0.0,
272 -0.333333333333, -0.471404520791, 0.816496580928,
273 -0.333333333333, -0.471404520791, -0.816496580928
276 static GLdouble tetrahedron_n[TETRAHEDRON_NUM_FACES*3] =
279 0.333333333333, -0.942809041582, 0.0,
280 0.333333333333, 0.471404520791, -0.816496580928,
281 0.333333333333, 0.471404520791, 0.816496580928
285 static GLubyte tetrahedron_vi[TETRAHEDRON_VERT_PER_OBJ] =
292 DECLARE_SHAPE_CACHE(tetrahedron,Tetrahedron,TETRAHEDRON);
294 /* -- Sierpinski Sponge -- */
295 static void fghSierpinskiSpongeGenerate ( int numLevels, GLdouble offset[3], GLdouble scale, GLdouble* vertices, GLdouble* normals )
298 if ( numLevels == 0 )
300 for (i=0; i<TETRAHEDRON_NUM_FACES; i++)
303 int faceIdxVertIdx = i*TETRAHEDRON_NUM_VERT_PER_FACE;
304 for (j=0; j<TETRAHEDRON_NUM_VERT_PER_FACE; j++)
306 int outIdx = i*TETRAHEDRON_NUM_VERT_PER_FACE*3+j*3;
307 int vertIdx = tetrahedron_vi[faceIdxVertIdx+j]*3;
309 vertices[outIdx ] = offset[0] + scale * tetrahedron_v[vertIdx ];
310 vertices[outIdx+1] = offset[1] + scale * tetrahedron_v[vertIdx+1];
311 vertices[outIdx+2] = offset[2] + scale * tetrahedron_v[vertIdx+2];
313 normals [outIdx ] = tetrahedron_n[normIdx ];
314 normals [outIdx+1] = tetrahedron_n[normIdx+1];
315 normals [outIdx+2] = tetrahedron_n[normIdx+2];
319 else if ( numLevels > 0 )
321 GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */
322 unsigned int stride = ipow(4,--numLevels)*TETRAHEDRON_VERT_ELEM_PER_OBJ;
324 for ( i = 0 ; i < TETRAHEDRON_NUM_FACES ; i++ )
327 local_offset[0] = offset[0] + scale * tetrahedron_v[idx ];
328 local_offset[1] = offset[1] + scale * tetrahedron_v[idx+1];
329 local_offset[2] = offset[2] + scale * tetrahedron_v[idx+2];
330 fghSierpinskiSpongeGenerate ( numLevels, local_offset, scale, vertices+i*stride, normals+i*stride );
335 /* -- Now the various shapes involving circles -- */
337 * Compute lookup table of cos and sin values forming a cirle
340 * It is the responsibility of the caller to free these tables
341 * The size of the table is (n+1) to form a connected loop
342 * The last entry is exactly the same as the first
343 * The sign of n can be flipped to get the reverse loop
345 static void fghCircleTable(double **sint,double **cost,const int n)
349 /* Table size, the sign of n flips the circle direction */
351 const int size = abs(n);
353 /* Determine the angle between samples */
355 const double angle = 2*M_PI/(double)( ( n == 0 ) ? 1 : n );
357 /* Allocate memory for n samples, plus duplicate of first entry at the end */
359 *sint = (double *) calloc(sizeof(double), size+1);
360 *cost = (double *) calloc(sizeof(double), size+1);
362 /* Bail out if memory allocation fails, fgError never returns */
364 if (!(*sint) || !(*cost))
368 fgError("Failed to allocate memory in fghCircleTable");
371 /* Compute cos and sin around the circle */
376 for (i=1; i<size; i++)
378 (*sint)[i] = sin(angle*i);
379 (*cost)[i] = cos(angle*i);
382 /* Last sample is duplicate of the first */
384 (*sint)[size] = (*sint)[0];
385 (*cost)[size] = (*cost)[0];
389 /* -- INTERNAL DRAWING functions to avoid code duplication ------------- */
390 #define DECLARE_INTERNAL_DRAW(name,nameICaps,nameCaps)\
391 static void fgh##nameICaps( GLboolean useWireMode )\
395 fgh##nameICaps##Generate();\
396 name##Cached = TRUE;\
398 fghDrawGeometry(GL_TRIANGLES,name##_verts,name##_norms,nameCaps##_VERT_PER_OBJ,useWireMode);\
401 static void fghCube( GLdouble dSize, GLboolean useWireMode )
413 /* Need to build new vertex list containing vertices for cube of different size */
414 GLdouble *vertices = malloc(CUBE_VERT_ELEM_PER_OBJ * sizeof(GLdouble));
415 for (i=0; i<CUBE_VERT_ELEM_PER_OBJ; i++)
416 vertices[i] = dSize*cube_verts[i];
418 fghDrawGeometry(GL_QUADS,vertices ,cube_norms,CUBE_VERT_PER_OBJ,useWireMode);
421 fghDrawGeometry(GL_QUADS,cube_verts,cube_norms,CUBE_VERT_PER_OBJ,useWireMode);
423 DECLARE_INTERNAL_DRAW(octahedron,Octahedron,OCTAHEDRON);
424 DECLARE_INTERNAL_DRAW(tetrahedron,Tetrahedron,TETRAHEDRON);
426 static void fghSierpinskiSponge ( int numLevels, GLdouble offset[3], GLdouble scale, GLboolean useWireMode )
430 GLsizei numTetr = numLevels<0? 0 : ipow(4,numLevels); /* No sponge for numLevels below 0 */
431 GLsizei numVert = numTetr*TETRAHEDRON_VERT_PER_OBJ;
435 /* Allocate memory */
436 vertices = malloc(numVert*3 * sizeof(GLdouble));
437 normals = malloc(numVert*3 * sizeof(GLdouble));
439 /* Generate elements */
440 fghSierpinskiSpongeGenerate ( numLevels, offset, scale, vertices, normals );
442 /* Draw and cleanup */
443 fghDrawGeometry(GL_TRIANGLES,vertices,normals,numVert,useWireMode);
450 /* -- INTERFACE FUNCTIONS ---------------------------------------------- */
454 * Draws a solid sphere
456 void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
460 /* Adjust z and radius as stacks are drawn. */
465 /* Pre-computed circle */
467 double *sint1,*cost1;
468 double *sint2,*cost2;
470 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" );
472 fghCircleTable(&sint1,&cost1,-slices);
473 fghCircleTable(&sint2,&cost2,stacks*2);
475 /* The top stack is covered with a triangle fan */
478 z1 = cost2[(stacks>0)?1:0];
480 r1 = sint2[(stacks>0)?1:0];
482 glBegin(GL_TRIANGLE_FAN);
485 glVertex3d(0,0,radius);
487 for (j=slices; j>=0; j--)
489 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
490 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
495 /* Cover each stack with a quad strip, except the top and bottom stacks */
497 for( i=1; i<stacks-1; i++ )
499 z0 = z1; z1 = cost2[i+1];
500 r0 = r1; r1 = sint2[i+1];
502 glBegin(GL_QUAD_STRIP);
504 for(j=0; j<=slices; j++)
506 glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
507 glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
508 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
509 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
515 /* The bottom stack is covered with a triangle fan */
520 glBegin(GL_TRIANGLE_FAN);
523 glVertex3d(0,0,-radius);
525 for (j=0; j<=slices; j++)
527 glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
528 glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
533 /* Release sin and cos tables */
542 * Draws a wire sphere
544 void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
548 /* Adjust z and radius as stacks and slices are drawn. */
553 /* Pre-computed circle */
555 double *sint1,*cost1;
556 double *sint2,*cost2;
558 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSphere" );
560 fghCircleTable(&sint1,&cost1,-slices );
561 fghCircleTable(&sint2,&cost2, stacks*2);
563 /* Draw a line loop for each stack */
565 for (i=1; i<stacks; i++)
570 glBegin(GL_LINE_LOOP);
572 for(j=0; j<=slices; j++)
578 glVertex3d(x*r*radius,y*r*radius,z*radius);
584 /* Draw a line loop for each slice */
586 for (i=0; i<slices; i++)
588 glBegin(GL_LINE_STRIP);
590 for(j=0; j<=stacks; j++)
592 x = cost1[i]*sint2[j];
593 y = sint1[i]*sint2[j];
597 glVertex3d(x*radius,y*radius,z*radius);
603 /* Release sin and cos tables */
614 void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks )
618 /* Step in z and radius as stacks are drawn. */
623 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
624 const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );
626 /* Scaling factors for vertex normals */
628 const double cosn = ( height / sqrt ( height * height + base * base ));
629 const double sinn = ( base / sqrt ( height * height + base * base ));
631 /* Pre-computed circle */
635 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCone" );
637 fghCircleTable(&sint,&cost,-slices);
639 /* Cover the circular base with a triangle fan... */
647 glBegin(GL_TRIANGLE_FAN);
649 glNormal3d(0.0,0.0,-1.0);
650 glVertex3d(0.0,0.0, z0 );
652 for (j=0; j<=slices; j++)
653 glVertex3d(cost[j]*r0, sint[j]*r0, z0);
657 /* Cover each stack with a quad strip, except the top stack */
659 for( i=0; i<stacks-1; i++ )
661 glBegin(GL_QUAD_STRIP);
663 for(j=0; j<=slices; j++)
665 glNormal3d(cost[j]*cosn, sint[j]*cosn, sinn);
666 glVertex3d(cost[j]*r0, sint[j]*r0, z0 );
667 glVertex3d(cost[j]*r1, sint[j]*r1, z1 );
670 z0 = z1; z1 += zStep;
671 r0 = r1; r1 -= rStep;
676 /* The top stack is covered with individual triangles */
678 glBegin(GL_TRIANGLES);
680 glNormal3d(cost[0]*sinn, sint[0]*sinn, cosn);
682 for (j=0; j<slices; j++)
684 glVertex3d(cost[j+0]*r0, sint[j+0]*r0, z0 );
685 glVertex3d(0, 0, height);
686 glNormal3d(cost[j+1]*sinn, sint[j+1]*sinn, cosn );
687 glVertex3d(cost[j+1]*r0, sint[j+1]*r0, z0 );
692 /* Release sin and cos tables */
701 void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
705 /* Step in z and radius as stacks are drawn. */
710 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
711 const double rStep = base / ( ( stacks > 0 ) ? stacks : 1 );
713 /* Scaling factors for vertex normals */
715 const double cosn = ( height / sqrt ( height * height + base * base ));
716 const double sinn = ( base / sqrt ( height * height + base * base ));
718 /* Pre-computed circle */
722 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCone" );
724 fghCircleTable(&sint,&cost,-slices);
726 /* Draw the stacks... */
728 for (i=0; i<stacks; i++)
730 glBegin(GL_LINE_LOOP);
732 for( j=0; j<slices; j++ )
734 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn);
735 glVertex3d(cost[j]*r, sint[j]*r, z );
744 /* Draw the slices */
750 for (j=0; j<slices; j++)
752 glNormal3d(cost[j]*sinn, sint[j]*sinn, cosn );
753 glVertex3d(cost[j]*r, sint[j]*r, 0.0 );
754 glVertex3d(0.0, 0.0, height);
759 /* Release sin and cos tables */
767 * Draws a solid cylinder
769 void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
773 /* Step in z and radius as stacks are drawn. */
776 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
778 /* Pre-computed circle */
782 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCylinder" );
784 fghCircleTable(&sint,&cost,-slices);
786 /* Cover the base and top */
788 glBegin(GL_TRIANGLE_FAN);
789 glNormal3d(0.0, 0.0, -1.0 );
790 glVertex3d(0.0, 0.0, 0.0 );
791 for (j=0; j<=slices; j++)
792 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0);
795 glBegin(GL_TRIANGLE_FAN);
796 glNormal3d(0.0, 0.0, 1.0 );
797 glVertex3d(0.0, 0.0, height);
798 for (j=slices; j>=0; j--)
799 glVertex3d(cost[j]*radius, sint[j]*radius, height);
807 for (i=1; i<=stacks; i++)
812 glBegin(GL_QUAD_STRIP);
813 for (j=0; j<=slices; j++ )
815 glNormal3d(cost[j], sint[j], 0.0 );
816 glVertex3d(cost[j]*radius, sint[j]*radius, z0 );
817 glVertex3d(cost[j]*radius, sint[j]*radius, z1 );
821 z0 = z1; z1 += zStep;
824 /* Release sin and cos tables */
831 * Draws a wire cylinder
833 void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, GLint stacks)
837 /* Step in z and radius as stacks are drawn. */
840 const double zStep = height / ( ( stacks > 0 ) ? stacks : 1 );
842 /* Pre-computed circle */
846 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCylinder" );
848 fghCircleTable(&sint,&cost,-slices);
850 /* Draw the stacks... */
852 for (i=0; i<=stacks; i++)
857 glBegin(GL_LINE_LOOP);
859 for( j=0; j<slices; j++ )
861 glNormal3d(cost[j], sint[j], 0.0);
862 glVertex3d(cost[j]*radius, sint[j]*radius, z );
870 /* Draw the slices */
874 for (j=0; j<slices; j++)
876 glNormal3d(cost[j], sint[j], 0.0 );
877 glVertex3d(cost[j]*radius, sint[j]*radius, 0.0 );
878 glVertex3d(cost[j]*radius, sint[j]*radius, height);
883 /* Release sin and cos tables */
892 void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
894 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
895 double *vertex, *normal;
897 double spsi, cpsi, sphi, cphi ;
899 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTorus" );
901 if ( nSides < 1 ) nSides = 1;
902 if ( nRings < 1 ) nRings = 1;
904 /* Allocate the vertices array */
905 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
906 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
910 dpsi = 2.0 * M_PI / (double)nRings ;
911 dphi = -2.0 * M_PI / (double)nSides ;
914 for( j=0; j<nRings; j++ )
920 for( i=0; i<nSides; i++ )
922 int offset = 3 * ( j * nSides + i ) ;
925 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
926 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
927 *(vertex + offset + 2) = sphi * iradius ;
928 *(normal + offset + 0) = cpsi * cphi ;
929 *(normal + offset + 1) = spsi * cphi ;
930 *(normal + offset + 2) = sphi ;
937 for( i=0; i<nSides; i++ )
939 glBegin( GL_LINE_LOOP );
941 for( j=0; j<nRings; j++ )
943 int offset = 3 * ( j * nSides + i ) ;
944 glNormal3dv( normal + offset );
945 glVertex3dv( vertex + offset );
951 for( j=0; j<nRings; j++ )
953 glBegin(GL_LINE_LOOP);
955 for( i=0; i<nSides; i++ )
957 int offset = 3 * ( j * nSides + i ) ;
958 glNormal3dv( normal + offset );
959 glVertex3dv( vertex + offset );
971 * Draws a solid torus
973 void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLint nSides, GLint nRings )
975 double iradius = dInnerRadius, oradius = dOuterRadius, phi, psi, dpsi, dphi;
976 double *vertex, *normal;
978 double spsi, cpsi, sphi, cphi ;
980 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTorus" );
982 if ( nSides < 1 ) nSides = 1;
983 if ( nRings < 1 ) nRings = 1;
985 /* Increment the number of sides and rings to allow for one more point than surface */
989 /* Allocate the vertices array */
990 vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings );
991 normal = (double *)calloc( sizeof(double), 3 * nSides * nRings );
995 dpsi = 2.0 * M_PI / (double)(nRings - 1) ;
996 dphi = -2.0 * M_PI / (double)(nSides - 1) ;
999 for( j=0; j<nRings; j++ )
1001 cpsi = cos ( psi ) ;
1002 spsi = sin ( psi ) ;
1005 for( i=0; i<nSides; i++ )
1007 int offset = 3 * ( j * nSides + i ) ;
1008 cphi = cos ( phi ) ;
1009 sphi = sin ( phi ) ;
1010 *(vertex + offset + 0) = cpsi * ( oradius + cphi * iradius ) ;
1011 *(vertex + offset + 1) = spsi * ( oradius + cphi * iradius ) ;
1012 *(vertex + offset + 2) = sphi * iradius ;
1013 *(normal + offset + 0) = cpsi * cphi ;
1014 *(normal + offset + 1) = spsi * cphi ;
1015 *(normal + offset + 2) = sphi ;
1022 glBegin( GL_QUADS );
1023 for( i=0; i<nSides-1; i++ )
1025 for( j=0; j<nRings-1; j++ )
1027 int offset = 3 * ( j * nSides + i ) ;
1028 glNormal3dv( normal + offset );
1029 glVertex3dv( vertex + offset );
1030 glNormal3dv( normal + offset + 3 );
1031 glVertex3dv( vertex + offset + 3 );
1032 glNormal3dv( normal + offset + 3 * nSides + 3 );
1033 glVertex3dv( vertex + offset + 3 * nSides + 3 );
1034 glNormal3dv( normal + offset + 3 * nSides );
1035 glVertex3dv( vertex + offset + 3 * nSides );
1049 void FGAPIENTRY glutWireDodecahedron( void )
1051 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireDodecahedron" );
1053 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
1054 * of a cube. The coordinates of the points are:
1055 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
1056 * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or
1057 * x = 0.61803398875 and z = 1.61803398875.
1059 glBegin ( GL_LINE_LOOP ) ;
1060 glNormal3d ( 0.0, 0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1062 glBegin ( GL_LINE_LOOP ) ;
1063 glNormal3d ( 0.0, 0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1065 glBegin ( GL_LINE_LOOP ) ;
1066 glNormal3d ( 0.0, -0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1068 glBegin ( GL_LINE_LOOP ) ;
1069 glNormal3d ( 0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1072 glBegin ( GL_LINE_LOOP ) ;
1073 glNormal3d ( 0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1075 glBegin ( GL_LINE_LOOP ) ;
1076 glNormal3d ( -0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1078 glBegin ( GL_LINE_LOOP ) ;
1079 glNormal3d ( 0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1081 glBegin ( GL_LINE_LOOP ) ;
1082 glNormal3d ( -0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1085 glBegin ( GL_LINE_LOOP ) ;
1086 glNormal3d ( 0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1088 glBegin ( GL_LINE_LOOP ) ;
1089 glNormal3d ( 0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1091 glBegin ( GL_LINE_LOOP ) ;
1092 glNormal3d ( -0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1094 glBegin ( GL_LINE_LOOP ) ;
1095 glNormal3d ( -0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1102 void FGAPIENTRY glutSolidDodecahedron( void )
1104 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidDodecahedron" );
1106 /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
1107 * of a cube. The coordinates of the points are:
1108 * (+-x,0, z); (+-1, 1, 1); (0, z, x )
1109 * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or
1110 * x = 0.61803398875 and z = 1.61803398875.
1112 glBegin ( GL_POLYGON ) ;
1113 glNormal3d ( 0.0, 0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1115 glBegin ( GL_POLYGON ) ;
1116 glNormal3d ( 0.0, 0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1118 glBegin ( GL_POLYGON ) ;
1119 glNormal3d ( 0.0, -0.525731112119, 0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1121 glBegin ( GL_POLYGON ) ;
1122 glNormal3d ( 0.0, -0.525731112119, -0.850650808354 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1125 glBegin ( GL_POLYGON ) ;
1126 glNormal3d ( 0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1128 glBegin ( GL_POLYGON ) ;
1129 glNormal3d ( -0.850650808354, 0.0, 0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, 1.61803398875 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1131 glBegin ( GL_POLYGON ) ;
1132 glNormal3d ( 0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( 0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1134 glBegin ( GL_POLYGON ) ;
1135 glNormal3d ( -0.850650808354, 0.0, -0.525731112119 ) ; glVertex3d ( -0.61803398875, 0.0, -1.61803398875 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1138 glBegin ( GL_POLYGON ) ;
1139 glNormal3d ( 0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( 1.0, 1.0, -1.0 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 1.0, 1.0, 1.0 ) ;
1141 glBegin ( GL_POLYGON ) ;
1142 glNormal3d ( 0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( 1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( 1.0, -1.0, 1.0 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 1.0, -1.0, -1.0 ) ;
1144 glBegin ( GL_POLYGON ) ;
1145 glNormal3d ( -0.525731112119, 0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, 0.61803398875, 0.0 ) ; glVertex3d ( -1.0, 1.0, 1.0 ) ; glVertex3d ( 0.0, 1.61803398875, 0.61803398875 ) ; glVertex3d ( 0.0, 1.61803398875, -0.61803398875 ) ; glVertex3d ( -1.0, 1.0, -1.0 ) ;
1147 glBegin ( GL_POLYGON ) ;
1148 glNormal3d ( -0.525731112119, -0.850650808354, 0.0 ) ; glVertex3d ( -1.61803398875, -0.61803398875, 0.0 ) ; glVertex3d ( -1.0, -1.0, -1.0 ) ; glVertex3d ( 0.0, -1.61803398875, -0.61803398875 ) ; glVertex3d ( 0.0, -1.61803398875, 0.61803398875 ) ; glVertex3d ( -1.0, -1.0, 1.0 ) ;
1155 static double icos_r[12][3] = {
1157 { 0.447213595500, 0.894427191000, 0.0 },
1158 { 0.447213595500, 0.276393202252, 0.850650808354 },
1159 { 0.447213595500, -0.723606797748, 0.525731112119 },
1160 { 0.447213595500, -0.723606797748, -0.525731112119 },
1161 { 0.447213595500, 0.276393202252, -0.850650808354 },
1162 { -0.447213595500, -0.894427191000, 0.0 },
1163 { -0.447213595500, -0.276393202252, 0.850650808354 },
1164 { -0.447213595500, 0.723606797748, 0.525731112119 },
1165 { -0.447213595500, 0.723606797748, -0.525731112119 },
1166 { -0.447213595500, -0.276393202252, -0.850650808354 },
1170 static int icos_v [20][3] = {
1193 void FGAPIENTRY glutWireIcosahedron( void )
1197 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireIcosahedron" );
1199 for ( i = 0; i < 20; i++ )
1202 normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
1203 normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
1204 normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
1205 glBegin ( GL_LINE_LOOP ) ;
1206 glNormal3dv ( normal ) ;
1207 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
1208 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
1209 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
1217 void FGAPIENTRY glutSolidIcosahedron( void )
1221 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidIcosahedron" );
1223 glBegin ( GL_TRIANGLES ) ;
1224 for ( i = 0; i < 20; i++ )
1227 normal[0] = ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) - ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) ;
1228 normal[1] = ( icos_r[icos_v[i][1]][2] - icos_r[icos_v[i][0]][2] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) - ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][2] - icos_r[icos_v[i][0]][2] ) ;
1229 normal[2] = ( icos_r[icos_v[i][1]][0] - icos_r[icos_v[i][0]][0] ) * ( icos_r[icos_v[i][2]][1] - icos_r[icos_v[i][0]][1] ) - ( icos_r[icos_v[i][1]][1] - icos_r[icos_v[i][0]][1] ) * ( icos_r[icos_v[i][2]][0] - icos_r[icos_v[i][0]][0] ) ;
1230 glNormal3dv ( normal ) ;
1231 glVertex3dv ( icos_r[icos_v[i][0]] ) ;
1232 glVertex3dv ( icos_r[icos_v[i][1]] ) ;
1233 glVertex3dv ( icos_r[icos_v[i][2]] ) ;
1242 static double rdod_r[14][3] = {
1244 { 0.707106781187, 0.000000000000, 0.5 },
1245 { 0.000000000000, 0.707106781187, 0.5 },
1246 { -0.707106781187, 0.000000000000, 0.5 },
1247 { 0.000000000000, -0.707106781187, 0.5 },
1248 { 0.707106781187, 0.707106781187, 0.0 },
1249 { -0.707106781187, 0.707106781187, 0.0 },
1250 { -0.707106781187, -0.707106781187, 0.0 },
1251 { 0.707106781187, -0.707106781187, 0.0 },
1252 { 0.707106781187, 0.000000000000, -0.5 },
1253 { 0.000000000000, 0.707106781187, -0.5 },
1254 { -0.707106781187, 0.000000000000, -0.5 },
1255 { 0.000000000000, -0.707106781187, -0.5 },
1259 static int rdod_v [12][4] = {
1274 static double rdod_n[12][3] = {
1275 { 0.353553390594, 0.353553390594, 0.5 },
1276 { -0.353553390594, 0.353553390594, 0.5 },
1277 { -0.353553390594, -0.353553390594, 0.5 },
1278 { 0.353553390594, -0.353553390594, 0.5 },
1279 { 0.000000000000, 1.000000000000, 0.0 },
1280 { -1.000000000000, 0.000000000000, 0.0 },
1281 { 0.000000000000, -1.000000000000, 0.0 },
1282 { 1.000000000000, 0.000000000000, 0.0 },
1283 { 0.353553390594, 0.353553390594, -0.5 },
1284 { -0.353553390594, 0.353553390594, -0.5 },
1285 { -0.353553390594, -0.353553390594, -0.5 },
1286 { 0.353553390594, -0.353553390594, -0.5 }
1289 void FGAPIENTRY glutWireRhombicDodecahedron( void )
1293 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireRhombicDodecahedron" );
1295 for ( i = 0; i < 12; i++ )
1297 glBegin ( GL_LINE_LOOP ) ;
1298 glNormal3dv ( rdod_n[i] ) ;
1299 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1300 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1301 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1302 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1310 void FGAPIENTRY glutSolidRhombicDodecahedron( void )
1314 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidRhombicDodecahedron" );
1316 glBegin ( GL_QUADS ) ;
1317 for ( i = 0; i < 12; i++ )
1319 glNormal3dv ( rdod_n[i] ) ;
1320 glVertex3dv ( rdod_r[rdod_v[i][0]] ) ;
1321 glVertex3dv ( rdod_r[rdod_v[i][1]] ) ;
1322 glVertex3dv ( rdod_r[rdod_v[i][2]] ) ;
1323 glVertex3dv ( rdod_r[rdod_v[i][3]] ) ;
1331 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
1333 * Draws a wireframed cube.
1335 void FGAPIENTRY glutWireCube( GLdouble dSize )
1337 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCube" );
1338 fghCube( dSize, TRUE );
1340 void FGAPIENTRY glutSolidCube( GLdouble dSize )
1342 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube" );
1343 fghCube( dSize, FALSE );
1346 void FGAPIENTRY glutWireOctahedron( void )
1348 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireOctahedron" );
1349 fghOctahedron( TRUE );
1351 void FGAPIENTRY glutSolidOctahedron( void )
1353 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidOctahedron" );
1354 fghOctahedron( FALSE );
1357 void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1359 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSierpinskiSponge" );
1360 fghSierpinskiSponge ( num_levels, offset, scale, TRUE );
1362 void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], GLdouble scale )
1364 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSierpinskiSponge" );
1365 fghSierpinskiSponge ( num_levels, offset, scale, FALSE );
1368 void FGAPIENTRY glutWireTetrahedron( void )
1370 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTetrahedron" );
1371 fghTetrahedron( TRUE );
1373 void FGAPIENTRY glutSolidTetrahedron( void )
1375 FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTetrahedron" );
1376 fghTetrahedron( FALSE );
1380 /*** END OF FILE ***/