Mercurial > public > algo-animator
annotate README.md @ 27:30b6812fefdd
add cmake config
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 28 Jun 2023 08:58:44 +0100 |
parents | 2945f5898960 |
children | 99592fae8ea1 |
rev | line source |
---|---|
4
035d3880da04
render text with number of elements on screen
Dennis C. M. <dennis@denniscm.com>
parents:
diff
changeset
|
1 # algo-animator |
035d3880da04
render text with number of elements on screen
Dennis C. M. <dennis@denniscm.com>
parents:
diff
changeset
|
2 |
21 | 3 This project is inspired by - off course - the video by Timo Bingmann called [15 sorting algorithms in 6 minutes](https://www.youtube.com/watch?v=kPRA0W1kECg). |
4 | |
24 | 5  |
26 | 6  |
24 | 7 |
21 | 8 ## Compile |
9 | |
4
035d3880da04
render text with number of elements on screen
Dennis C. M. <dennis@denniscm.com>
parents:
diff
changeset
|
10 ```bash |
13
074bde2db09a
printing text with custom font but incorrect letters
Dennis C. M. <dennis@denniscm.com>
parents:
4
diff
changeset
|
11 gcc main.c -lglut -lGL -lGLU -lm -I/usr/local/include/freetype2 -L/usr/local/lib -lfreetype |
4
035d3880da04
render text with number of elements on screen
Dennis C. M. <dennis@denniscm.com>
parents:
diff
changeset
|
12 ``` |
21 | 13 |
14 ## To improve | |
15 | |
16 Since `GLUT` is single-thread, I cannot call `glutPostRedisplay()` within `while` or `for loops` to redraw the screen in every | |
17 step of the selected sorting algorithm. I guess the solution is multi-threading, so I can perform the sorting in the second thread | |
18 and post notifications to the main thread to redraw the screen. | |
19 | |
20 Since this is my first OpenGL project and just my second program in C, I am tired and I don't want to spend more time in this project, | |
21 but maybe in the future I'll do it. Right now there are just two algorithms supported. I've implemented them in a way that every function | |
22 call is a single step of the sorting. So, storing the "state" outside the function, I can use `idle()` as the loop of the sorting algorithm. | |
23 | |
24 Let's say we selected `bubble sort`. Once you press `ENTER`, the process will be like this: | |
25 | |
26 ```c | |
27 run = true; | |
28 bubble_sort(); | |
29 glutPostRedisplay; | |
30 bubble_sort(); | |
31 glutPostRedisplay; | |
32 bubble_sort(); | |
33 glutPostRedisplay; | |
34 | |
35 // Continue until the array is sorted | |
36 run = false; | |
37 ``` |