SpiecsEngine
 
Loading...
Searching...
No Matches
Application.cpp
Go to the documentation of this file.
1/**
2* @file Application.cpp.
3* @brief The Application Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
8#include "Application.h"
9#include "Render/FrameInfo.h"
10#include "Render/Vulkan/VulkanRenderBackend.h"
11#include "Thread\ThreadModel.h"
12
13// System Header.
14#include "Systems/SystemManager.h"
15#include "Systems/RenderSystem.h"
16#include "Systems/NativeScriptSystem.h"
17#include "Systems/ResourceSystem.h"
18#include "Systems/SlateSystem.h"
19#include "Core/Memory/MemoryPool.h"
20
21namespace Spices {
22
24 {
26
27 /**
28 * @brief Init Log Class.
29 */
31
32 /**
33 * @brief Init General ThreadPool.
34 */
35 ThreadModel::Get()->InitCustomThreadPool();
36 ThreadModel::Get()->InitGameThreadPool();
37
38 /**
39 * @brief Init all Systems.
40 */
42 .PushSystem<NativeScriptSystem>()
43 .PushSystem<RenderSystem>()
44 .PushSystem<ResourceSystem>()
45 .PushSystem<SlateSystem>();
46 }
47
49 {
51
52 /**
53 * @brief Destroy our Specific World.
54 */
55 FrameInfo::Get().m_World = nullptr;
56
57 /**
58 * @brief Release ThreadPool.
59 */
60 ThreadModel::Get()->ShutDownThreadModel();
61
62 /**
63 * @brief Destroy all Systems.
64 */
66 .PopSystem("SlateSystem")
67 .PopSystem("ResourceSystem")
68 .PopSystem("RenderSystem")
69 .PopSystem("NativeScriptSystem");
70
71 /**
72 * @brief Shutdown Log Class.
73 */
75 }
76
78 {
79 /**
80 * @brief Specify the current World, which created from Game.
81 * @todo Mult World Support.
82 */
83 FrameInfo::Get().m_World = CreateWorld();
84
85 /**
86 * @brief World OnPreActivate.
87 * @todo Remove.
88 */
89 FrameInfo::Get().m_World->OnPreActivate();
90
91 /**
92 * @brief Init Golbal TimeStep Class.
93 */
94 TimeStep ts;
95
96 /**
97 * @brief Golbal While Loop.
98 * @todo Multithreading.
99 */
100 while (!glfwWindowShouldClose(VulkanRenderBackend::GetState().m_Windows))
101 {
102 SPICES_PROFILE_ZONEN("MainLoop");
103
104 /**
105 * @brief Wait for glfw events.
106 */
107 glfwPollEvents();
108
109 /**
110 * @brief Update TimeStep.
111 */
112 ts.Flush();
113
114 /**
115 * @brief Update Aftermath frame cut.
116 */
117 NSIGHTAFTERMATH_GPUCRASHTRACKER_SETFRAMECUT(ts.fs())
118
119 /**
120 * @brief Activete Our Specific World.
121 */
122 FrameInfo::Get().m_World->OnActivate(ts);
123
125 }
126
127 /**
128 * @brief Vulkan Device Idle.
129 */
130 vkDeviceWaitIdle(VulkanRenderBackend::GetState().m_Device);
131
132 /**
133 * @brief Deactivate Our Specific World.
134 */
135 FrameInfo::Get().m_World->OnDeactivate();
136 }
137}
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define SPICES_PROFILE_FRAME
virtual ~Application()
Destructor Function.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
static FrameInfo & Get()
Get FrameInfo.
Definition FrameInfo.cpp:14
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
static void Init()
Init Log.
Definition Log.cpp:24
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
NativeScriptSystem Class. This class defines the specific behaves of NativeScriptSystem.
ResourceSystem Class. This class defines the specific behaves of RenderSystem.
ResourceSystem Class. Handles resource load/unload event.
SlateSystem Class. This class defines the specific behaves of SlateSystem.
Definition SlateSystem.h:21
SystemManager()
Constructor Function.
static SystemManager & Get()
Get Static SystemManager.
SystemManager & PopSystem(const std::string &systemName)
Push a system to this manager.
SystemManager Class. This class defines the behave of SystemManager.
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
static VulkanState & GetState()
Get VulkanState in use.
This class defines the render backend behaves of Vulkan.