add new frame_finalize stage to game loop

This commit is contained in:
2019-10-22 02:59:52 +07:00
parent ef24a39646
commit 5de8190e37
4 changed files with 17 additions and 3 deletions

View File

@@ -53,6 +53,7 @@ namespace e2d
virtual void shutdown() noexcept;
virtual bool frame_tick();
virtual void frame_render();
virtual void frame_finalize();
};
//

View File

@@ -29,6 +29,8 @@ namespace e2d::systems
struct pre_render_event {};
struct post_render_event {};
struct frame_finalize_event {};
using update_system = ecs::system<update_event>;
using post_update_system = ecs::system<post_update_event>;

View File

@@ -60,6 +60,9 @@ namespace e2d
void engine::application::frame_render() {
}
void engine::application::frame_finalize() {
}
//
// engine::debug_parameters
//
@@ -501,6 +504,7 @@ namespace e2d
the<window>().swap_buffers();
}
app->frame_finalize();
state_->calculate_end_frame_timers();
} catch ( ... ) {
app->shutdown();

View File

@@ -51,10 +51,10 @@ namespace
.add_system<flipbook_system>())
.feature<struct label_feature>(ecs::feature()
.add_system<label_system>())
.feature<struct spine_feature>(ecs::feature()
.add_system<spine_system>())
.feature<struct render_feature>(ecs::feature()
.add_system<render_system>());
.add_system<render_system>())
.feature<struct spine_feature>(ecs::feature()
.add_system<spine_system>());
return !application_ || application_->initialize();
}
@@ -84,6 +84,13 @@ namespace
registry.process_event(systems::render_event{});
registry.process_event(systems::post_render_event{});
}
void frame_finalize() final {
world& w = the<world>();
ecs::registry& registry = w.registry();
registry.process_event(systems::frame_finalize_event{});
w.finalize_instances();
}
private:
starter::application_uptr application_;
};