26#include <ospp/event.h>
48std::atomic<bool> is_shutting_down{
false};
50void update_input_zone(
const renderer& rend, input_system&
input)
52 const auto& window = rend.get_main_window();
55 auto main_pos = window->get_window().get_position();
56 auto main_size = window->get_window().get_size();
59 window_zone.
x = main_pos.x;
60 window_zone.y = main_pos.y;
61 window_zone.w = int(main_size.w);
62 window_zone.h = int(main_size.h);
64 input.manager.set_window_zone(window_zone);
69void engine_interrupt_handler(
const crash::signal_info& info)
71 APPLOG_INFO(
"User interrupt ({}) -> {}", info.signal_number, info.signal_name);
78void engine_termination_handler(
const crash::signal_info& info)
80 APPLOG_INFO(
"Termination signal ({}) -> {}", info.signal_number, info.signal_name);
88void engine_crash_handler(
const crash::signal_info& info,
const crash::trace_info& trace)
91 APPLOG_CRITICAL(
"Crash signal ({}) -> {}\n{}", info.signal_number, info.signal_name, trace.formatted_trace);
99void engine_exception_handler(
const crash::exception_info& info,
const crash::trace_info& trace)
101 APPLOG_CRITICAL(
"{}\n{}", info.exception_message, trace.formatted_trace);
113 return *context_ptr();
119 context_ptr() = &ctx;
121 fs::path binary_path = fs::executable_path(parser.app_name().c_str()).parent_path();
124 fs::path engine_data = binary_path /
"data" /
"engine";
129 .warning_logger = [](
const std::string& log,
const hpp::source_location& loc)
131 APPLOG_WARNING_LOC(loc.file_name(),
int(loc.line()), loc.function_name(),
"Serialization {}", log);
141 .interrupt_handler = engine_interrupt_handler,
142 .termination_handler = engine_termination_handler,
143 .crash_handler = engine_crash_handler,
144 .exception_handler = engine_exception_handler,
183 ls.begin_module(
"Renderer");
184 if(!ls.check(ctx.get_cached<
renderer>().
init(ctx, parser)))
189 ls.begin_module(
"Audio");
195 ls.begin_module(
"Assets");
210 if(!ls.check(ctx.get_cached<
ecs>().
init(ctx)))
215 ls.begin_module(
"Rendering");
221 ls.begin_module(
"Transforms");
227 ls.begin_module(
"Camera");
233 ls.begin_module(
"Reflection Probes");
239 ls.begin_module(
"Sky Lighting");
245 ls.begin_module(
"Models");
251 ls.begin_module(
"Animation");
257 ls.begin_module(
"Physics");
263 ls.begin_module(
"Particles");
269 ls.begin_module(
"Input");
275 ls.begin_module(
"Scripting");
281 ls.begin_module(
"UI");
287 ls.begin_module(
"Play Mode");
293 ls.begin_module(
"Defaults");
436 bool empty = ctx.empty();
451 auto& ev = ctx.get_cached<
events>();
452 auto& rend = ctx.get_cached<
renderer>();
453 auto& thr = ctx.get_cached<
threader>();
464 sim.run_one_frame(
true);
466 auto dt =
sim.get_delta_time();
467 auto& play = ctx.get_cached<
play_mode>();
472 if(play.is_simulation_running() && play.frames_running() == 0)
482 update_input_zone(rend,
input);
484 input.manager.before_events_update();
486 bool should_quit =
false;
491 while(os::poll_event(e))
493 ev.on_os_event(ctx, e);
495 input.manager.on_os_event(e);
497 should_quit = rend.get_main_window() ==
nullptr || is_shutting_down;
507 input.manager.after_events_update();
512 ctx.get_cached<
play_mode>().set_active(ctx,
false);
513 is_shutting_down =
false;
519 ev.on_frame_begin(ctx, dt);
530 ev.on_frame_update(ctx, dt);
540 ev.on_frame_before_render(ctx, dt);
545 ev.on_frame_render(ctx, dt);
550 ev.on_frame_end(ctx, dt);
553 if(play.is_simulation_running())
555 play.on_simulation_frame();
565 is_shutting_down =
true;
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
Manages assets, including loading, unloading, and storage.
auto init(rtti::context &ctx) -> bool
Initializes the asset manager with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the asset manager with the given context.
Manages the audio operations and integrates with the audio backend.
auto init(rtti::context &ctx) -> bool
Initializes the audio system with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the audio system with the given context.
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
System that manages and updates particle emitters in the ECS.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the particle system.
auto init(rtti::context &ctx) -> bool
Initializes the particle system.
Manages the physics operations using the specified backend.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the physics system with the given context.
auto init(rtti::context &ctx) -> bool
Initializes the physics system with the given context.
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
Base class for different rendering paths in the ACE framework.
auto init(rtti::context &ctx) -> bool
Initializes the rendering path with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the rendering path with the given context.
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
#define APPLOG_CRITICAL(...)
#define APPLOG_WARNING_LOC(FILE_LOC, LINE_LOC, FUNC_LOC,...)
bool add_path_protocol(const std::string &protocol, const path &dir)
Allows us to map a protocol to a specific directory. A path protocol gives the caller the ability to ...
void update(seq_id_t id, duration_t delta)
Updates the elapsed duration of a specific action.
void init(const init_data &data)
auto install_handlers(const crash_handlers &handlers) -> void
Install comprehensive crash handlers.
auto get_app_profiler() -> performance_profiler *
#define APP_SCOPE_PERF(name_literal)
Create a scoped performance timer that records to the timeline profiler. Only accepts string literals...
Provides default initialization and creation functions for various entities and assets.
static auto init(rtti::context &ctx) -> bool
Initializes default settings and assets.
static auto deinit(rtti::context &ctx) -> bool
Deinitializes default settings and assets.
Manages the entity-component-system (ECS) operations for the ACE framework.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the ECS with the given context.
auto init(rtti::context &ctx) -> bool
Initializes the ECS with the given context.
static auto process() -> int
static auto init_systems(const cmd_line::parser &parser) -> bool
static auto destroy() -> bool
static auto context() -> rtti::context &
static auto deinit() -> bool
static auto interrupt() -> bool
static auto create(rtti::context &ctx, cmd_line::parser &parser) -> bool
static auto init_core(const cmd_line::parser &parser) -> bool
void begin_module(const std::string &module_name)
Owns play-mode state and orchestrates the splash -> running lifecycle.
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx, const cmd_line::parser &parser) -> bool
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx, const cmd_line::parser &parser) -> bool
Class responsible for timers.
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
System responsible for managing user interface components and rendering.
auto init(rtti::context &ctx) -> bool
Initializes the UI system with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the UI system with the given context.