X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_geometry.c;fp=freeglut-1.3%2Ffreeglut_geometry.c;h=f1b1dda11fa07c0a01fe11f4ab87a13eee5019ee;hb=5045a0816bfc941f2a556e8d8af03534754843db;hp=ed25bf1308b135da9e91f81a1416a3bbc42f20cf;hpb=a82e219413778d1fd55d270af98e9ad6a97e25a0;p=freeglut diff --git a/freeglut-1.3/freeglut_geometry.c b/freeglut-1.3/freeglut_geometry.c index ed25bf1..f1b1dda 100644 --- a/freeglut-1.3/freeglut_geometry.c +++ b/freeglut-1.3/freeglut_geometry.c @@ -37,32 +37,30 @@ /* * TODO BEFORE THE STABLE RELEASE: * - * Following functions have been contributed by Andreas Umbach. I modified - * them a bit to make them use GLib (for memory allocation). + * Following functions have been contributed by Andreas Umbach. * - * glutWireCube() -- could add normal vectors so that lighting works + * glutWireCube() -- looks OK * glutSolidCube() -- OK * glutWireSphere() -- OK * glutSolidSphere() -- OK * - * Following functions have been implemented by me: + * Following functions have been implemented by Pawel and modified by John Fay: * * glutWireCone() -- looks OK - * glutSolidCone() -- normals are missing, there are holes in the thing + * glutSolidCone() -- looks OK * - * Those functions need to be implemented, as nothing has been done yet. - * For now all of them draw a wire or solid cube, just to mark their presence. + * Those functions have been implemented by John Fay. * - * glutWireTorus() -- - * glutSolidTorus() -- - * glutWireDodecahedron() -- - * glutSolidDodecahedron() -- - * glutWireOctahedron() -- - * glutSolidOctahedron() -- - * glutWireTetrahedron() -- - * glutSolidTetrahedron() -- - * glutWireIcosahedron() -- - * glutSolidIcosahedron() -- + * glutWireTorus() -- looks OK + * glutSolidTorus() -- looks OK + * glutWireDodecahedron() -- looks OK + * glutSolidDodecahedron() -- looks OK + * glutWireOctahedron() -- looks OK + * glutSolidOctahedron() -- looks OK + * glutWireTetrahedron() -- looks OK + * glutSolidTetrahedron() -- looks OK + * glutWireIcosahedron() -- looks OK + * glutSolidIcosahedron() -- looks OK */ @@ -76,18 +74,20 @@ void FGAPIENTRY glutWireCube( GLdouble dSize ) float size = (float) dSize * 0.5f; # define V(a,b,c) glVertex3f( a size, b size, c size ); +# define N(a,b,c) glNormal3f( a, b, c ); /* * PWO: I dared to convert the code to use macros... */ - glBegin( GL_LINE_LOOP ); V(-,-,+); V(+,-,+); V(+,+,+); V(-,+,+); glEnd(); - glBegin( GL_LINE_LOOP ); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-); glEnd(); - glBegin( GL_LINES ); - V(-,-,+); V(-,-,-); V(-,+,+); V(-,+,-); - V(+,-,+); V(+,-,-); V(+,+,+); V(+,+,-); - glEnd(); + 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(); + 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(); # undef V +# undef N } /* @@ -104,12 +104,12 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize ) * PWO: Again, I dared to convert the code to use macros... */ glBegin( GL_QUADS ); - N( 1, 0, 0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); - N( 0, 1, 0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); - N( 0, 0, 1); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+); - N(-1, 0, 0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-); - N( 0,-1, 0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+); - N( 0, 0,-1); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-); + N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+); + N( 0.0, 1.0, 0.0); V(+,+,+); V(+,+,-); V(-,+,-); V(-,+,+); + N( 0.0, 0.0, 1.0); V(+,+,+); V(-,+,+); V(-,-,+); V(+,-,+); + N(-1.0, 0.0, 0.0); V(-,-,+); V(-,+,+); V(-,+,-); V(-,-,-); + N( 0.0,-1.0, 0.0); V(-,-,+); V(-,-,-); V(+,-,-); V(+,-,+); + N( 0.0, 0.0,-1.0); V(-,-,-); V(-,+,-); V(+,+,-); V(+,-,-); glEnd(); # undef V @@ -124,6 +124,7 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks ) float radius = (float) dRadius, phi, psi, dpsi, dphi; float* vertex; int i, j; + float cphi, sphi, cpsi, spsi ; /* * Allocate the vertices array @@ -139,15 +140,19 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks ) for( j=0; j