-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (36 loc) · 1.31 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
#include "htmlBuilder.hpp"
#include "renderer.hpp"
#include "scene.hpp"
#include "sceneDescriptionParser.hpp"
#include "stdFilesystem.hpp"
#include "timing.hpp"
#include <iostream>
#define PAGE_TITLE ("Extra Credit")
inline void generateScenesWebpage(const std::vector<fs::path>& sceneDescrs) {
HtmlBuilder htmlBuilder;
htmlBuilder.addHeader(PAGE_TITLE);
for (const fs::path& descr : sceneDescrs) {
SceneDescrParser sceneDescrParser(descr);
Scene scene = sceneDescrParser.parse();
Renderer renderer(scene);
Img img;
double renderTime = timeExecutionOf([&] { renderer.render(img); });
fs::path png = descr.stem();
png.replace_extension("png");
img.writePng(png);
htmlBuilder.addHr();
htmlBuilder.addPre(sceneDescrParser.getRawDescription());
htmlBuilder.addImg(png);
htmlBuilder.addP("Rendered in " + std::to_string(renderTime) + " sec");
}
htmlBuilder.write(PAGE_TITLE, "index.html");
}
int main(int argc, char* argv[]) {
if (argc == 1) {
std::cout << "Usage: " << argv[0] << " scene-description-1 scene-description-2 ... scene-description-n" << std::endl;
return 0;
}
std::vector<fs::path> sceneDescrs(argv + 1, argv + argc);
generateScenesWebpage(sceneDescrs);
return 0;
}