Getting Started with Application
This guide demonstrates how to create and run an Astra application.
Basic Application
Every Astra application follows three steps: initialize, start, then run.
cpp
#include "application.hpp"
using namespace astralix;
int main() {
Application* app = Application::init();
app->start();
app->run(); // blocks until window closes, then cleans up
return 0;
}What init() Sets Up
Application::init() creates the singleton instance and initializes all core subsystems in order:
EventDispatcherEventSchedulerTimeProjectManagerEngineSystemManagerWindowManager
What start() Does
start() activates the three runtime subsystems:
WindowManager- opens the window and prepares the rendering contextEngine- starts the ECS engineSystemManager- starts all registered systems
The Run Loop
run() executes the main loop until the window is closed, then deletes the application instance:
while window is open:
time->update()
wm->update()
scheduler POST_FRAME events
system->fixed_update(1/60)
system->update(deltaTime)
scheduler IMMEDIATE events
wm->swap()
// on exit: ~Application() ends Engine, Time, WindowManagerThe destructor handles cleanup automatically - no explicit shutdown call is needed.
Accessing From Anywhere
Use the static accessor to retrieve the singleton from any context:
cpp
Application* app = Application::get();Explicit Teardown
If you need to destroy the application before run() exits (e.g. in a headless context), call:
cpp
Application::end();This deletes the instance and triggers the same destructor cleanup as the normal run loop exit.