From 91e1dfa064864f71f2df4c86dba62dd44865260b Mon Sep 17 00:00:00 2001 From: Alejandro Laguna Date: Tue, 14 Jul 2026 18:29:09 +0200 Subject: [PATCH] fix: only calculate points if position has been updated --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 79b5653d52f8253afbb4cd1a3dc0b25ab40a67e3..5e11a1377a527ada21dd10b0166b53b4facba3b7 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,8 @@ int main(void) { position.x_max = 1.0; position.y_min = -1.2; position.y_max = 1.2; + + bool pos_updated = false; while (running) { while (SDL_PollEvent(&e)) { if (e.type == SDL_EVENT_QUIT) { @@ -101,9 +104,13 @@ int main(void) { position.x_max = position.x_min + new_width; position.y_min = ci - (double)my / (WINDOW_HEIGHT - 1) * new_height; position.y_max = position.y_min + new_height; + pos_updated = true; } } - calculate_points(&position); + if (pos_updated) { + calculate_points(&position); + pos_updated = false; + } draw_points(surface); SDL_UpdateWindowSurface(window); SDL_Delay(16);