Class Application¶
Defined in File application.h
Class Documentation¶
-
class Application¶
The main application class providing the game loop and module orchestration.
Application is the entry point for Portal Framework applications. It manages the main game loop, coordinates module lifecycle execution, and handles frame timing.
The typical flow:
Construct Application (or derived class like Engine) with ApplicationProperties
Register modules with modules.add_module<T>()
Call modules.build_dependency_graph()
Call run() to start the game loop
Each frame executes:
process_events() - virtual method for windowing/input (override in derived class)
modules.begin_frame(context)
modules.update(context)
modules.gui_update(context)
modules.post_update(context)
modules.end_frame(context)
Derived classes (typically Engine) register their specific modules in the constructor and override process_events() for platform-specific event handling.
Example:
int main() { ApplicationProperties props{ .name = STRING_ID("My Game"), .width = 1920, .height = 1080 }; Engine engine(props); // Engine derives from Application return engine.run(); }
Public Functions
-
explicit Application(const ApplicationProperties &properties)¶
Construct application with configuration properties.
- Parameters:
properties – Configuration for window, buffering, resources, etc.
-
virtual ~Application()¶
-
virtual void build_dependency_graph()¶
-
inline virtual void prepare()¶
-
void run()¶
Start the main game loop.
Executes the frame loop until should_run() returns false. Each iteration processes events, executes module lifecycle hooks in sequence, and updates frame timing. Blocks until the application stops.
-
void stop()¶
Request the application to stop. Sets the should_stop flag, causing the game loop to exit after the current frame.
-
inline virtual void process_events()¶
Process platform events (override in derived classes). Called at the beginning of each frame before module lifecycle execution.
-
void on_event(Event &event)¶
Dispatch an event to all registered event handlers and modules.
- Parameters:
event – The event to dispatch
-
virtual bool should_run() const¶
Check if the application should continue running.
- Returns:
true if the game loop should continue, false to exit
Protected Functions
-
virtual ProjectSettings &get_settings() const = 0¶
Protected Attributes
-
ApplicationProperties properties¶
-
ModuleStack modules¶
-
size_t current_frame = 0¶
-
float last_frame_time = 0¶
-
float frame_time = 0¶
-
float time_step = 0¶
-
std::atomic_flag should_stop¶
-
llvm::SmallVector<std::reference_wrapper<EventHandler>> event_handlers¶