added queuing push and pop logic and having fun with c# integration
This commit is contained in:
@@ -1,42 +1,51 @@
|
||||
#include <pch.hpp>
|
||||
|
||||
#include <core.hpp>
|
||||
#include <events/application_event.hpp>
|
||||
#include <imgui/imgui_layer.hpp>
|
||||
#include <core/time.hpp>
|
||||
#include <renderer/renderer.hpp>
|
||||
#include <application.hpp>
|
||||
#include <input/input_system.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 <memory>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
Application::Application()
|
||||
{
|
||||
OE_CORE_ASSERT(!instance, "Application already exists!");
|
||||
instance = this;
|
||||
|
||||
window = std::unique_ptr<Window>(Window::Create());
|
||||
window = Window::Create();
|
||||
window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent));
|
||||
|
||||
Renderer::Init();
|
||||
Renderer2D::Init();
|
||||
|
||||
imgui_layer = new ImGuiLayer();
|
||||
PushOverlay(imgui_layer);
|
||||
imgui_layer = std::make_shared<ImGuiLayer>();
|
||||
QueueOverlayPush(imgui_layer);
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
Renderer2D::Shutdown();
|
||||
}
|
||||
|
||||
void Application::Run()
|
||||
{
|
||||
while(running) {
|
||||
Time::Get().Update();
|
||||
layer_stack.UpdateLayers();
|
||||
|
||||
for (Layer* layer : layer_stack)
|
||||
for (auto layer : layer_stack)
|
||||
layer->OnUpdate();
|
||||
|
||||
imgui_layer->Begin();
|
||||
|
||||
for (Layer* layer : layer_stack)
|
||||
for (auto layer : layer_stack)
|
||||
layer->OnImGuiRender();
|
||||
|
||||
imgui_layer->End();
|
||||
@@ -72,13 +81,23 @@ namespace OpenEngine {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Application::PushLayer(Layer* layer)
|
||||
void Application::QueueLayerPush(Ref<Layer> layer)
|
||||
{
|
||||
layer_stack.PushLayer(layer);
|
||||
layer_stack.QueueLayerPush(layer);
|
||||
}
|
||||
|
||||
void Application::PushOverlay(Layer* overlay)
|
||||
void Application::QueueLayerPop(Ref<Layer> layer)
|
||||
{
|
||||
layer_stack.PushOverlay(overlay);
|
||||
layer_stack.QueueLayerPop(layer);
|
||||
}
|
||||
|
||||
void Application::QueueOverlayPush(Ref<Layer> overlay)
|
||||
{
|
||||
layer_stack.QueueOverlayPush(overlay);
|
||||
}
|
||||
|
||||
void Application::QueueOverlayPop(Ref<Layer> overlay)
|
||||
{
|
||||
layer_stack.QueueOverlayPop(overlay);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user