summaryrefslogtreecommitdiffstats
path: root/balls.c
diff options
context:
space:
mode:
Diffstat (limited to 'balls.c')
-rw-r--r--balls.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/balls.c b/balls.c
index 7594eb7..48fc430 100644
--- a/balls.c
+++ b/balls.c
@@ -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;