light/modules/app/include/app/application.hpp

78 lines
1.2 KiB
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#pragma once
#include <time/timer.hpp>
2025-07-05 13:28:41 +03:30
2025-07-11 00:05:48 +03:30
namespace lt {
2025-07-05 13:28:41 +03:30
class Renderer;
2025-07-05 13:28:41 +03:30
class Window;
class Event;
class GraphicsContext;
2025-07-11 01:42:56 +03:30
class UserInterface;
class LayerStack;
2025-07-05 13:28:41 +03:30
2025-07-07 15:13:05 +03:30
extern Scope<class Application> create_application();
2025-07-05 16:07:51 +03:30
class Application
2025-07-05 13:28:41 +03:30
{
public:
Application(const Application &) = delete;
2025-07-05 16:07:51 +03:30
2025-07-07 15:13:05 +03:30
Application(Application &&) = delete;
auto operator=(const Application &) -> Application & = delete;
auto operator=(Application &&) -> Application & = delete;
2025-07-05 13:28:41 +03:30
2025-07-11 01:42:56 +03:30
virtual ~Application();
2025-07-05 13:28:41 +03:30
2025-07-11 00:24:44 +03:30
[[nodiscard]] auto sanity_check() const -> bool;
void game_loop();
2025-07-05 13:28:41 +03:30
2025-07-07 15:13:05 +03:30
[[nodiscard]] auto get_window() -> Window &
{
return *m_window;
}
2025-07-11 00:56:57 +03:30
[[nodiscard]] auto get_layer_stack() -> LayerStack &
{
return *m_layer_stack;
}
static void quit();
2025-07-05 13:28:41 +03:30
protected:
Application();
private:
2025-07-11 00:49:04 +03:30
void update_layers();
void render_layers();
void render_user_interface();
void poll_events();
2025-07-06 16:30:38 +03:30
void on_event(const Event &event);
2025-07-05 16:07:51 +03:30
2025-07-11 00:49:04 +03:30
void log_debug_data() const;
Timer m_timer;
2025-07-07 15:13:05 +03:30
Scope<Window> m_window;
Scope<UserInterface> m_user_interface;
Scope<GraphicsContext> m_graphics_context;
Scope<Renderer> m_renderer;
2025-07-11 00:56:57 +03:30
Scope<LayerStack> m_layer_stack;
2025-07-07 15:13:05 +03:30
static Application *s_instance;
2025-07-05 13:28:41 +03:30
};
2025-07-11 00:05:48 +03:30
} // namespace lt