cleanup and instrumentation

This commit is contained in:
Erris
2026-01-25 16:12:32 +01:00
parent c8cfed58da
commit 736591415c
61 changed files with 845 additions and 383 deletions

View File

@@ -3,27 +3,32 @@
#include <application.hpp>
#include <core.hpp>
#include <core/time.hpp>
#include <events/application_event.hpp>
#include <renderer/renderer2d.hpp>
#include <renderer/renderer.hpp>
#include <input/input_system.hpp>
#include <imgui/imgui_layer.hpp>
#include <renderer/renderer.hpp>
#include <instrumentor.hpp>
#include <core/time.hpp>
#include <memory>
#include <imgui.h>
namespace OpenEngine {
Application::Application()
{
OE_PROFILE_FUNCTION();
OE_CORE_ASSERT(!instance, "Application already exists!");
instance = this;
window = Window::Create();
window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent));
Renderer::Init();
Renderer2D::Init();
{
OE_PROFILE_SCOPE("Initializing Renderers");
Renderer::Init();
Renderer2D::Init();
}
imgui_layer = std::make_shared<ImGuiLayer>();
QueueOverlayPush(imgui_layer);
@@ -33,24 +38,34 @@ namespace OpenEngine {
Application::~Application()
{
Renderer2D::Shutdown();
Renderer::ShutDown();
}
void Application::Run()
{
OE_PROFILE_FUNCTION()
while(running) {
OE_PROFILE_SCOPE("Frame");
Time::Update();
layer_stack.UpdateLayers();
for (auto layer : layer_stack)
layer->OnUpdate();
{
OE_PROFILE_SCOPE("Updating all Layers");
for (auto layer : layer_stack)
layer->OnUpdate();
}
imgui_layer->Begin();
{
OE_PROFILE_SCOPE("Rendering ImGui");
imgui_layer->Begin();
for (auto layer : layer_stack)
layer->OnImGuiRender();
for (auto layer : layer_stack)
layer->OnImGuiRender();
imgui_layer->End();
imgui_layer->End();
}
window->OnUpdate();
}
@@ -58,14 +73,19 @@ namespace OpenEngine {
void Application::OnEvent(Event& event)
{
OE_PROFILE_FUNCTION();
EventDispatcher dispatcher(event);
dispatcher.Dispatch<WindowCloseEvent>(BIND_EVENT_FN(Application::OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(BIND_EVENT_FN(Application::OnWindowResize));
for (auto it = layer_stack.end(); it != layer_stack.begin();) {
(*--it)->OnEvent(event);
if (event.handled)
break;
{
OE_PROFILE_SCOPE("Layers OnEvent");
for (auto it = layer_stack.end(); it != layer_stack.begin();) {
(*--it)->OnEvent(event);
if (event.handled)
break;
}
}
}
@@ -78,6 +98,7 @@ namespace OpenEngine {
bool Application::OnWindowResize(WindowResizeEvent& event)
{
OE_PROFILE_FUNCTION();
Renderer::OnWindowResize(event.GetWidth(), event.GetHeight());
return false;