#endif
#include <GL/glut.h>
#include <math.h>
-#include <string.h>
#define Scale 0.3
static int mono=0;
static int smooth=1;
+static int anim=1;
static GLint WindH, WindW;
static GLfloat step=0;
static GLfloat seno;
}
static void draw ( void ) {
- static double t0 = -1.;
- double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
- if (t0 < 0.0)
- t0 = t;
- dt = t - t0;
- t0 = t;
-
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
glutSwapBuffers();
- step += dt;
}
static void idle_( void )
{
+ static double t0 = -1.;
+ double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+ if (t0 < 0.0)
+ t0 = t;
+ dt = t - t0;
+ t0 = t;
+
+ step += dt;
+
glutPostRedisplay();
}
case '4': object=4; break;
case '5': object=5; break;
case ' ': mono^=1; break;
- case 13: smooth^=1; break;
+ case 's': smooth^=1; break;
+ case 'a':
+ anim^=1;
+ if (anim)
+ glutIdleFunc( idle_ );
+ else
+ glutIdleFunc(NULL);
+ break;
case 27:
exit(0);
}
pinit();
+ glutPostRedisplay();
}
static void pinit(void)
}
-static void INIT(void)
+int main(int argc, char **argv)
{
printf("Morph 3D - Shows morphing platonic polyhedra\n");
printf("Author: Marcelo Fernandes Vianna (vianna@cat.cbpf.br)\n\n");
object=1;
+ glutInit(&argc, argv);
glutInitWindowPosition(0,0);
glutInitWindowSize(640,480);
glutIdleFunc( idle_ );
glutDisplayFunc( draw );
glutMainLoop();
-
-}
-int main(int argc, char **argv)
-{
- INIT();
- return(0);
+ return 0;
}