-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject.cpp
More file actions
44 lines (39 loc) · 1.24 KB
/
project.cpp
File metadata and controls
44 lines (39 loc) · 1.24 KB
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
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;
#include "simulator.h"
#include "videomaker.h"
int main(int argc, char* argv[]) {
Simulator sim;
char profile_filename[256];
strcpy(profile_filename, "profile.txt");
if(argc == 2)
strcpy(profile_filename, argv[1]);
printf("Start simulation using profile '%s'\n", profile_filename);
sim.initialize(profile_filename);
if(sim.config.find("load") != sim.config.end())
sim.loadState(sim.config["load"].c_str());
VideoMaker* video = VideoMaker_Create("imgs/video", sim.render.width, sim.render.height);
for(int i = 0; i < sim.max_frame; i++) {
Timing tm("Frame");
sim.runSimulation();
sim.renderFrame();
tm.measure("run");
video->addFrame(sim.render.colors, sim.render.width, sim.render.height);
tm.measure("write");
fflush(stdout);
if(i % 100 == 0) {
char filename[256];
sprintf(filename, "imgs/state.%04d.bin", i);
sim.saveState(filename);
}
}
sim.saveState("imgs/state.bin");
video->finish();
return 0;
}