3#include "pixelbullet/application/event.h"
4#include "pixelbullet/application/specification.h"
13struct ApplicationBootstrap;
15using ApplicationFactory = std::unique_ptr<Application> (*)(
const ApplicationBootstrap& bootstrap);
24class WindowCloseEvent;
25class WindowResizeEvent;
83 template <
typename T,
typename... Args>
86 static_assert(std::is_base_of<Layer, T>::value,
"T must be derived from Layer");
87 auto layer = std::make_unique<T>(std::forward<Args>(args)...);
88 return static_cast<T*
>(PushLayerImpl(std::move(layer)));
95 template <
typename T,
typename... Args>
98 static_assert(std::is_base_of<Layer, T>::value,
"T must be derived from Layer");
99 auto layer = std::make_unique<T>(std::forward<Args>(args)...);
100 return static_cast<T*
>(PushOverlayImpl(std::move(layer)));
109 return specification_;
118 ASSERT(window_,
"Window has not been initialized!");
128 ASSERT(graphics_,
"Graphics system has not been initialized!");
138 ASSERT(audio_,
"Audio system has not been initialized!");
144 ASSERT(filesystem_,
"Filesystem has not been initialized!");
147 const Filesystem& GetFilesystem()
const
149 ASSERT(filesystem_,
"Filesystem has not been initialized!");
153 ResourceCache& GetResourceCache()
155 ASSERT(resource_cache_,
"Resource cache has not been initialized!");
156 return *resource_cache_;
158 const ResourceCache& GetResourceCache()
const
160 ASSERT(resource_cache_,
"Resource cache has not been initialized!");
161 return *resource_cache_;
164 void Start() noexcept
173 [[nodiscard]]
inline bool IsRunning() const noexcept
178 static int Launch(
const ApplicationBootstrap& bootstrap, ApplicationFactory factory);
198 EventResult OnWindowClose(WindowCloseEvent& e);
205 EventResult OnWindowResize(WindowResizeEvent& e);
206 Layer* PushLayerImpl(std::unique_ptr<Layer> layer);
207 Layer* PushOverlayImpl(std::unique_ptr<Layer> layer);
208 void RegisterUiFrameLayer(Layer* layer);
210 std::unique_ptr<Filesystem> filesystem_;
211 std::unique_ptr<ResourceCache> resource_cache_;
213 std::unique_ptr<Window> window_;
214 std::unique_ptr<Graphics> graphics_;
215 std::unique_ptr<Audio> audio_;
217 std::unique_ptr<LayerStack> layer_stack_;
218 UiFrameLayer* ui_frame_layer_ =
nullptr;
221 ApplicationSpecification specification_;
222 ApplicationLaunchOptions launch_options_;
224 bool running_ =
true;
225 bool minimized_ =
false;
226 float last_frame_time_ = 0.0f;
Provides assertion and panic mechanisms with optional custom formatting.
#define ASSERT(condition,...)
Asserts that a condition is true.
Definition assert.h:163
Main application class.
Definition application.h:40
Application(ApplicationSpecification specification, const ApplicationBootstrap &bootstrap)
Definition application.cc:60
T * PushLayer(Args &&... args)
Definition application.h:84
Window & GetWindow()
Definition application.h:116
Application & operator=(const Application &)=delete
const ApplicationSpecification & GetSpecification() const
Definition application.h:107
Application(const Application &)=delete
Audio & GetAudio()
Definition application.h:136
T * PushOverlay(Args &&... args)
Definition application.h:96
Graphics & GetGraphics()
Definition application.h:126
virtual ~Application()
Definition application.cc:116
Application & operator=(Application &&)=delete
Application(Application &&)=delete
void OnEvent(Event &e)
Definition application.cc:178
Definition filesystem.h:16
Module that manages the Vulkan instance_, Surface, Window and the renderpass structure.
Definition graphics.h:36
Definition specification.h:62
Contains configuration options for both the game and the engine.
Definition specification.h:145