diff options
Diffstat (limited to 'balls.c')
| -rw-r--r-- | balls.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -24,6 +24,7 @@ #define VMAX_INIT 0.1 /* Maximum initial velocity. */ enum { WIDTH = 640, HEIGHT = 480 }; +enum { KEY_QUIT = 'q' }; enum { NBALLS = 8, CIRCLE_POINTS = 16+2, /* +2 for center point and last point which overlaps with first point. */ @@ -40,6 +41,7 @@ void configureSharedData(void); void setKernelArgs(void); void display(void); void reshape(int w, int h); +void keyboard(unsigned char key, int x, int y); void move(void); void collideWalls(void); void genVertices(void); @@ -71,6 +73,7 @@ main(int argc, char *argv[]) { glutDisplayFunc(display); glutReshapeFunc(reshape); + glutKeyboardFunc(keyboard); glutMainLoop(); @@ -306,6 +309,12 @@ reshape(int w, int h) { } void +keyboard(unsigned char key, int x, int y) { + if (key == KEY_QUIT) + glutDestroyWindow(glutGetWindow()); +} + +void move(void) { size_t size; int err; |