-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInitialize.cpp
More file actions
64 lines (49 loc) · 1.4 KB
/
Initialize.cpp
File metadata and controls
64 lines (49 loc) · 1.4 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
64
#include "Initialize.h"
int main()
{
srand(0);
rme::Scene *scene = new rme::Scene();
rme::Camera *camera = new rme::Camera(std::string("camera1"));
camera->position = glm::vec3(0.0, 2.0, -3.0);
camera->physics = true;
scene->add(camera);
rme::BoxInterior *room = new rme::BoxInterior(std::string("room"));
room->shape = glm::vec3(30.0, 16.0, 36.0);
room->color = glm::vec3(0.0, 0.8, 0.4);
//room->position = glm::vec3(0.5, 0.7, 0.2);
scene->add(room);
//rme::Light *light = new rme::Light(std::string("light"));
//light->position = glm::vec3(0.0, 3.0, 0.0);
//light->radius = 1.0;
rme::Sphere *sphere = new rme::Sphere(std::string("light"));
sphere->radius = 1.0;
sphere->position = glm::vec3(0.0, 2.0, 10.0);
scene->add(sphere);
rme::RaymarchRenderer *renderer = new rme::RaymarchRenderer(1200, 720);
int totalFrames = 0;
int lastFrame = 0;
float totalTime = 0.0;
float lastTime = 0.0;
//glfwSetTime(0.0);
// Game loop
while (!glfwWindowShouldClose(renderer->window))
{
// s1->position.z += 0.002;
for (int i = 0; i < 5; i++)
{
scene->update(renderer->getControl());
}
renderer->render(scene, camera);
totalFrames++;
totalTime = float(glfwGetTime());
float delta = totalTime - lastTime;
if (delta > 1.0)
{
std::printf("FPS: %f\n", float(totalFrames - lastFrame)/delta);
lastFrame = totalFrames;
lastTime = totalTime;
}
}
delete renderer;
return 0;
}