light/Engine/src/Engine/Core/Application.cpp

45 lines
789 B
C++
Raw Normal View History

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()
{
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)
{
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
}