diff options
author | jaroWMR <jarorutjes07@gmail.com> | 2024-10-23 20:03:18 +0200 |
---|---|---|
committer | jaroWMR <jarorutjes07@gmail.com> | 2024-10-23 20:03:18 +0200 |
commit | 3789031ac520b393969bbedd55444e3fd2b7f1fa (patch) | |
tree | 212f78845ae1f8972a96636e8425b080a64c7e05 /src/crepe/RenderSystem.cpp | |
parent | edbb6c892299e3b7f93638abcc9e55b2cfce2358 (diff) | |
parent | c9246515fe785563411e9170aedd0231165ab988 (diff) |
merge with niels/rendering
Diffstat (limited to 'src/crepe/RenderSystem.cpp')
-rw-r--r-- | src/crepe/RenderSystem.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/crepe/RenderSystem.cpp b/src/crepe/RenderSystem.cpp index 6aae3bb..b5503d3 100644 --- a/src/crepe/RenderSystem.cpp +++ b/src/crepe/RenderSystem.cpp @@ -6,7 +6,6 @@ #include "api/Sprite.h" #include "api/Transform.h" #include "util/log.h" -#include <cstddef> #include <functional> #include <vector> @@ -17,25 +16,27 @@ RenderSystem::RenderSystem() { dbg_trace(); } RenderSystem::~RenderSystem() { dbg_trace(); } -RenderSystem& RenderSystem::get_instance(){ +RenderSystem & RenderSystem::get_instance() { static RenderSystem instance; return instance; } void RenderSystem::update() { - ComponentManager& mgr = ComponentManager::get_instance(); - - std::vector<std::reference_wrapper<Sprite>> sprites = mgr.get_components_by_type<Sprite>(); - std::vector<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_type<Transform>(); + ComponentManager & mgr = ComponentManager::get_instance(); - SdlContext& render = SdlContext::get_instance(); + std::vector<std::reference_wrapper<Sprite>> sprites + = mgr.get_components_by_type<Sprite>(); + + SdlContext & render = SdlContext::get_instance(); render.clear_screen(); - for (size_t i = 0; i < sprites.size(); ++i) { - render.draw(sprites[i].get(), transforms[i].get()); - } + for (const Sprite & sprite : sprites) { + std::vector<std::reference_wrapper<Transform>> transforms = mgr.get_components_by_id<Transform>(sprite.gameObjectId); + for (const Transform& transform : transforms) { + render.draw(sprite, transform); + } + } render.present_screen(); - } |