-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
89 lines (70 loc) · 2.04 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "core/input.h"
#include "core/window.h"
#include "graphics/gpubuffer.h"
#include "graphics/graphicsdevice.h"
#include "scenegraph/scenebase.h"
#include "pointcloud/chunkmanager.h"
#include "pointcloud/chunkjobmanager.h"
#include "misc/model.h"
#include "imgui/imgui.h"
#include <chrono>
#include <fstream>
#include <iostream>
#include <memory>
#include <random>
#include <immintrin.h>
namespace PVC = ProtoVoxel::Core;
namespace PVG = ProtoVoxel::Graphics;
namespace PPC = ProtoVoxel::PointCloud;
namespace PVSG = ProtoVoxel::SceneGraph;
namespace PVM = ProtoVoxel::Misc;
class TestScene : public PVSG::SceneBase
{
private:
public:
TestScene() {}
~TestScene() {}
PPC::ChunkManager manager;
void Initialize() override
{
PVSG::SceneBase::Initialize();
manager.Initialize();
}
void Update(double time) override
{
manager.Update(camera.GetParameters()->eyePos, camera.GetParameters()->vp, PVSG::SceneBase::camera_buffer.GetBuffer());
PVSG::SceneBase::Update(time);
}
void Render(double time) override
{
manager.Render(PVSG::SceneBase::camera_buffer.GetBuffer(), time);
auto tmp = camera.GetParameters()->eyePos;
ImGui::Begin("Camera Info");
ImGui::Text("Camera Position: %f, %f, %f\n", tmp.x, tmp.y, tmp.z);
tmp = camera.GetParameters()->eyeDir;
ImGui::Text("Camera Direction: %f, %f, %f\n", tmp.x, tmp.y, tmp.z);
ImGui::End();
}
};
int main(int, char **)
{
PVC::Window win(1024, 1024, "Test");
win.InitGL();
PVC::Input::RegisterWindow(&win);
TestScene* scene = new TestScene();
scene->Initialize();
srand(0);
double lastTime = 0, nowTime = 0;
while (!win.ShouldClose())
{
PVG::GraphicsDevice::ClearAll();
win.StartFrame();
auto delta = (nowTime - lastTime) * 1000;
scene->UpdateStart(delta);
scene->Update(delta);
scene->Render(delta);
win.SwapBuffers();
lastTime = nowTime;
nowTime = win.GetTime();
}
}