From 07adbf48e0781cd8c95983c1871a84b6160ee5bf Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 14 Nov 2024 13:57:13 +0100 Subject: implement asset + more WIP audio system --- src/crepe/facade/SDLContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/crepe/facade/SDLContext.cpp') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index a68d940..5527803 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -159,7 +159,7 @@ SDLContext::texture_from_path(const std::string & path) { SDL_Surface * tmp = IMG_Load(path.c_str()); if (tmp == nullptr) { - tmp = IMG_Load("../asset/texture/ERROR.png"); + tmp = IMG_Load("asset/texture/ERROR.png"); } std::unique_ptr> -- cgit v1.2.3 From dc7a1c3d669b901adb9c520b4a76a868a3cc94e9 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 8 Dec 2024 12:54:35 +0100 Subject: fixed inputtest test because of adjusting inputtest values. however inputtest passes while sdlcontext returns pixel coordinates????? --- src/crepe/facade/SDLContext.cpp | 4 ++++ src/test/CMakeLists.txt | 2 +- src/test/InputTest.cpp | 16 ++++++++-------- src/test/Profiling.cpp | 16 +++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src/crepe/facade/SDLContext.cpp') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 4cc2206..e010ac3 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -324,6 +325,8 @@ SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) { render_scale.x = render_scale.y = scale; } + //cout << render_scale.x << " " << bar_size.x << " " << bar_size.y << endl; + SDL_SetRenderDrawColor(this->game_renderer.get(), cam_data.bg_color.r, cam_data.bg_color.g, cam_data.bg_color.b, cam_data.bg_color.a); @@ -374,6 +377,7 @@ ivec2 SDLContext::get_size(const Texture & ctx) { void SDLContext::delay(int ms) const { SDL_Delay(ms); } + std::vector SDLContext::get_events() { std::vector event_list; SDL_Event event; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index c9cbac5..eae59f2 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -13,8 +13,8 @@ target_sources(test_main PUBLIC ValueBrokerTest.cpp DBTest.cpp Vector2Test.cpp + Profiling.cpp InputTest.cpp ScriptEventTest.cpp ScriptSceneTest.cpp - Profiling.cpp ) diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index a7c0157..73eaab3 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -61,7 +61,7 @@ protected: TEST_F(InputTest, MouseDown) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool mouse_triggered = false; EventHandler on_mouse_down = [&](const MousePressEvent & event) { @@ -91,7 +91,7 @@ TEST_F(InputTest, MouseDown) { TEST_F(InputTest, MouseUp) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_mouse_release = [&](const MouseReleaseEvent & e) { @@ -119,7 +119,7 @@ TEST_F(InputTest, MouseUp) { TEST_F(InputTest, MouseMove) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_mouse_move = [&](const MouseMoveEvent & e) { @@ -149,7 +149,7 @@ TEST_F(InputTest, MouseMove) { TEST_F(InputTest, KeyDown) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; @@ -180,7 +180,7 @@ TEST_F(InputTest, KeyDown) { TEST_F(InputTest, KeyUp) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_key_release = [&](const KeyReleaseEvent & event) { @@ -204,7 +204,7 @@ TEST_F(InputTest, KeyUp) { TEST_F(InputTest, MouseClick) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool on_click_triggered = false; EventHandler on_mouse_click = [&](const MouseClickEvent & event) { @@ -225,7 +225,7 @@ TEST_F(InputTest, MouseClick) { TEST_F(InputTest, testButtonClick) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; @@ -252,7 +252,7 @@ TEST_F(InputTest, testButtonClick) { TEST_F(InputTest, testButtonHover) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index c753bca..d40ee1d 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,7 +1,3 @@ -#include "manager/Mediator.h" -#include "system/ParticleSystem.h" -#include "system/PhysicsSystem.h" -#include "system/RenderSystem.h" #include #include #include @@ -21,6 +17,10 @@ #include #include #include +#include "manager/Mediator.h" +#include "system/ParticleSystem.h" +#include "system/PhysicsSystem.h" +#include "system/RenderSystem.h" using namespace std; using namespace std::chrono_literals; @@ -47,7 +47,7 @@ public: // Minimum amount to let test pass const int min_gameobject_count = 100; // Maximum amount to stop test - const int max_gameobject_count = 150; + const int max_gameobject_count = 1000; // Amount of times a test runs to calculate average const int average = 5; // Maximum duration to stop test @@ -98,10 +98,8 @@ public: std::chrono::microseconds run_all_systems() { std::chrono::microseconds total_microseconds = 0us; total_microseconds += time_function("PhysicsSystem", [&]() { physics_sys.update(); }); - total_microseconds - += time_function("CollisionSystem", [&]() { collision_sys.update(); }); - total_microseconds - += time_function("ParticleSystem", [&]() { particle_sys.update(); }); + //total_microseconds += time_function("CollisionSystem", [&]() { collision_sys.update(); }); + total_microseconds += time_function("ParticleSystem", [&]() { particle_sys.update(); }); total_microseconds += time_function("RenderSystem", [&]() { render_sys.update(); }); return total_microseconds; } -- cgit v1.2.3 From 63bcd54e0e0ea64cfef5950568b4253d5dae5c1e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 8 Dec 2024 14:29:25 +0100 Subject: removed singleton from SDLContext, problem now is cannot call functionalities in the constructor sprite and animator and texture because it can only be filled at rendersystem call --- src/crepe/api/Config.h | 2 +- src/crepe/api/LoopManager.h | 7 ++-- src/crepe/api/LoopTimer.cpp | 3 +- src/crepe/api/Sprite.cpp | 12 +++---- src/crepe/api/Sprite.h | 5 +-- src/crepe/api/Texture.cpp | 23 ++++--------- src/crepe/api/Texture.h | 15 ++++----- src/crepe/facade/SDLContext.cpp | 18 +++++----- src/crepe/facade/SDLContext.h | 62 +++++++++++++++-------------------- src/crepe/manager/EventManager.cpp | 2 ++ src/crepe/manager/Mediator.h | 4 +-- src/crepe/manager/ResourceManager.cpp | 2 +- src/crepe/manager/SceneManager.cpp | 3 ++ src/crepe/system/InputSystem.cpp | 6 +++- src/crepe/system/RenderSystem.cpp | 11 +++++++ src/example/rendering_particle.cpp | 9 +++-- 16 files changed, 95 insertions(+), 89 deletions(-) (limited to 'src/crepe/facade/SDLContext.cpp') diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index 6472270..73c9a4e 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -26,7 +26,7 @@ struct Config final { * * Only messages with equal or higher priority than this value will be logged. */ - Log::Level level = Log::Level::INFO; + Log::Level level = Log::Level::TRACE; /** * \brief Colored log output * diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h index d8910a0..8a30602 100644 --- a/src/crepe/api/LoopManager.h +++ b/src/crepe/api/LoopManager.h @@ -8,6 +8,7 @@ #include "../system/System.h" #include "LoopTimer.h" +#include "manager/ResourceManager.h" namespace crepe { @@ -96,8 +97,10 @@ private: //! Scene manager instance SceneManager scene_manager{mediator}; - //! SDL context \todo no more singletons! - SDLContext & sdl_context = SDLContext::get_instance(); + SDLContext sdl_context {mediator}; + + ResourceManager res_man {mediator}; + //! Loop timer \todo no more singletons! LoopTimer & loop_timer = LoopTimer::get_instance(); diff --git a/src/crepe/api/LoopTimer.cpp b/src/crepe/api/LoopTimer.cpp index 15a0e3a..40fc94e 100644 --- a/src/crepe/api/LoopTimer.cpp +++ b/src/crepe/api/LoopTimer.cpp @@ -1,6 +1,5 @@ #include -#include "../facade/SDLContext.h" #include "../util/Log.h" #include "LoopTimer.h" @@ -67,7 +66,7 @@ void LoopTimer::enforce_frame_rate() { = std::chrono::duration_cast(this->frame_target_time - frame_duration); if (delay_time.count() > 0) { - SDLContext::get_instance().delay(delay_time.count()); + //SDLContext::get_instance().delay(delay_time.count()); } } diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index cc0e20a..bae5ad9 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -2,25 +2,25 @@ #include #include "../util/Log.h" +#include "api/Asset.h" #include "Component.h" #include "Sprite.h" -#include "Texture.h" #include "types.h" using namespace std; using namespace crepe; -Sprite::Sprite(game_object_id_t id, Texture & texture, const Sprite::Data & data) +Sprite::Sprite(game_object_id_t id, const Asset & texture, const Sprite::Data & data) : Component(id), - texture(std::move(texture)), + source(texture), data(data) { dbg_trace(); - this->mask.w = this->texture.get_size().x; - this->mask.h = this->texture.get_size().y; - this->aspect_ratio = static_cast(this->mask.w) / this->mask.h; + //this->mask.w = this->texture.get_size().x; + //this->mask.h = this->texture.get_size().y; + //this->aspect_ratio = static_cast(this->mask.w) / this->mask.h; } Sprite::~Sprite() { dbg_trace(); } diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index dbf41e4..ec120c0 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -4,6 +4,7 @@ #include "Color.h" #include "Texture.h" +#include "api/Asset.h" #include "types.h" namespace crepe { @@ -74,11 +75,11 @@ public: * \param texture asset of the image * \param ctx all the sprite data */ - Sprite(game_object_id_t id, Texture & texture, const Data & data); + Sprite(game_object_id_t id, const Asset & texture, const Data & data); ~Sprite(); //! Texture used for the sprite - const Texture texture; + const Asset source; Data data; diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index 2b56271..9d8e02d 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -1,16 +1,16 @@ -#include "../facade/SDLContext.h" #include "../util/Log.h" #include "Asset.h" +#include "Resource.h" #include "Texture.h" #include "types.h" +#include using namespace crepe; using namespace std; -Texture::Texture(const Asset & src) { +Texture::Texture(const Asset & src) : Resource(src) { dbg_trace(); - this->load(src); } Texture::~Texture() { @@ -18,21 +18,12 @@ Texture::~Texture() { this->texture.reset(); } -Texture::Texture(Texture && other) noexcept : texture(std::move(other.texture)) {} - -Texture & Texture::operator=(Texture && other) noexcept { - if (this != &other) { - texture = std::move(other.texture); - } - return *this; -} - -void Texture::load(const Asset & res) { - SDLContext & ctx = SDLContext::get_instance(); - this->texture = ctx.texture_from_path(res.get_path()); +void Texture::load(std::unique_ptr> texture) { + this->texture = std::move(texture); + this->loaded = true; } ivec2 Texture::get_size() const { if (this->texture == nullptr) return {}; - return SDLContext::get_instance().get_size(*this); + return {}; } diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index 1817910..f9c7919 100644 --- a/src/crepe/api/Texture.h +++ b/src/crepe/api/Texture.h @@ -8,6 +8,7 @@ #include #include "Asset.h" +#include "Resource.h" #include "types.h" namespace crepe { @@ -22,7 +23,7 @@ class Animator; * The Texture class is responsible for loading an image from a source and providing access to * its dimensions. Textures can be used for rendering. */ -class Texture { +class Texture : public Resource { public: /** @@ -35,12 +36,6 @@ public: * \brief Destroys the Texture instance, freeing associated resources. */ ~Texture(); - // FIXME: this constructor shouldn't be necessary because this class doesn't manage memory - - Texture(Texture && other) noexcept; - Texture & operator=(Texture && other) noexcept; - Texture(const Texture &) = delete; - Texture & operator=(const Texture &) = delete; /** * \brief Gets the width and height of the texture. @@ -53,12 +48,14 @@ private: * \brief Loads the texture from an Asset resource. * \param res Unique pointer to an Asset resource to load the texture from. */ - void load(const Asset & res); - + void load(std::unique_ptr> texture); + private: //! The texture of the class from the library std::unique_ptr> texture; + bool loaded = false; + //! Grants SDLContext access to private members. friend class SDLContext; diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 4cc2206..85257d6 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -22,19 +23,16 @@ #include "../util/Log.h" #include "SDLContext.h" +#include "manager/Manager.h" +#include "manager/Mediator.h" #include "types.h" using namespace crepe; using namespace std; -SDLContext & SDLContext::get_instance() { - static SDLContext instance; - return instance; -} - -SDLContext::SDLContext() { +SDLContext::SDLContext(Mediator & mediator) : Manager(mediator){ dbg_trace(); - + mediator.sdl_context = *this; if (SDL_Init(SDL_INIT_VIDEO) != 0) { throw runtime_error(format("SDLContext: SDL_Init error: {}", SDL_GetError())); } @@ -261,6 +259,8 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { void SDLContext::draw(const RenderContext & ctx) { + if (!ctx.texture.loaded) ctx.texture.load(this->texture_from_path(ctx.sprite.source.get_path())); + const Sprite::Data & data = ctx.sprite.data; SDL_RendererFlip render_flip = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * data.flip.flip_x) @@ -276,8 +276,8 @@ void SDLContext::draw(const RenderContext & ctx) { double angle = ctx.angle + data.angle_offset; - this->set_color_texture(ctx.sprite.texture, ctx.sprite.data.color); - SDL_RenderCopyExF(this->game_renderer.get(), ctx.sprite.texture.texture.get(), &srcrect, + this->set_color_texture(ctx.texture, ctx.sprite.data.color); + SDL_RenderCopyExF(this->game_renderer.get(), ctx.texture.texture.get(), &srcrect, &dstrect, angle, NULL, render_flip); } diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index e232511..d95ebec 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -14,14 +14,16 @@ #include "api/Color.h" #include "api/KeyCodes.h" #include "api/Sprite.h" -#include "api/Texture.h" #include "api/Transform.h" + +#include "manager/Manager.h" +#include "manager/Mediator.h" #include "types.h" namespace crepe { -class LoopManager; -class InputSystem; +class Texture; + /** * \class SDLContext * \brief Facade for the SDL library @@ -29,7 +31,7 @@ class InputSystem; * SDLContext is a singleton that handles the SDL window and renderer, provides methods for * event handling, and rendering to the screen. It is never used directly by the user */ -class SDLContext { +class SDLContext : public Manager { public: //! data that the camera component cannot hold struct CameraValues { @@ -62,6 +64,7 @@ public: //! rendering data needed to render on screen struct RenderContext { const Sprite & sprite; + Texture & texture; const CameraValues & cam; const vec2 & pos; const double & angle; @@ -92,20 +95,27 @@ public: float scroll_delta = INFINITY; ivec2 rel_mouse_move = {-1, -1}; }; - /** - * \brief Gets the singleton instance of SDLContext. - * \return Reference to the SDLContext instance. - */ - static SDLContext & get_instance(); +public: SDLContext(const SDLContext &) = delete; SDLContext(SDLContext &&) = delete; SDLContext & operator=(const SDLContext &) = delete; SDLContext & operator=(SDLContext &&) = delete; -private: - //! will only use get_events - friend class InputSystem; +public: + /** + * \brief Constructs an SDLContext instance. + * Initializes SDL, creates a window and renderer. + */ + SDLContext(Mediator & mediator); + + /** + * \brief Destroys the SDLContext instance. + * Cleans up SDL resources, including the window and renderer. + */ + ~SDLContext(); + +public: /** * \brief Retrieves a list of all events from the SDL context. * @@ -139,9 +149,7 @@ private: */ MouseButton sdl_to_mousebutton(Uint8 sdl_button); -private: - //! Will only use delay - friend class LoopTimer; +public: /** * \brief Gets the current SDL ticks since the program started. * \return Current ticks in milliseconds as a constant uint64_t. @@ -157,23 +165,8 @@ private: */ void delay(int ms) const; -private: - /** - * \brief Constructs an SDLContext instance. - * Initializes SDL, creates a window and renderer. - */ - SDLContext(); - - /** - * \brief Destroys the SDLContext instance. - * Cleans up SDL resources, including the window and renderer. - */ - ~SDLContext(); - -private: - //! Will use the funtions: texture_from_path, get_width,get_height. - friend class Texture; +public: /** * \brief Loads a texture from a file path. * \param path Path to the image file. @@ -188,10 +181,7 @@ private: */ ivec2 get_size(const Texture & ctx); -private: - //! Will use draw,clear_screen, present_screen, camera. - friend class RenderSystem; - +public: /** * \brief Draws a sprite to the screen using the specified transform and camera. * \param RenderContext Reference to rendering data to draw @@ -210,7 +200,7 @@ private: */ CameraValues set_camera(const Camera & camera); -private: +public: //! the data needed to construct a sdl dst rectangle struct DestinationRectangleData { const Sprite & sprite; diff --git a/src/crepe/manager/EventManager.cpp b/src/crepe/manager/EventManager.cpp index 20f0dd3..17fe528 100644 --- a/src/crepe/manager/EventManager.cpp +++ b/src/crepe/manager/EventManager.cpp @@ -1,9 +1,11 @@ #include "EventManager.h" +#include "util/Log.h" using namespace crepe; using namespace std; EventManager & EventManager::get_instance() { + dbg_trace(); static EventManager instance; return instance; } diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h index ba0b41f..6a9e113 100644 --- a/src/crepe/manager/Mediator.h +++ b/src/crepe/manager/Mediator.h @@ -3,7 +3,6 @@ #include "../util/OptionalRef.h" // TODO: remove these singletons: -#include "../facade/SDLContext.h" #include "EventManager.h" #include "SaveManager.h" #include "api/LoopTimer.h" @@ -13,6 +12,7 @@ namespace crepe { class ComponentManager; class SceneManager; class ResourceManager; +class SDLContext; /** * Struct to pass references to classes that would otherwise need to be singletons down to @@ -27,12 +27,12 @@ class ResourceManager; * \warning This class should never be directly accessible from the API */ struct Mediator { + OptionalRef sdl_context; OptionalRef component_manager; OptionalRef scene_manager; OptionalRef save_manager = SaveManager::get_instance(); OptionalRef event_manager = EventManager::get_instance(); OptionalRef resource_manager; - OptionalRef sdl_context = SDLContext::get_instance(); OptionalRef timer = LoopTimer::get_instance(); }; diff --git a/src/crepe/manager/ResourceManager.cpp b/src/crepe/manager/ResourceManager.cpp index 7c01808..a141a46 100644 --- a/src/crepe/manager/ResourceManager.cpp +++ b/src/crepe/manager/ResourceManager.cpp @@ -6,8 +6,8 @@ using namespace crepe; using namespace std; ResourceManager::ResourceManager(Mediator & mediator) : Manager(mediator) { - mediator.resource_manager = *this; dbg_trace(); + mediator.resource_manager = *this; } ResourceManager::~ResourceManager() { dbg_trace(); } diff --git a/src/crepe/manager/SceneManager.cpp b/src/crepe/manager/SceneManager.cpp index 50a9fbb..a788c51 100644 --- a/src/crepe/manager/SceneManager.cpp +++ b/src/crepe/manager/SceneManager.cpp @@ -4,10 +4,13 @@ #include "ComponentManager.h" #include "SceneManager.h" +#include "util/Log.h" + using namespace crepe; using namespace std; SceneManager::SceneManager(Mediator & mediator) : Manager(mediator) { + dbg_trace(); mediator.scene_manager = *this; } diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index aaa8bdf..b36ec09 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -1,15 +1,19 @@ #include "../api/Button.h" #include "../manager/ComponentManager.h" #include "../manager/EventManager.h" +#include "facade/SDLContext.h" +#include "util/Log.h" #include "InputSystem.h" using namespace crepe; void InputSystem::update() { + dbg_trace(); ComponentManager & mgr = this->mediator.component_manager; EventManager & event_mgr = this->mediator.event_manager; - std::vector event_list = SDLContext::get_instance().get_events(); + SDLContext & context = this->mediator.sdl_context; + std::vector event_list = context.get_events(); RefVector