diff src/utils.h @ 30:f945bcc3571f

refactor
author Dennis C. M. <dennis@denniscm.com>
date Thu, 29 Jun 2023 17:48:36 +0100
parents dae463bbf5ca
children 61104b22a25d
line wrap: on
line diff
--- a/src/utils.h	Wed Jun 28 20:10:55 2023 +0100
+++ b/src/utils.h	Thu Jun 29 17:48:36 2023 +0100
@@ -6,6 +6,11 @@
 #include <time.h>
 #include <stdbool.h>
 #include <unistd.h>
+#include <GL/glut.h>
+#include <pthread.h>
+#include <ft2build.h>
+#include <signal.h>
+#include FT_FREETYPE_H
 
 
 struct Element {
@@ -18,12 +23,31 @@
 	void *(*function)(void *);
 };
 
+struct AlgoArgs {
+	struct Element *arr;
+	int arr_size;
+	int comparisons;
+	bool pause;
+	bool sequentially;
+	useconds_t delay;
+};
+
+
+struct ThreadState {
+	bool running;
+	pthread_t thread;
+};
+
 void create_array(struct Element *arr, int arr_size, int window_height, int vpadding);
 void swap_elements(int x, int y, struct Element *arr);
 void randomize_array(struct Element *arr, int arr_size);
 bool array_sorted(struct Element *arr, int arr_size);
-void algorithm_selector(struct Algo *algos, int direction, int *selected_algorithm);
-void delay_flow(useconds_t *delay, bool *pause);
+void algorithm_selector(struct Algo *algos, int algos_size, int direction, int *selected_algo);
+void change_speed(struct AlgoArgs *algo_args, int change);
+void control_flow(useconds_t delay, bool sequentially, bool *pause);
+void reset_state(struct AlgoArgs *algo_args, struct ThreadState *thread_state);
+void run(struct AlgoArgs *algo_args, struct Algo *algos, int selected_algo, 
+		struct ThreadState *thread_state);
 
 
-#endif // UTILS_H
+#endif // UTILS_H