X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_geometry.c;h=b41b5b766bfdc5022915eb57a9f0efbae99e84a5;hb=81414e3bfb81f912cbb88f7f88fee8edacf5e969;hp=3184fa981e9a40575e7bdc9a8074621a69c86350;hpb=3c1e1a5baed46b7efd6b6a499f500651535aa24f;p=freeglut diff --git a/src/freeglut_geometry.c b/src/freeglut_geometry.c index 3184fa9..b41b5b7 100644 --- a/src/freeglut_geometry.c +++ b/src/freeglut_geometry.c @@ -25,10 +25,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include "freeglut_internal.h" @@ -72,6 +68,8 @@ void FGAPIENTRY glutWireCube( GLdouble dSize ) { double size = dSize * 0.5; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCube" ); + # define V(a,b,c) glVertex3d( a size, b size, c size ); # define N(a,b,c) glNormal3d( a, b, c ); @@ -94,6 +92,8 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize ) { double size = dSize * 0.5; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube" ); + # define V(a,b,c) glVertex3d( a size, b size, c size ); # define N(a,b,c) glNormal3d( a, b, c ); @@ -180,6 +180,9 @@ void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks) double *sint1,*cost1; double *sint2,*cost2; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" ); + fghCircleTable(&sint1,&cost1,-slices); fghCircleTable(&sint2,&cost2,stacks*2); @@ -265,6 +268,9 @@ void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks) double *sint1,*cost1; double *sint2,*cost2; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSphere" ); + fghCircleTable(&sint1,&cost1,-slices ); fghCircleTable(&sint2,&cost2, stacks*2); @@ -339,6 +345,9 @@ void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLi /* Pre-computed circle */ double *sint,*cost; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCone" ); + fghCircleTable(&sint,&cost,-slices); /* Cover the circular base with a triangle fan... */ @@ -423,6 +432,9 @@ void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLin /* Pre-computed circle */ double *sint,*cost; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCone" ); + fghCircleTable(&sint,&cost,-slices); /* Draw the stacks... */ @@ -480,6 +492,9 @@ void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices /* Pre-computed circle */ double *sint,*cost; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCylinder" ); + fghCircleTable(&sint,&cost,-slices); /* Cover the base and top */ @@ -541,6 +556,9 @@ void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices, /* Pre-computed circle */ double *sint,*cost; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCylinder" ); + fghCircleTable(&sint,&cost,-slices); /* Draw the stacks... */ @@ -591,6 +609,9 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi double *vertex, *normal; int i, j; double spsi, cpsi, sphi, cphi ; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTorus" ); + if ( nSides < 1 ) nSides = 1; if ( nRings < 1 ) nRings = 1; @@ -669,6 +690,9 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL double *vertex, *normal; int i, j; double spsi, cpsi, sphi, cphi ; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTorus" ); + if ( nSides < 1 ) nSides = 1; if ( nRings < 1 ) nRings = 1; @@ -738,6 +762,8 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL */ void FGAPIENTRY glutWireDodecahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireDodecahedron" ); + /* 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 ) @@ -789,6 +815,8 @@ void FGAPIENTRY glutWireDodecahedron( void ) */ void FGAPIENTRY glutSolidDodecahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidDodecahedron" ); + /* 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 ) @@ -840,6 +868,8 @@ void FGAPIENTRY glutSolidDodecahedron( void ) */ void FGAPIENTRY glutWireOctahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireOctahedron" ); + #define RADIUS 1.0f glBegin( GL_LINE_LOOP ); glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); @@ -859,6 +889,8 @@ void FGAPIENTRY glutWireOctahedron( void ) */ void FGAPIENTRY glutSolidOctahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidOctahedron" ); + #define RADIUS 1.0f glBegin( GL_TRIANGLES ); glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS ); @@ -900,6 +932,8 @@ static GLint tet_i[4][3] = /* Vertex indices */ */ void FGAPIENTRY glutWireTetrahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTetrahedron" ); + glBegin( GL_LINE_LOOP ) ; glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ; glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ; @@ -913,6 +947,8 @@ void FGAPIENTRY glutWireTetrahedron( void ) */ void FGAPIENTRY glutSolidTetrahedron( void ) { + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTetrahedron" ); + glBegin( GL_TRIANGLES ) ; glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ; glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ; @@ -936,6 +972,9 @@ int icos_v [20][3] = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 5 }, { 0, void FGAPIENTRY glutWireIcosahedron( void ) { int i ; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireIcosahedron" ); + for ( i = 0; i < 20; i++ ) { double normal[3] ; @@ -958,6 +997,8 @@ void FGAPIENTRY glutSolidIcosahedron( void ) { int i ; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidIcosahedron" ); + glBegin ( GL_TRIANGLES ) ; for ( i = 0; i < 20; i++ ) { @@ -994,6 +1035,9 @@ double rdod_n[12][3] = { void FGAPIENTRY glutWireRhombicDodecahedron( void ) { int i ; + + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireRhombicDodecahedron" ); + for ( i = 0; i < 12; i++ ) { glBegin ( GL_LINE_LOOP ) ; @@ -1013,6 +1057,8 @@ void FGAPIENTRY glutSolidRhombicDodecahedron( void ) { int i ; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidRhombicDodecahedron" ); + glBegin ( GL_QUADS ) ; for ( i = 0; i < 12; i++ ) { @@ -1030,6 +1076,8 @@ void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], G { int i, j ; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSierpinskiSponge" ); + if ( num_levels == 0 ) { @@ -1048,7 +1096,7 @@ void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], G glEnd () ; } } - else + else if ( num_levels > 0 ) { GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */ num_levels -- ; @@ -1067,6 +1115,8 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], { int i, j ; + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSierpinskiSponge" ); + if ( num_levels == 0 ) { glBegin ( GL_TRIANGLES ) ; @@ -1085,7 +1135,7 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3], glEnd () ; } - else + else if ( num_levels > 0 ) { GLdouble local_offset[3] ; /* Use a local variable to avoid buildup of roundoff errors */ num_levels -- ;