diff options
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r-- | src/main/engine/engine.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index 36bb352..fb0875a 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -43,9 +43,6 @@ init_log(void) _log = log_create("Engine"); } -static int width; -static int height; - typedef struct Line { float x1, y1, x2, y2; } Line; @@ -78,12 +75,10 @@ engine_new(int w, int h) } engine->circles = list_create(); engine->lines = list_create(); - engine_set_rendering_background(engine, 0.0f, 0.0f, 0.2f, 1.0f); - - width = w; - height = h; engine->ui = ui_init(w, h); + engine_set_rendering_background(engine, 0.0f, 0.0f, 0.2f, 1.0f); + return engine; } @@ -257,14 +252,14 @@ engine_loop(void) start = time(NULL); frames = 0; - ui_loop(); + ui_loop(engine->ui); } void mouse_button_press_event(UIMouseButtonPressed *mbp) { - float oglX = engine->ortho_left + ((float) mbp->x / width) * (engine->ortho_right - engine->ortho_left); - float oglY = engine->ortho_top - ((float) mbp->y / height) * (engine->ortho_top - engine->ortho_bottom); + float oglX = engine->ortho_left + ((float) mbp->x / engine->ui->width) * (engine->ortho_right - engine->ortho_left); + float oglY = engine->ortho_top - ((float) mbp->y / engine->ui->height) * (engine->ortho_top - engine->ortho_bottom); mouse_button_event->on_mouse_button_pressed(oglX, oglY, mouse_button_event->data); } |