summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application.cpp22
-rw-r--r--application.h11
2 files changed, 29 insertions, 4 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;
+ }
+}
diff --git a/application.h b/application.h
index 5d821f9..5befce1 100644
--- a/application.h
+++ b/application.h
@@ -10,19 +10,24 @@
class Application {
private:
ARParam cparam;
-
ARGL_CONTEXT_SETTINGS_REF argl_ctx;
-
SDL_Surface *surface;
-
+
int count;
+ bool please_quit;
+
public:
Pattern* patt;
Application();
~Application();
void run();
+ void quit();
+
+ protected:
+ virtual void event_keypress(SDLKey key);
+
void main_loop(void);
};