diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-02-26 22:20:25 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-02-26 22:20:25 +0100 |
commit | b353185ff989e2dd058284dc5b1a6d5d6197bcbd (patch) | |
tree | b7251ecbd60297e1b93b5c3febc2beb0592f7171 /application.cpp | |
parent | 9466244a852d6620edf671a89e1a7188248d5482 (diff) |
Handle keypresses through virtual method.
Diffstat (limited to 'application.cpp')
-rw-r--r-- | application.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/application.cpp b/application.cpp index 95027ac..b49bcb9 100644 --- a/application.cpp +++ b/application.cpp @@ -77,6 +77,8 @@ Application::Application() { glShadeModel(GL_SMOOTH); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + please_quit = false; } Application::~Application() { @@ -90,9 +92,15 @@ void Application::run() { while(1) { SDL_Event event; SDL_PollEvent(&event); - if(event.type == SDL_QUIT || event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) { + if(event.type == SDL_QUIT) { break; + } else if(event.type == SDL_KEYDOWN) { + event_keypress(event.key.keysym.sym); } + if(please_quit) { + return; + } + main_loop(); } } @@ -134,3 +142,15 @@ void Application::main_loop(void) { arVideoCapNext(); SDL_GL_SwapBuffers(); } + +void Application::quit() { + please_quit = true; +} + +void Application::event_keypress(SDLKey key) { + switch(key) { + case SDLK_ESCAPE: + quit(); + break; + } +} |