aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/RenderSystem.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-31 18:41:30 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-31 18:41:30 +0100
commit8e3367b186e60eb1e33bf58a066823cb00a7566e (patch)
treec4038a31993767276efec5fa1b1a37dff3b79465 /src/crepe/RenderSystem.cpp
parentb7df77d6cc26cb9ee46891d7108f01734b3104dd (diff)
parent35ef3ba91ce9e00466508f2388f4c1dd2321b505 (diff)
Merge branch 'master' into poc/audio-miniaudio
Diffstat (limited to 'src/crepe/RenderSystem.cpp')
-rw-r--r--src/crepe/RenderSystem.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/crepe/RenderSystem.cpp b/src/crepe/RenderSystem.cpp
new file mode 100644
index 0000000..fae93f0
--- /dev/null
+++ b/src/crepe/RenderSystem.cpp
@@ -0,0 +1,42 @@
+#include <functional>
+#include <vector>
+
+#include "api/Sprite.h"
+#include "api/Transform.h"
+#include "util/log.h"
+
+#include "ComponentManager.h"
+#include "RenderSystem.h"
+#include "SDLContext.h"
+
+using namespace crepe;
+using namespace crepe::api;
+
+RenderSystem::RenderSystem() { dbg_trace(); }
+
+RenderSystem::~RenderSystem() { dbg_trace(); }
+
+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>();
+
+ SDLContext & render = SDLContext::get_instance();
+ render.clear_screen();
+
+ for (const Sprite & sprite : sprites) {
+ std::vector<std::reference_wrapper<Transform>> transforms
+ = mgr.get_components_by_id<Transform>(sprite.game_object_id);
+ for (const Transform & transform : transforms) {
+ render.draw(sprite, transform);
+ }
+ }
+ render.present_screen();
+}