LkEngine 0.1.2
 
Loading...
Searching...
No Matches
Application.h
Go to the documentation of this file.
1
4#pragma once
5
6#include "LkEngine/Version.h"
7
11#include "LkEngine/Core/LObject/ObjectPtr.h"
12#include "LkEngine/Core/ApplicationConfig.h"
14#include "LkEngine/Core/Layer.h"
16#include "LkEngine/Core/CrashHandler.h"
18#include "LkEngine/Core/IO/File.h"
19#include "LkEngine/Core/IO/FileSystem.h"
21#include "LkEngine/Core/MetadataRegistry.h"
22#include "LkEngine/Core/Memory/GarbageCollector.h"
23#include "LkEngine/Core/Event/KeyEvent.h"
24#include "LkEngine/Core/Event/MouseEvent.h"
25#include "LkEngine/Core/Event/EventQueue.h"
26#include "LkEngine/Core/Input/Input.h"
27#include "LkEngine/Core/Input/Mouse.h"
28#include "LkEngine/Core/Input/Keyboard.h"
29
30#include "LkEngine/Renderer/UI/UILayer.h"
31
32#include "LkEngine/Asset/AssetManager.h"
33
34#include "LkEngine/Renderer/Renderer.h"
35#include "LkEngine/Renderer/SceneRenderer.h"
36
37#include "LkEngine/Serialization/FileStream.h"
38
39#include "LkEngine/Scene/Scene.h"
40#include "LkEngine/Scene/Entity.h"
41#include "LkEngine/Scene/Components.h"
42#include "LkEngine/Scene/SceneSerializer.h"
43
44#include "LkEngine/Physics/PhysicsSystem.h"
45
46namespace LkEngine {
47
48 LK_DECLARE_MULTICAST_DELEGATE(FOnEngineShutdown);
49
56 namespace Core
57 {
63 extern FOnEngineShutdown OnEngineShutdown;
64
68 void Setup(const int Argc, char* Argv[]);
69 }
76 class LApplication : public LObject
77 {
78 public:
81
82 virtual void Initialize();
83 virtual void Run();
84 virtual void Shutdown();
85
86 FORCEINLINE static LApplication& Get() { return *Instance; }
87
88 bool ReadConfigurationFile(FApplicationSpecification& InSpecification);
89
90 void RenderUI();
91 void ProcessEvents();
92
93 static const char* GetPlatformName();
94 static const char* GetConfigurationName();
95
96 FORCEINLINE void PushLayer(TObjectPtr<LLayer> InLayer)
97 {
98 LayerStack.PushLayer(InLayer);
99 }
100
101 void OnEvent(LEvent& Event);
102
103 template<typename TEvent, bool DispatchImmediately = false, typename... TEventArgs>
104 void DispatchEvent(TEventArgs&&... Args)
105 {
106 std::shared_ptr<TEvent> Event = std::make_shared<TEvent>(std::forward<TEventArgs>(Args)...);
107 if constexpr (DispatchImmediately)
108 {
109 OnEvent(*Event);
110 }
111 else
112 {
113 /* Queue the event. */
114 CoreEventQueue.Add([Event]() { LApplication::Get().OnEvent(*Event); });
115 }
116 }
117
118 FORCEINLINE LWindow& GetWindow() { return *Window; }
119 uint32_t GetCurrentFrameIndex() const { return CurrentFrameIndex; }
120
121 FORCEINLINE const FApplicationSpecification& GetSpecification() const { return Specification; }
122
123 LPerformanceProfiler* GetPerformanceProfiler() { return PerformanceProfiler; }
124
125 FORCEINLINE float GetDeltaTime() const { return LastDeltaTime; }
126 std::string GenerateCrashDump();
127
128 private:
129 bool bRunning = false;
130 FApplicationSpecification Specification{};
131
132 LTimer Timer;
133 float LastDeltaTime = 0.0f;
134
135 LMetadataRegistry& MetadataRegistry;
136 LEventQueue CoreEventQueue;
137
138 TObjectPtr<LWindow> Window{};
139 LLayerStack LayerStack;
140
141 uint32_t CurrentFrameIndex = 0;
142
143 TObjectPtr<LUILayer> UILayer{};
144
145 LPerformanceProfiler* PerformanceProfiler{};
146 std::unordered_map<const char*, LPerformanceProfiler::FFrameData> ProfilerPreviousFrameData;
147
148 inline static LApplication* Instance = nullptr;
149
151 };
152
153}
Core header.
Globals.
Layer stack.
Base layer.
Mathematics used by the engine.
LObject implementation.
Timer.
Definition Application.h:77
virtual void Initialize()
Initialize object.
Definition Application.cpp:45
Definition EventQueue.h:74
FORCEINLINE void Add(EventArgs &&... Args)
Definition EventQueue.h:182
Definition Event.h:71
Definition LayerStack.h:25
FORCEINLINE void PushLayer(LLayer *Layer)
Push a layer to top of the layer stack.
Definition LayerStack.h:38
Definition MetadataRegistry.h:19
Definition Object.h:46
Definition Timer.h:99
Definition Timer.h:26
Definition Window.h:88
Definition ObjectPtr.h:102
#define LCLASS(Class)
Definition CoreMacros.h:226
Definition Asset.h:11
Definition ApplicationConfig.h:10