From 73195399de0a6b5de27a838bba2daedc8ff2ae65 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Mon, 19 May 2025 15:57:13 +0200 Subject: Add reference to UI in the Engine structure --- src/main/engine/engine.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/engine/engine.c') diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index 46b34cb..b4d70b0 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -22,6 +22,7 @@ #include #include #include "engine.h" +#include "../util.h" #include "ui/ui.h" #include "../util/list.h" @@ -43,10 +44,11 @@ typedef struct Line { } Line; typedef struct Engine { + UI *ui; void (*draw_frame)(); } Engine; -static Engine engine; +static Engine *engine; /* FPS */ static time_t start; @@ -59,9 +61,15 @@ void (*on_mouse_pressed)(); void engine_init(int w, int h) { + engine = malloc(sizeof(Engine)); + if (engine == NULL) { + log_error("Error allocating memory for engine"); + exit(EXIT_FAILURE); + } + width = w; height = h; - ui_init(w, h); + engine->ui = ui_init(w, h); xstep = RANGE_GL / (float) w; ystep = RANGE_GL / (float) h; -- cgit v1.2.3