-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (51 loc) · 1.59 KB
/
main.cpp
File metadata and controls
63 lines (51 loc) · 1.59 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "Header.h"
#include "Struct_cam.h"
int main(void)
{
Camera camera;
int randomness = 0;
int heightmapWidth = 0;
cout << "Enter size fro map: ";
cin >> heightmapWidth;
cout << "Enter the randomness: ";
cin >> randomness;
heightmapWidth += 1;
int** heightmap = createHeightmap(heightmapWidth);
if (!glfwInit())
return -1;
GLFWwindow* window = glfwCreateWindow(1200, 800, "3D", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glFrustum(-1.5, 1.5, -1.5, 1.5, 2, 1500);
glEnable(GL_DEPTH_TEST);
generateHeightmap(heightmap, heightmapWidth, randomness);
createDisplayList(heightmap, heightmapWidth);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
MoveCamera(camera);
drawHeightmap();
glPopMatrix();
glfwSwapBuffers(window);
glfwPollEvents();
if (glfwGetKey(window, GLFW_KEY_G) == GLFW_PRESS)
{
generateHeightmap(heightmap, heightmapWidth, randomness);
createDisplayList(heightmap, heightmapWidth);
}
if (glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS)
{
cout << "Enter the randomness: ";
cin >> randomness;
generateHeightmap(heightmap, heightmapWidth, randomness);
createDisplayList(heightmap, heightmapWidth);
}
}
glfwTerminate();
return 0;
}