-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.cpp
61 lines (52 loc) · 1.27 KB
/
Application.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
#include "Application.h"
#include "logging.h"
#include "Imgui/ImguiLayer.h"
namespace CC
{
Application *Application::application;
Application::Application()
{
assert(!application);
application = this;
m_Window = Window::Create();
m_Window->SetEventCallback(BIND_EVENT_FN(OnEvent));
PushOverlay(new ImguiLayer());
}
Application::~Application()
{
}
void Application::run()
{
LOGI("hello world")
while (m_Running)
{
for (Layers *layer : m_LayerStack)
{
layer->OnUpdate();
}
// LOGI("update")
m_Window->OnUpdate();
}
}
void Application::OnEvent(Event &e)
{
LOGI("on OnEvent {0}", e.ToString());
EventDispatcher dispatcher(e);
dispatcher.Dispatch<WindowCloseEvent>(BIND_EVENT_FN(OnWindowClose));
}
bool Application::OnWindowClose(WindowCloseEvent &e)
{
m_Running = false;
return true;
}
void Application::PushLayer(Layers *layer)
{
m_LayerStack.PushLayer(layer);
layer->OnAttach();
}
void Application::PushOverlay(Layers *layer)
{
m_LayerStack.PushOverlay(layer);
layer->OnAttach();
}
}