diff options
author | 2025-05-22 12:13:31 +0200 | |
---|---|---|
committer | 2025-05-22 12:13:31 +0200 | |
commit | baa50758f6f98822db1e01eec3b8f0fc7577fdf5 (patch) | |
tree | cad361a4eb93f6d3b4714d283e8c47d496896444 /src/main/engine/engine.c | |
parent | d80ab578627dc00837a5e264d4f0164f2263ffa1 (diff) | |
download | tris-baa50758f6f98822db1e01eec3b8f0fc7577fdf5.tar.gz tris-baa50758f6f98822db1e01eec3b8f0fc7577fdf5.zip |
Fix the mouse click on resize window
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); } |