45
45
#include " Stats.hpp"
46
46
#endif
47
47
48
- uint GLOBALSEED;
49
-
50
- void init (int &WIDTH, int &HEIGHT, int &SCALE, int &DELAY,
51
- std::array<int , 3 > &BGCOLOR, std::array<int , 3 > &WALLCOLOR,
52
- bool &HEATMAPENABLED, std::vector<Actor> &actors, Room &room,
48
+ void init (int &width, int &height, int &scale, int &delay,
49
+ std::array<int , 3 > &bgColor, std::array<int , 3 > &wallColor,
50
+ bool &heatmapEnabled, std::vector<Actor> &actors, Room &room,
53
51
std::vector<Path> &paths, int argc, char **argv) {
54
52
// Read from input file path JSON
55
53
if (argc == 2 ) {
56
54
std::string inputPath = argv[1 ];
57
- parseInputFile (inputPath, actors, room, paths, WIDTH, HEIGHT, SCALE ,
58
- DELAY, BGCOLOR, WALLCOLOR, HEATMAPENABLED );
55
+ parseInputFile (inputPath, actors, room, paths, width, height, scale ,
56
+ delay, bgColor, wallColor, heatmapEnabled );
59
57
} else if (argc < 2 ) {
60
58
throw std::invalid_argument (
61
59
" Input configuration file must be supplied" );
@@ -73,12 +71,12 @@ void init(int &WIDTH, int &HEIGHT, int &SCALE, int &DELAY,
73
71
}
74
72
75
73
#ifndef PROFILING_MODE
76
- void initSDL (int WIDTH , int HEIGHT , int SCALE , SDL_Window *&win,
74
+ void initSDL (int width , int height , int scale , SDL_Window *&win,
77
75
SDL_Renderer *&render) {
78
76
SDL_Init (SDL_INIT_VIDEO);
79
77
win = SDL_CreateWindow (" SYCL Crowd Simulation" , SDL_WINDOWPOS_UNDEFINED,
80
- SDL_WINDOWPOS_UNDEFINED, WIDTH * SCALE ,
81
- HEIGHT * SCALE , SDL_WINDOW_SHOWN);
78
+ SDL_WINDOWPOS_UNDEFINED, width * scale ,
79
+ height * scale , SDL_WINDOW_SHOWN);
82
80
render = SDL_CreateRenderer (win, -1 , SDL_RENDERER_ACCELERATED);
83
81
}
84
82
@@ -96,29 +94,29 @@ void drawCircle(SDL_Renderer *&render, SDL_Point center, int radius,
96
94
}
97
95
}
98
96
99
- void draw (int SCALE , std::array<int , 3 > BGCOLOR , std::array<int , 3 > WALLCOLOR ,
97
+ void draw (int scale , std::array<int , 3 > bgColor , std::array<int , 3 > wallColor ,
100
98
SDL_Renderer *&render,
101
99
sycl::host_accessor<Actor, 1 , sycl::access::mode::read> actors,
102
100
Room room) {
103
- SDL_SetRenderDrawColor (render, BGCOLOR [0 ], BGCOLOR [1 ], BGCOLOR [2 ], 255 );
101
+ SDL_SetRenderDrawColor (render, bgColor [0 ], bgColor [1 ], bgColor [2 ], 255 );
104
102
SDL_RenderClear (render);
105
103
106
104
for (int i = 0 ; i < actors.size (); i++) {
107
105
auto actor = actors[i];
108
- SDL_Point pos = {int (actor.getPos ()[0 ] * SCALE ),
109
- int (actor.getPos ()[1 ] * SCALE )};
106
+ SDL_Point pos = {int (actor.getPos ()[0 ] * scale ),
107
+ int (actor.getPos ()[1 ] * scale )};
110
108
SDL_Color actorColor = {Uint8 (actor.getColor ()[0 ]),
111
109
Uint8 (actor.getColor ()[1 ]),
112
110
Uint8 (actor.getColor ()[2 ]), 255 };
113
- drawCircle (render, pos, actor.getRadius () * SCALE , actorColor);
111
+ drawCircle (render, pos, actor.getRadius () * scale , actorColor);
114
112
}
115
113
116
- SDL_SetRenderDrawColor (render, WALLCOLOR [0 ], WALLCOLOR [1 ], WALLCOLOR [2 ],
114
+ SDL_SetRenderDrawColor (render, wallColor [0 ], wallColor [1 ], wallColor [2 ],
117
115
255 );
118
116
auto walls = room.getWalls ();
119
117
for (auto wall : walls) {
120
- SDL_RenderDrawLine (render, wall[0 ][0 ] * SCALE , wall[0 ][1 ] * SCALE ,
121
- wall[1 ][0 ] * SCALE , wall[1 ][1 ] * SCALE );
118
+ SDL_RenderDrawLine (render, wall[0 ][0 ] * scale , wall[0 ][1 ] * scale ,
119
+ wall[1 ][0 ] * scale , wall[1 ][1 ] * scale );
122
120
}
123
121
124
122
SDL_RenderPresent (render);
@@ -183,14 +181,14 @@ void updateBBox(sycl::queue &myQueue, sycl::buffer<Actor> &actorBuf) {
183
181
}
184
182
185
183
int main (int argc, char *argv[]) {
186
- int WIDTH ; // metres
187
- int HEIGHT ; // metres
188
- int SCALE ;
189
- int DELAY ;
190
- bool HEATMAPENABLED ;
184
+ int width ; // metres
185
+ int height ; // metres
186
+ int scale ;
187
+ int delay ;
188
+ bool heatmapEnabled ;
191
189
192
- std::array<int , 3 > BGCOLOR ;
193
- std::array<int , 3 > WALLCOLOR ;
190
+ std::array<int , 3 > bgColor ;
191
+ std::array<int , 3 > wallColor ;
194
192
195
193
std::vector<Actor> actors;
196
194
Room room = Room ({});
@@ -204,13 +202,13 @@ int main(int argc, char *argv[]) {
204
202
205
203
sycl::queue myQueue{sycl::gpu_selector (), asyncHandler};
206
204
207
- init (WIDTH, HEIGHT, SCALE, DELAY, BGCOLOR, WALLCOLOR, HEATMAPENABLED ,
205
+ init (width, height, scale, delay, bgColor, wallColor, heatmapEnabled ,
208
206
actors, room, paths, argc, argv);
209
207
210
208
#ifndef PROFILING_MODE
211
209
SDL_Window *win;
212
210
SDL_Renderer *render;
213
- initSDL (WIDTH, HEIGHT, SCALE , win, render);
211
+ initSDL (width, height, scale , win, render);
214
212
#endif
215
213
216
214
// Buffer creation
@@ -221,7 +219,7 @@ int main(int argc, char *argv[]) {
221
219
wallsBuf.set_final_data (nullptr );
222
220
auto pathsBuf = sycl::buffer<Path>(paths.data (), paths.size ());
223
221
pathsBuf.set_final_data (nullptr );
224
- auto heatmapEnableBuf = sycl::buffer<bool >(&HEATMAPENABLED , 1 );
222
+ auto heatmapEnableBuf = sycl::buffer<bool >(&heatmapEnabled , 1 );
225
223
226
224
int delayCounter = 0 ;
227
225
int updateBBoxCounter = 0 ;
@@ -260,7 +258,7 @@ int main(int argc, char *argv[]) {
260
258
#endif
261
259
262
260
if (!isPause) {
263
- if (delayCounter >= DELAY ) {
261
+ if (delayCounter >= delay ) {
264
262
delayCounter = 0 ;
265
263
266
264
#ifdef STATS
@@ -294,7 +292,7 @@ int main(int argc, char *argv[]) {
294
292
actorHostAcc (actorBuf);
295
293
296
294
#ifndef PROFILING_MODE
297
- draw (SCALE, BGCOLOR, WALLCOLOR , render, actorHostAcc, room);
295
+ draw (scale, bgColor, wallColor , render, actorHostAcc, room);
298
296
#endif
299
297
300
298
updateBBoxCounter--;
0 commit comments