-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (31 loc) · 939 Bytes
/
main.cpp
File metadata and controls
42 lines (31 loc) · 939 Bytes
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
//
// Created by 이재현 on 2021/09/19.
//
#include "glHeader.h"
int main() {
glWindowInit();
shaderInit();
simulationInit();
glObjectInit();
do {
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
//main simulation step
step();
render();
std::cout << "frame: " << frame << "\n";
frame++;
glfwSwapBuffers(window);
#if RECORD_VIDEO
//Make sure ffmpeg has installed and added to Environment variable.
glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
fwrite(buffer, sizeof(int) * WINDOW_WIDTH * WINDOW_HEIGHT, 1, ffmpeg);
#endif
} // Check if the ESC key was pressed or the window was closed
while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 && frame <END_FRAME);
#if RECORD_VIDEO
_pclose(ffmpeg);
#endif
return 0;
}