summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2010-10-03 23:53:09 -0500
committerKamil Kaminski <kamilkss@gmail.com>2010-10-03 23:53:09 -0500
commit31b833b52d2d0047596a1d55cdd86e3427a36a6e (patch)
treeec1b024673685504b9187e82d50feddc51535360
parent264bcddb08ca2e35ad7f692aac84dab57ed29a45 (diff)
downloadGLPyramid-31b833b52d2d0047596a1d55cdd86e3427a36a6e.tar.gz
GLPyramid-31b833b52d2d0047596a1d55cdd86e3427a36a6e.tar.bz2
GLPyramid-31b833b52d2d0047596a1d55cdd86e3427a36a6e.zip
pyramid: fix escape
-rw-r--r--sdl/pyramid.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 0f4dd92..a8cb41b 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -9,6 +9,9 @@
#include <sys/time.h>
#define FRAMES_PER_SECOND 300
+/* global */
+int program_running = 1;
+
static GLfloat xRot = 0.0f;
static GLfloat yRot = 0.0f;
@@ -92,7 +95,7 @@ static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag)
{
switch (keysym->sym)
{
- case SDLK_ESCAPE: exit(0); break;
+ case SDLK_ESCAPE: program_running = 0; break;
case SDLK_w: xRot -= 1.0f; break;
case SDLK_s: xRot += 1.0f; break;
case SDLK_a: yRot -= 1.0f; break;
@@ -144,7 +147,7 @@ void processEvents()
break;
}
case SDL_VIDEORESIZE: { resize(event.resize.w, event.resize.h); break; }
- case SDL_QUIT: { printf("status: exiting...\n"); exit(0); break; }
+ case SDL_QUIT: { program_running = 0; break; }
default: break;
}
}
@@ -318,7 +321,7 @@ int main(int argc, char **argv)
#endif
struct timeval m_LastCount;
struct timeval lcurrent;
- for (;;)
+ while (program_running)
{
gettimeofday(&m_LastCount, 0);
#ifdef STAT_FPS
@@ -345,6 +348,7 @@ int main(int argc, char **argv)
SDL_WM_SetCaption(buffer, NULL);
#endif
}
+ puts("bye!");
return 0;
}