X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_geometry.c;h=3e4fd3c0fda881f42693374048239601aea70c5f;hb=006650e1dd72e73249d41e2bcea8b1668262a999;hp=b81a05ff6b7dadbf0f80d9f7e50c9f51bbb9af01;hpb=65e03872c287ab34ae76bd1831a3786d5e986b72;p=freeglut diff --git a/src/freeglut_geometry.c b/src/freeglut_geometry.c index b81a05f..3e4fd3c 100644 --- a/src/freeglut_geometry.c +++ b/src/freeglut_geometry.c @@ -75,9 +75,7 @@ void FGAPIENTRY glutWireCube( GLdouble dSize ) # define V(a,b,c) glVertex3d( a size, b size, c size ); # define N(a,b,c) glNormal3d( a, b, c ); - /* - * PWO: I dared to convert the code to use macros... - */ + /* PWO: I dared to convert the code to use macros... */ glBegin( GL_LINE_LOOP ); N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); glEnd(); glBegin( GL_LINE_LOOP ); N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); glEnd(); glBegin( GL_LINE_LOOP ); N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+); glEnd(); @@ -99,9 +97,7 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize ) # define V(a,b,c) glVertex3d( a size, b size, c size ); # define N(a,b,c) glNormal3d( a, b, c ); - /* - * PWO: Again, I dared to convert the code to use macros... - */ + /* PWO: Again, I dared to convert the code to use macros... */ glBegin( GL_QUADS ); N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); @@ -125,7 +121,7 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize ) * The sign of n can be flipped to get the reverse loop */ -static void circleTable(double **sint,double **cost,const int n) +static void fghCircleTable(double **sint,double **cost,const int n) { int i; @@ -148,7 +144,7 @@ static void circleTable(double **sint,double **cost,const int n) { free(*sint); free(*cost); - fgError("Failed to allocate memory in circleTable"); + fgError("Failed to allocate memory in fghCircleTable"); } /* Compute cos and sin around the circle */ @@ -181,8 +177,8 @@ void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) double *sint1,*cost1; double *sint2,*cost2; - circleTable(&sint1,&cost1,-slices); - circleTable(&sint2,&cost2,stacks*2); + fghCircleTable(&sint1,&cost1,-slices); + fghCircleTable(&sint2,&cost2,stacks*2); /* The top stack is covered with a triangle fan */ @@ -197,7 +193,7 @@ void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) glVertex3d(0,0,radius); for (j=slices; j>=0; j--) - { + { glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 ); glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius); } @@ -263,11 +259,11 @@ void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks) double x,y,z; /* Pre-computed circle */ - + double *sint1,*cost1; double *sint2,*cost2; - circleTable(&sint1,&cost1,-slices ); - circleTable(&sint2,&cost2, stacks*2); + fghCircleTable(&sint1,&cost1,-slices ); + fghCircleTable(&sint2,&cost2, stacks*2); /* Draw a line loop for each stack */ @@ -340,7 +336,7 @@ void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLi /* Pre-computed circle */ double *sint,*cost; - circleTable(&sint,&cost,-slices); + fghCircleTable(&sint,&cost,-slices); /* Cover the circular base with a triangle fan... */ @@ -424,7 +420,7 @@ void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLin /* Pre-computed circle */ double *sint,*cost; - circleTable(&sint,&cost,-slices); + fghCircleTable(&sint,&cost,-slices); /* Draw the stacks... */ @@ -481,7 +477,7 @@ void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices /* Pre-computed circle */ double *sint,*cost; - circleTable(&sint,&cost,-slices); + fghCircleTable(&sint,&cost,-slices); /* Cover the base and top */ @@ -542,7 +538,7 @@ void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, /* Pre-computed circle */ double *sint,*cost; - circleTable(&sint,&cost,-slices); + fghCircleTable(&sint,&cost,-slices); /* Draw the stacks... */ @@ -593,9 +589,7 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi int i, j; double spsi, cpsi, sphi, cphi ; - /* - * Allocate the vertices array - */ + /* Allocate the vertices array */ vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings ); normal = (double *)calloc( sizeof(double), 3 * nSides * nRings ); @@ -671,15 +665,11 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL int i, j; double spsi, cpsi, sphi, cphi ; - /* - * Increment the number of sides and rings to allow for one more point than surface - */ + /* Increment the number of sides and rings to allow for one more point than surface */ nSides ++ ; nRings ++ ; - /* - * Allocate the vertices array - */ + /* Allocate the vertices array */ vertex = (double *)calloc( sizeof(double), 3 * nSides * nRings ); normal = (double *)calloc( sizeof(double), 3 * nSides * nRings ); @@ -744,7 +734,8 @@ void FGAPIENTRY glutWireDodecahedron( void ) /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of * of a cube. The coordinates of the points are: * (+-x,0, z); (+-1, 1, 1); (0, z, x ) - * where x = 0.61803398875 and z = 1.61803398875. + * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or + * x = 0.61803398875 and z = 1.61803398875. */ glBegin ( GL_LINE_LOOP ) ; 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 ) ; @@ -794,7 +785,8 @@ void FGAPIENTRY glutSolidDodecahedron( void ) /* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of * of a cube. The coordinates of the points are: * (+-x,0, z); (+-1, 1, 1); (0, z, x ) - * where x = 0.61803398875 and z = 1.61803398875. + * where x = (-1 + sqrt(5))/2, z = (1 + sqrt(5))/2 or + * x = 0.61803398875 and z = 1.61803398875. */ glBegin ( GL_POLYGON ) ; 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 ) ;