summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/main.c6
-rw-r--r--src/main/ui/ui.h3
-rw-r--r--src/main/ui/x11/ui.c12
3 files changed, 18 insertions, 3 deletions
diff --git a/src/main/main.c b/src/main/main.c
index 5ac3698..20a2a72 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -18,15 +18,21 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include "ui/ui.h"
#include "engine/engine.h"
#define WIDTH 640
#define HEIGHT 480
+void draw_frame() {
+}
+
int main(void) {
engine_init(WIDTH, HEIGHT);
ui_set_title("Tris Game");
+ ui_set_loop_listener(draw_frame);
+ ui_loop();
return EXIT_SUCCESS;
}
diff --git a/src/main/ui/ui.h b/src/main/ui/ui.h
index 90d8c80..86521aa 100644
--- a/src/main/ui/ui.h
+++ b/src/main/ui/ui.h
@@ -21,7 +21,8 @@
#define __UI_H__
void ui_init(int w, int h);
-void ui_loop(void (*draw_frame)(void));
+void ui_loop(void);
void ui_set_title(const char *title);
+void ui_set_loop_listener(void (*loop_event)());
#endif /* __UI_H__ */
diff --git a/src/main/ui/x11/ui.c b/src/main/ui/x11/ui.c
index 6e5b2f4..1c04fd4 100644
--- a/src/main/ui/x11/ui.c
+++ b/src/main/ui/x11/ui.c
@@ -31,6 +31,8 @@ static Window window;
static GLXContext gl_context;
static int close_window = 0;
+void (*on_loop_event)();
+
void cleanup(void);
static Display *
@@ -126,7 +128,13 @@ ui_on_keypress(XEvent event)
}
void
-ui_loop(void (*draw_frame)())
+ui_set_loop_listener(void (*loop_event)())
+{
+ on_loop_event = loop_event;
+}
+
+void
+ui_loop(void)
{
XEvent event;
while (!close_window) {
@@ -137,7 +145,7 @@ ui_loop(void (*draw_frame)())
ui_on_keypress(event);
}
- draw_frame();
+ on_loop_event();
glXSwapBuffers(display, window);
}