-
Notifications
You must be signed in to change notification settings - Fork 0
/
gol-cuda.cpp
56 lines (41 loc) · 1009 Bytes
/
gol-cuda.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
53
54
55
56
#include <SDL2/SDL.h>
#include <chrono>
#include <ctime>
#include "boilerplate.h"
#include "colours.h"
#include "field-cuda.h"
#include "graphics-cuda.h"
#include "terminal.h"
using namespace std::chrono;
unsigned S, H, W, F, P;
int T;
SDL_WINDOW
int main(int argc, char* argv[]) {
SANITY
ARGUMENTS
SDL_CHECK_INIT
if (S) {
SDL_BOILERPLATE
}
unsigned field[H * W];
init_field(field, H, W, F);
auto last_time = system_clock::now() - milliseconds(P);
unsigned t = 0;
while (!interrupted) {
SDL_QUIT_EVENT_HANDLER
auto now = system_clock::now();
if (duration_cast<milliseconds>(now - last_time).count() >= P) {
if (S) {
SDL_DRAW
} else {
clear(H);
display(field, H, W);
}
transition(field, H, W);
if (t++ >= T && T != -1) break;
last_time = now;
}
}
if (S) SDL_DESTROY_QUIT
return 0;
}