diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-10-23 19:56:28 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-10-23 19:56:28 +0200 |
commit | c9246515fe785563411e9170aedd0231165ab988 (patch) | |
tree | e3b713e1e1200b26861e951e0b1ac4ab64d4eab6 /src/crepe/RenderSystem.cpp | |
parent | adb7dfabec4811566308cd072e0542cd7eae8cc1 (diff) |
rendering and assetmanager
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(); - } |