diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:27:58 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-18 14:27:58 +0100 |
commit | 03e493012edc106b00bc5676c1830ce2085a7ff9 (patch) | |
tree | ff06d4314552e82f98d08c52d7a15edb3a74436e /src/crepe/system/RenderSystem.cpp | |
parent | 21f5b66d0bcc13d903800adf3bb614e380ff8591 (diff) | |
parent | 121b64b1cb6cfead5814070c8b0185d3d7308095 (diff) |
Merge remote-tracking branch 'origin/master' into niels/sorting_rendering
Diffstat (limited to 'src/crepe/system/RenderSystem.cpp')
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 718036c..aa9910b 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -7,33 +7,19 @@ #include "../api/Sprite.h" #include "../api/Transform.h" #include "../facade/SDLContext.h" -#include "../util/log.h" -#include "Asset.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(); - std::vector<std::reference_wrapper<Camera>> cameras - = mgr.get_components_by_type<Camera>(); + ComponentManager & mgr = this->component_manager; + + std::vector<std::reference_wrapper<Camera>> cameras = mgr.get_components_by_type<Camera>(); for (Camera & cam : cameras) { SDLContext::get_instance().camera(cam); @@ -63,6 +49,7 @@ RenderSystem::sort(std::vector<std::reference_wrapper<Sprite>> & objs) { } void RenderSystem::render_sprites() { + ComponentManager & mgr = this->component_manager; ComponentManager & mgr = ComponentManager::get_instance(); @@ -72,8 +59,7 @@ void RenderSystem::render_sprites() { SDLContext & render = SDLContext::get_instance(); for (const Sprite & sprite : sorted_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); } } |