app

class Application

The main application class.

Think of this like an aggregate of Systems, You register a System with this, then it’ll tick every “application frame”.

To make your own applications:

  • Make a subclass of Application,.

  • Do the required initialization work for your own application in its constructor.

  • Construct systems derived from lt::app::System.

  • Register them to be ticked via register_system.

  • Eventually, unregister every system via unregister_system, when wishing to exit the app.

  • The gmae_loop should terminate once all systems are unregistered

Note

No main function is provided, you must implement your own, and at the end call game_loop to start your application/game.

Subclassed by lt::Mirror

Public Functions

i32 game_loop()

Where the magic happens.

bool register_system(ref<app::ISystem> system)

Adds a system to the app.

This will result in system->tick() to be called on every game_loop() iteration, systems are ticked in order that they were registered.

Returns:

Whether the system was succesfully registered or not.

bool unregister_system(ref<app::ISystem> system)

Removes a system from the app.

This will result in system->tick() to NO LONGER be called on every game_loop() iteration.

Returns:

Whether the system was succesfully unregistered or not.

class ISystem

The base, pure-virtual class for creating systems.

Subclassed by lt::MirrorSystem, lt::input::System, lt::renderer::System, lt::surface::System

struct TickInfo

Information required to tick a system.

Note

May be used across an entire application-frame (consisting of multiple systems ticking)

Public Types

using Timepoint_T = std::chrono::time_point<std::chrono::steady_clock>

Timepoint type.

using Duration_T = std::chrono::duration<f64>

Duration type.

Public Members

Duration_T delta_time = {}

Duration since previous tick’s end_time to current tick’s start_time.

Duration_T budget = {}

Maximum duration the system is expected to finish ticking in.

  • if end_time - start_time > budget -> the system exceeded its ticking budget.

  • else end_time - start_time < budget -> the system ticked properly.

In other words, end_time is expected to be less than start_time + budget.

Note

end_time comes from TickResult

Timepoint_T start_time

Exact time when ticking started.

struct TickResult

Information about how a system’s tick performed.

Public Types

using Timepoint_T = std::chrono::time_point<std::chrono::steady_clock>

Timepoint type.

using Duration_T = std::chrono::duration<f64>

Duration type.

Public Members

TickInfo info

The info supplied to the system for ticking.

Duration_T duration = {}

Equivalent to end_time - info.start_time.

Timepoint_T end_time

Exact timepoint when ticking ended.