2021-05-20 10:21:08 +04:30
|
|
|
#include "Application.h"
|
|
|
|
|
2021-05-21 10:55:39 +04:30
|
|
|
#include "Logger.h"
|
2021-05-21 20:33:37 +04:30
|
|
|
#include "Window.h"
|
2021-05-21 10:55:39 +04:30
|
|
|
|
2021-05-23 18:10:11 +04:30
|
|
|
#include "Events/MouseEvents.h"
|
|
|
|
|
|
|
|
#include <typeinfo>
|
|
|
|
#include <functional>
|
|
|
|
|
2021-05-20 10:21:08 +04:30
|
|
|
namespace Light {
|
|
|
|
|
|
|
|
Application::Application()
|
|
|
|
{
|
2021-05-21 10:55:39 +04:30
|
|
|
Logger::Initialize();
|
|
|
|
|
2021-05-23 18:10:11 +04:30
|
|
|
m_Window = std::unique_ptr<Window>(Window::Create({ "Title", 800u, 600u, false }, std::bind(&Application::OnEvent, this , std::placeholders::_1)));
|
|
|
|
|
|
|
|
TestLayer* layer = new TestLayer("Test Layer");
|
|
|
|
m_LayerStack.PushLayer(layer);
|
2021-05-21 20:33:37 +04:30
|
|
|
|
2021-05-21 10:55:39 +04:30
|
|
|
LT_ENGINE_INFO("Initialized Logger");
|
2021-05-20 10:21:08 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
Application::~Application()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::GameLoop()
|
|
|
|
{
|
2021-05-23 21:25:31 +04:30
|
|
|
while (m_Window->IsOpen())
|
|
|
|
{
|
|
|
|
m_Window->OnUpdate();
|
|
|
|
}
|
2021-05-20 10:21:08 +04:30
|
|
|
}
|
|
|
|
|
2021-05-23 18:10:11 +04:30
|
|
|
void Application::OnEvent(Event& event)
|
|
|
|
{
|
2021-05-23 21:25:31 +04:30
|
|
|
if (event.IsInCategory(WindowEventCategory))
|
|
|
|
m_Window->OnEvent(event);
|
|
|
|
|
|
|
|
m_LayerStack.OnEvent(event);
|
2021-05-23 18:10:11 +04:30
|
|
|
}
|
|
|
|
|
2021-05-20 10:21:08 +04:30
|
|
|
}
|