aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/RenderSystem.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-19 20:49:09 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-19 20:49:09 +0100
commit0f9f379a4dec7ad9d1dce30af5e2259931692c5f (patch)
treed84a76559d99fd6a3541d0087538564d79e39470 /src/crepe/system/RenderSystem.cpp
parent38a2476bcfa41b6d83a9a72d35f5acb684dc87fd (diff)
parent0476a8e9dbe7afb422862f7b1c15aaed7f3c416e (diff)
merge with master
Diffstat (limited to 'src/crepe/system/RenderSystem.cpp')
-rw-r--r--src/crepe/system/RenderSystem.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 10211a3..fa3d0de 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -5,33 +5,19 @@
#include "../api/Sprite.h"
#include "../api/Transform.h"
#include "../facade/SDLContext.h"
-#include "../util/log.h"
+#include "../util/Log.h"
#include "RenderSystem.h"
using namespace crepe;
-RenderSystem::RenderSystem() { dbg_trace(); }
+void RenderSystem::clear_screen() const { SDLContext::get_instance().clear_screen(); }
-RenderSystem::~RenderSystem() { dbg_trace(); }
-
-RenderSystem & RenderSystem::get_instance() {
- static RenderSystem instance;
- return instance;
-}
-
-void RenderSystem::clear_screen() const {
- SDLContext::get_instance().clear_screen();
-}
-
-void RenderSystem::present_screen() const {
- SDLContext::get_instance().present_screen();
-}
+void RenderSystem::present_screen() const { SDLContext::get_instance().present_screen(); }
void RenderSystem::update_camera() {
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
- std::vector<std::reference_wrapper<Camera>> cameras
- = mgr.get_components_by_type<Camera>();
+ std::vector<std::reference_wrapper<Camera>> cameras = mgr.get_components_by_type<Camera>();
for (Camera & cam : cameras) {
SDLContext::get_instance().camera(cam);
@@ -39,16 +25,13 @@ void RenderSystem::update_camera() {
}
}
void RenderSystem::render_sprites() const {
+ ComponentManager & mgr = this->component_manager;
- ComponentManager & mgr = ComponentManager::get_instance();
-
- std::vector<std::reference_wrapper<Sprite>> sprites
- = mgr.get_components_by_type<Sprite>();
+ std::vector<std::reference_wrapper<Sprite>> sprites = mgr.get_components_by_type<Sprite>();
SDLContext & render = SDLContext::get_instance();
for (const Sprite & sprite : sprites) {
- auto transforms
- = mgr.get_components_by_id<Transform>(sprite.game_object_id);
+ auto transforms = mgr.get_components_by_id<Transform>(sprite.game_object_id);
render.draw(sprite, transforms[0], *curr_cam);
}
}