diff options
| author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 19:19:25 +0100 | 
|---|---|---|
| committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-10 19:19:25 +0100 | 
| commit | bb0dba6b2a84a8bcbb1e07a14f015f73408d460c (patch) | |
| tree | 0d669bc5e88544749964d4639d27575545fbabe1 /src/crepe/api/Texture.h | |
| parent | 46716724df7697fa789329a62f7a5444ceed5585 (diff) | |
| parent | 3a690f7d0c91b92b9cdfe62f44dba8db90142abc (diff) | |
Merge branch 'master' of github.com:lonkaars/crepe into jaro/particle-system-master
Diffstat (limited to 'src/crepe/api/Texture.h')
| -rw-r--r-- | src/crepe/api/Texture.h | 54 | 
1 files changed, 49 insertions, 5 deletions
diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index 9a86f6f..b89bc17 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 <functional>  #include <memory>  #include "Asset.h"  namespace crepe { -class SDLContext; -} -namespace crepe { +class SDLContext; +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: +	/** +	 * \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(); +	// FIXME: this constructor shouldn't be necessary because this class doesn't +	// manage memory + +	/** +	 * \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: +	/** +	 * \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 +	std::unique_ptr<SDL_Texture, std::function<void(SDL_Texture *)>> texture; + +	//! Grants SDLContext access to private members. +	friend class SDLContext; -	friend class crepe::SDLContext; +	//! Grants Animator access to private members. +	friend class Animator;  };  } // namespace crepe  |