Mercurial > 3de
changeset 7:e681fac7212c
Added a timer, some cleanup
author | jsipek@huey.fsl.cs.sunysb.edu |
---|---|
date | Thu, 24 Nov 2005 02:03:12 -0400 |
parents | b06a7e9cda60 |
children | 640a1d1a730d |
files | .hgignore render.c |
diffstat | 2 files changed, 22 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Nov 24 01:34:26 2005 -0400 +++ b/.hgignore Thu Nov 24 02:03:12 2005 -0400 @@ -1,3 +1,4 @@ \.swp$ ^render$ ^transform$ +^rotate$
--- a/render.c Thu Nov 24 01:34:26 2005 -0400 +++ b/render.c Thu Nov 24 02:03:12 2005 -0400 @@ -13,6 +13,7 @@ #include "GL/glut.h" #define BUF_SIZE 1024 +#define TIMER_PERIOD 10 int infd; int outfd; @@ -73,6 +74,12 @@ display(); } +void timer2(int val) +{ + glutPostRedisplay(); + glutTimerFunc(TIMER_PERIOD, timer2, 0); +} + void display(void) { ssize_t r; @@ -93,18 +100,19 @@ printf("buf = \"%s\"\n", buf); fflush(stdout); - - if (!strncmp(buf, "CLEAR", 5)) { - glClear(GL_COLOR_BUFFER_BIT); - } else if (!strncmp(buf, "FLUSH", 5)) { - glFlush(); - glutSwapBuffers(); - } else if (!strncmp(buf, "POLY", 4)) - draw_poly(buf); - else { - printf("unknown command\n"); - fflush(stdout); - } + +fprintf(stderr,"displaying...%s.\n",buf); + if (!strncmp(buf, "CLEAR", 5)) { + glClear(GL_COLOR_BUFFER_BIT); + } else if (!strncmp(buf, "FLUSH", 5)) { + glFlush(); + glutSwapBuffers(); + } else if (!strncmp(buf, "POLY", 4)) + draw_poly(buf); + else { + printf("unknown command\n"); + fflush(stdout); + } ptr = buf; } @@ -164,6 +172,7 @@ glutDisplayFunc(display); glutKeyboardFunc(key); init(); + glutTimerFunc(TIMER_PERIOD, timer2, 0); glutMainLoop(); close(infd);