-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
72 lines (58 loc) · 1.88 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Voxel Volume Renderer.
*
* @author Mirco Werner
*/
#include "renderengine/engine/RenderEngine.h"
#include "renderengine/utils/IOUtils.h"
#include "volumerenderer/VolumeRenderLogic.h"
void generateTestScreenshots(GLFWwindow *window, IRenderLogic *renderLogic) {
glfwSetWindowSize(window, 1920, 1080);
glfwPollEvents();
glfwSwapBuffers(window);
glFinish();
int number = 0;
IRenderLogic::SceneScreenshotInfo info;
while (renderLogic->generateSceneScreenshot(number, &info)) {
glfwSetWindowSize(window, info.width, info.height);
glfwPollEvents();
glFinish();
for (int i = 0; i < info.iterations; i++) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderLogic->render();
glfwSwapBuffers(window);
}
IOUtils::writeFramebufferToFile(info.fileName, info.width, info.height);
number++;
}
}
int main(int argc, char *argv[]) {
GLFWwindow *window = RenderEngine::initGL("Voxel Volume Render", 1920, 1080);
if (window == nullptr) {
return -1;
}
RenderEngine::initImGui(window);
IRenderLogic *renderLogic = new VolumeRenderLogic();
// startup parameters
bool generateImages = false;
for (int i = 1; i < argc; i++) {
renderLogic->m_startupParameters.emplace_back(argv[i]);
if (std::string("--generate-images") == argv[i]) {
generateImages = true;
}
}
// startup for screenshot generation
if (generateImages) {
auto *renderEngine = new RenderEngine(window, renderLogic);
renderEngine->init();
generateTestScreenshots(window, renderLogic);
renderEngine->cleanUp();
delete renderEngine;
return 0;
}
// normal startup
auto *renderEngine = new RenderEngine(window, renderLogic);
renderEngine->run();
delete renderEngine;
return 0;
}