X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2Fshapes%2Fshapes.c;h=0c0667e65c175a78b35d0355ee466a4c87da2fff;hb=68d6a5e545bc17173f8d43e0e5eaf4eb5f93bf5c;hp=4928260e884cc6ce5d469f6e452ada3d23f1a0de;hpb=32ee0c1e2137eee3f3879c7a246efd0558be71ee;p=freeglut
diff --git a/progs/demos/shapes/shapes.c b/progs/demos/shapes/shapes.c
index 4928260..0c0667e 100644
--- a/progs/demos/shapes/shapes.c
+++ b/progs/demos/shapes/shapes.c
@@ -12,6 +12,7 @@
Keys:
- Esc Quit
- q Q Quit
+ - i I Show info
- = + Increase \a slices
- - _ Decreate \a slices
- , < Decreate \a stacks
@@ -41,7 +42,8 @@
#include
#ifdef WIN32
-#include // DUMP MEMORY LEAKS
+/* DUMP MEMORY LEAKS */
+#include
#endif
/*
@@ -61,7 +63,7 @@ static double irad = .25;
static double orad = 1.0;
static int depth = 4;
static double offset[ 3 ] = { 0, 0, 0 };
-
+static GLboolean show_info = GL_TRUE;
/*
* These one-liners draw particular objects, fetching appropriate
@@ -92,9 +94,11 @@ static void drawSolidCone(void) { glutSolidCone(1,1,slices,stacks
static void drawWireCone(void) { glutWireCone(1,1,slices,stacks); }
static void drawSolidCylinder(void) { glutSolidCylinder(1,1,slices,stacks); }
static void drawWireCylinder(void) { glutWireCylinder(1,1,slices,stacks); }
+
+#define RADIUS 1.0f
+
static void drawSolidCuboctahedron(void)
{
-#define RADIUS 1.0f
glBegin( GL_TRIANGLES );
glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0, RADIUS, RADIUS ); glVertex3d( RADIUS, 0.0, RADIUS );
glNormal3d( 0.577350269189, 0.577350269189,-0.577350269189); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( RADIUS, 0.0,-RADIUS ); glVertex3d( 0.0, RADIUS,-RADIUS );
@@ -110,16 +114,36 @@ static void drawSolidCuboctahedron(void)
glNormal3d( 1.0, 0.0, 0.0 ); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( RADIUS, 0.0, RADIUS ); glVertex3d( RADIUS,-RADIUS, 0.0 ); glVertex3d( RADIUS, 0.0,-RADIUS );
glNormal3d(-1.0, 0.0, 0.0 ); glVertex3d(-RADIUS, RADIUS, 0.0 ); glVertex3d(-RADIUS, 0.0,-RADIUS ); glVertex3d(-RADIUS,-RADIUS, 0.0 ); glVertex3d(-RADIUS, 0.0, RADIUS );
glNormal3d( 0.0, 1.0, 0.0 ); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0, RADIUS,-RADIUS ); glVertex3d(-RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0, RADIUS, RADIUS );
- glNormal3d( 0.0,-1.0, 0.0 ); glVertex3d(-RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS, RADIUS ); glVertex3d(-RADIUS,-RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS,-RADIUS );
+ glNormal3d( 0.0,-1.0, 0.0 ); glVertex3d( RADIUS,-RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS, RADIUS ); glVertex3d(-RADIUS,-RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS,-RADIUS );
glNormal3d( 0.0, 0.0, 1.0 ); glVertex3d( RADIUS, 0.0, RADIUS ); glVertex3d( 0.0, RADIUS, RADIUS ); glVertex3d(-RADIUS, 0.0, RADIUS ); glVertex3d( 0.0,-RADIUS, RADIUS );
glNormal3d( 0.0, 0.0,-1.0 ); glVertex3d( RADIUS, 0.0,-RADIUS ); glVertex3d( 0.0,-RADIUS,-RADIUS ); glVertex3d(-RADIUS, 0.0,-RADIUS ); glVertex3d( 0.0, RADIUS,-RADIUS );
glEnd();
-#undef RADIUS
}
+
static void drawWireCuboctahedron(void)
{
+ glBegin( GL_LINE_LOOP );
+ glNormal3d( 1.0, 0.0, 0.0 ); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( RADIUS, 0.0, RADIUS ); glVertex3d( RADIUS,-RADIUS, 0.0 ); glVertex3d( RADIUS, 0.0,-RADIUS );
+ glEnd();
+ glBegin( GL_LINE_LOOP );
+ glNormal3d(-1.0, 0.0, 0.0 ); glVertex3d(-RADIUS, RADIUS, 0.0 ); glVertex3d(-RADIUS, 0.0,-RADIUS ); glVertex3d(-RADIUS,-RADIUS, 0.0 ); glVertex3d(-RADIUS, 0.0, RADIUS );
+ glEnd();
+ glBegin( GL_LINE_LOOP );
+ glNormal3d( 0.0, 1.0, 0.0 ); glVertex3d( RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0, RADIUS,-RADIUS ); glVertex3d(-RADIUS, RADIUS, 0.0 ); glVertex3d( 0.0, RADIUS, RADIUS );
+ glEnd();
+ glBegin( GL_LINE_LOOP );
+ glNormal3d( 0.0,-1.0, 0.0 ); glVertex3d( RADIUS,-RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS, RADIUS ); glVertex3d(-RADIUS,-RADIUS, 0.0 ); glVertex3d( 0.0,-RADIUS,-RADIUS );
+ glEnd();
+ glBegin( GL_LINE_LOOP );
+ glNormal3d( 0.0, 0.0, 1.0 ); glVertex3d( RADIUS, 0.0, RADIUS ); glVertex3d( 0.0, RADIUS, RADIUS ); glVertex3d(-RADIUS, 0.0, RADIUS ); glVertex3d( 0.0,-RADIUS, RADIUS );
+ glEnd();
+ glBegin( GL_LINE_LOOP );
+ glNormal3d( 0.0, 0.0,-1.0 ); glVertex3d( RADIUS, 0.0,-RADIUS ); glVertex3d( 0.0,-RADIUS,-RADIUS ); glVertex3d(-RADIUS, 0.0,-RADIUS ); glVertex3d( 0.0, RADIUS,-RADIUS );
+ glEnd();
}
+#undef RADIUS
+
/*
* This structure defines an entry in our function-table.
*/
@@ -193,7 +217,7 @@ static void shapesPrintf (int row, int col, const char *fmt, ...)
glutBitmapWidth(font, ' ') * col,
- glutBitmapHeight(font) * (row+2) + viewport[3]
);
- glutBitmapString (font, buf);
+ glutBitmapString (font, (unsigned char*)buf);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
@@ -226,8 +250,6 @@ static void display(void)
glEnable(GL_LIGHTING);
- printf ( "Shape %d slides %d stacks %d\n", function_index, slices, stacks ) ;
-
glColor3d(1,0,0);
glPushMatrix();
@@ -247,13 +269,17 @@ static void display(void)
glDisable(GL_LIGHTING);
glColor3d(0.1,0.1,0.4);
-/* shapesPrintf (1, 3, "Shape PgUp PgDn: %s", table [function_index].name);
- shapesPrintf (2, 3, " Slices +-: %d Stacks <>: %d", slices, stacks);
- shapesPrintf (3, 3, " nSides +-: %d nRings <>: %d", slices, stacks);
- shapesPrintf (4, 3, " Depth (): %d", depth);
- shapesPrintf (5, 3, " Outer radius Up Down : %f", orad);
- shapesPrintf (6, 3, " Inner radius Left Right: %f", irad);
-*/
+ if( show_info ) {
+ shapesPrintf (1, 3, "Shape PgUp PgDn: %s", table [function_index].name);
+ shapesPrintf (2, 3, "Slices +-: %d Stacks <>: %d", slices, stacks);
+ shapesPrintf (3, 3, "nSides +-: %d nRings <>: %d", slices, stacks);
+ shapesPrintf (4, 3, "Depth (): %d", depth);
+ shapesPrintf (5, 3, "Outer radius Up Down : %f", orad);
+ shapesPrintf (6, 3, "Inner radius Left Right: %f", irad);
+ } else {
+ printf ( "Shape %d slides %d stacks %d\n", function_index, slices, stacks ) ;
+ }
+
glutSwapBuffers();
}
@@ -267,6 +293,9 @@ key(unsigned char key, int x, int y)
case 'Q':
case 'q': glutLeaveMainLoop () ; break;
+ case 'I':
+ case 'i': show_info = ( show_info == GL_TRUE ) ? GL_FALSE : GL_TRUE; break;
+
case '=':
case '+': slices++; break;
@@ -376,7 +405,8 @@ main(int argc, char *argv[])
glutMainLoop();
#ifdef WIN32
- _CrtDumpMemoryLeaks () ; // DUMP MEMORY LEAK INFORMATION
+ /* DUMP MEMORY LEAK INFORMATION */
+ _CrtDumpMemoryLeaks () ;
#endif
return EXIT_SUCCESS;