diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-08 11:44:21 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-08 11:44:21 +0100 |
commit | 9432900158e6a31815345fcf0af8d28ae34c6da9 (patch) | |
tree | 36f799da46ba8f5e921349d0f004b08d6d2f29ea /src/crepe/api/Texture.h | |
parent | 1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (diff) |
code style
Diffstat (limited to 'src/crepe/api/Texture.h')
-rw-r--r-- | src/crepe/api/Texture.h | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index 9a86f6f..6d99a93 100644 --- a/src/crepe/api/Texture.h +++ b/src/crepe/api/Texture.h @@ -3,31 +3,75 @@ // FIXME: this header can't be included because this is an API header, and SDL2 // development headers won't be bundled with crepe. Why is this facade in the // API namespace? + #include <SDL2/SDL_render.h> #include <memory> #include "Asset.h" namespace crepe { + +//! Forward declaration of SDLContext class. class SDLContext; -} -namespace crepe { +//! Forward declaration of Animator class. +class Animator; +/** + * \class Texture + * \brief Manages texture loading and properties. + * + * 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 { public: - Texture(const char * src); - Texture(std::unique_ptr<Asset> res); - ~Texture(); + /** + * \brief Constructs a Texture from a file path. + * \param src Path to the image file to be loaded as a texture. + */ + Texture(const char * src); + + /** + * \brief Constructs a Texture from an Asset resource. + * \param res Unique pointer to an Asset resource containing texture data. + */ + Texture(std::unique_ptr<Asset> res); + + /** + * \brief Destroys the Texture instance, freeing associated resources. + */ + ~Texture(); + + /** + * \brief Gets the width of the texture. + * \return Width of the texture in pixels. + */ + int get_width() const; + + /** + * \brief Gets the height of the texture. + * \return Height of the texture in pixels. + */ + int get_height() const; private: - void load(std::unique_ptr<Asset> res); + /** + * \brief Loads the texture from an Asset resource. + * \param res Unique pointer to an Asset resource to load the texture from. + */ + void load(std::unique_ptr<Asset> res); private: - SDL_Texture * texture = nullptr; + //! The texture of the class from the library + SDL_Texture * texture = nullptr; + + //! Grants SDLContext access to private members. + friend class SDLContext; - friend class crepe::SDLContext; + //! Grants Animator access to private members. + friend class Animator; }; } // namespace crepe |