-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (40 loc) · 1.2 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//#include "glad.h"
//#include "GLFW/glfw3.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include "bird.h"
#include "graphics_manager.h"
#include "Vector.h"
#define _USE_MATH_DEFINES
#include <math.h>
#include "Flock.h"
using namespace std;
void print_stats(float avg_loop_time) {
cout << '\r' << "Avg loop time: " << avg_loop_time << flush;
}
int main() {
Graphics_manager *graphics_manager = new(Graphics_manager);
Flock flock = Flock();
Dimension window_dimension = graphics_manager->getDimensions();
uint64_t loop_count = 0;
// Generate all N number of birds and layout them on canvas.
// Layout dimensions will be same as one of the window.
flock.generate(window_dimension);
// Start iterations
clock_t begin_time = clock();
while (graphics_manager->loop())
{
loop_count++;
graphics_manager->draw_birds(flock.birds, flock.number_of_birds);
graphics_manager->swap_buffers();
// Recalculates positions for all birds in the flock.
flock.run();
print_stats(1.0f / (float(clock() - begin_time) / CLOCKS_PER_SEC / loop_count));
}
// Cleanup
delete graphics_manager;
system("pause");
exit(EXIT_SUCCESS);
}