-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (41 loc) · 1.12 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
#include "ggl.h"
#include "Window.h"
#include "stb_image/stb_image.h"
#include "Scene.h"
#define SCR_WIDTH 1280
#define SCR_HEIGHT 720
const char* SCR_WND_NAME = "OPENGL_LIGHT";
std::unique_ptr<GLWindow> wnd = nullptr;
std::unique_ptr<Scene> scene = nullptr;
std::unique_ptr<UI> myUI = nullptr;
void GL_Interaction() {
glfwSetFramebufferSizeCallback(wnd->GetWnd(), framebuffer_size_callback);
glfwSetKeyCallback(wnd->GetWnd(), key_callback);;
glfwSetCursorPosCallback(wnd->GetWnd(), mouse_callback);
glfwSetMouseButtonCallback(wnd->GetWnd(), mouse_button_callback);
}
int main(int argc, char* argv[]) {
// create and init window
wnd.reset(new GLWindow(SCR_WIDTH, SCR_HEIGHT, SCR_WND_NAME));
if (!wnd->Init(true)) {
wnd->Close();
return -1;
}
// Set interaction
wnd->InitInteraction(GL_Interaction);
//UI
myUI.reset(new UI(wnd->GetWnd()));
myUI->ImguiInit();
scene.reset(new Scene());
scene->Init(myUI.get());
while (!wnd->IsClose()) {
myUI->ImguiCreateWindow();
wnd->Update(0.0f, 0.34f, 0.57f);
scene->Render();
myUI->ImguiRender();
wnd->SwapBuffer();
wnd->PollEvents();
}
wnd->Close();
return 0;
}