diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 19:19:25 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 19:19:25 +0100 |
commit | bb0dba6b2a84a8bcbb1e07a14f015f73408d460c (patch) | |
tree | 0d669bc5e88544749964d4639d27575545fbabe1 /src/crepe/system/RenderSystem.cpp | |
parent | 46716724df7697fa789329a62f7a5444ceed5585 (diff) | |
parent | 3a690f7d0c91b92b9cdfe62f44dba8db90142abc (diff) |
Merge branch 'master' of github.com:lonkaars/crepe into jaro/particle-system-master
Diffstat (limited to 'src/crepe/system/RenderSystem.cpp')
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 5a07cc2..10211a3 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -20,7 +20,25 @@ RenderSystem & RenderSystem::get_instance() { return instance; } -void RenderSystem::update() { +void RenderSystem::clear_screen() const { + SDLContext::get_instance().clear_screen(); +} + +void RenderSystem::present_screen() const { + SDLContext::get_instance().present_screen(); +} +void RenderSystem::update_camera() { + ComponentManager & mgr = ComponentManager::get_instance(); + + std::vector<std::reference_wrapper<Camera>> cameras + = mgr.get_components_by_type<Camera>(); + + for (Camera & cam : cameras) { + SDLContext::get_instance().camera(cam); + this->curr_cam = &cam; + } +} +void RenderSystem::render_sprites() const { ComponentManager & mgr = ComponentManager::get_instance(); @@ -28,14 +46,16 @@ void RenderSystem::update() { = mgr.get_components_by_type<Sprite>(); SDLContext & render = SDLContext::get_instance(); - render.clear_screen(); - for (const Sprite & sprite : sprites) { - std::vector<std::reference_wrapper<Transform>> transforms + auto transforms = mgr.get_components_by_id<Transform>(sprite.game_object_id); - for (const Transform & transform : transforms) { - render.draw(sprite, transform); - } + render.draw(sprite, transforms[0], *curr_cam); } - render.present_screen(); +} + +void RenderSystem::update() { + this->clear_screen(); + this->update_camera(); + this->render_sprites(); + this->present_screen(); } |