#include #include #include #include #include #include int gfxsizex = 1000, gfxsizey = 800; int len = 3000, clear = 1, continuous = 1; struct timeval lastt; int count = 0; void draw (void) { int i; static int s = 0; float scale = gfxsizey / 2; fprintf (stderr, "draw s %d\n", s); if (clear) glClear (GL_COLOR_BUFFER_BIT); glBegin (GL_LINE_LOOP); for (i = 0; i < len; i++) { glColor3ub (127 + 128 * ((i+s) & 0x01), 127 + 64 * ((i+s) & 0x02), 127 + 32 * ((i+s) & 0x04)); glVertex3f (scale * (1+ sin (i*2*M_PI/len)), scale * (1+ cos (i*2*M_PI/len)), 0); } glEnd(); glFlush (); glutSwapBuffers (); s = (s+1)%len; if (continuous) glutPostRedisplay (); } void reshape (int width, int height) { fprintf (stderr, "reshape %d %d\n", width, height); gfxsizex = width; gfxsizey = height; glViewport (0, 0, width, height); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0, width, 0, height, 0, 1); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glutPostRedisplay (); } void keyboard (unsigned char key, int x, int y) { exit (0); } int main (int argc, char *argv[]) { int db = 1; glutInitWindowSize (gfxsizex, gfxsizey); glutInit (&argc, argv); if (argc > 1) { len = atoi (argv[1]); if (argc > 2) { if (argv[2][0] == 's') db = 0; if (argc > 3) { if (argv[3][0] == 'c') clear = 1; if (argc > 4) { if (argv[4][0] == 'e') continuous = 0; } } } } else fprintf (stderr, "Usage: %s [ [s|d (buffering) [c|- (clear) [e (run on expose only)]]]\n", argv[0]); fprintf (stderr, "Using %s buffer, lineloop of length %d\n", db ? "double":"single", len); if (db) glutInitDisplayMode (GLUT_RGB|GLUT_DOUBLE); else glutInitDisplayMode (GLUT_RGB); glutCreateWindow (argv[0]); glutReshapeFunc (reshape); glutDisplayFunc (draw); glutKeyboardFunc (keyboard); gettimeofday (&lastt, NULL); glutMainLoop (); exit (0); }