diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-08 14:29:25 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-08 14:29:25 +0100 |
commit | 63bcd54e0e0ea64cfef5950568b4253d5dae5c1e (patch) | |
tree | 24f1f251259ca46566a4694b765dc4e99ee264ab /src/crepe/api/Texture.h | |
parent | 5c3ce63558f2d5dec06a124773f910d783bb22aa (diff) |
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
Diffstat (limited to 'src/crepe/api/Texture.h')
-rw-r--r-- | src/crepe/api/Texture.h | 15 |
1 files changed, 6 insertions, 9 deletions
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 <memory> #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<SDL_Texture, std::function<void(SDL_Texture *)>> texture); + private: //! The texture of the class from the library std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> texture; + bool loaded = false; + //! Grants SDLContext access to private members. friend class SDLContext; |