aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Versace <chad@kiwitree.net>2018-09-19 21:37:23 -0700
committerChad Versace <chad@kiwitree.net>2018-09-19 21:55:32 -0700
commit5acb35794f8fb42ec8528c5b83bbbd51f38c9405 (patch)
tree365a72642674bfacdb0ccf9f10ec755b085ab49f
parent90bf7282ab427e672c2e23f172d1e5d0cf2c0703 (diff)
downloadopengl-rutabagas-5acb35794f8fb42ec8528c5b83bbbd51f38c9405.zip
opengl-rutabagas-5acb35794f8fb42ec8528c5b83bbbd51f38c9405.tar.xz
util: Allow event hooks to start/stop drawing
-rw-r--r--util.c13
-rw-r--r--util.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/util.c b/util.c
index 21b5ed0..3c32245 100644
--- a/util.c
+++ b/util.c
@@ -270,6 +270,15 @@ ru_engine_main_loop(ru_engine_t *engine) {
need_resize = false;
}
+ switch (engine->draw_mode) {
+ case RU_DRAW_MODE_CONTINUOUS:
+ case RU_DRAW_MODE_ONCE:
+ need_draw = true;
+ break;
+ case RU_DRAW_MODE_PAUSED:
+ break;
+ }
+
if (exposed && need_draw) {
engine->draw(engine);
SDL_GL_SwapWindow(engine->window);
@@ -279,6 +288,10 @@ ru_engine_main_loop(ru_engine_t *engine) {
case RU_DRAW_MODE_CONTINUOUS:
break;
case RU_DRAW_MODE_ONCE:
+ engine->draw_mode = RU_DRAW_MODE_PAUSED;
+ need_draw = false;
+ break;
+ case RU_DRAW_MODE_PAUSED:
need_draw = false;
break;
}
diff --git a/util.h b/util.h
index 21bd9a9..9869140 100644
--- a/util.h
+++ b/util.h
@@ -58,6 +58,7 @@ typedef struct ru_engine ru_engine_t;
enum ru_draw_mode {
RU_DRAW_MODE_CONTINUOUS,
RU_DRAW_MODE_ONCE,
+ RU_DRAW_MODE_PAUSED,
};
struct ru_engine {