From db7d1e6c82a06ab40680417438fbdb847d23a905 Mon Sep 17 00:00:00 2001 From: marouault Date: Thu, 16 Dec 2021 16:13:11 +0100 Subject: [PATCH] Documented TextureHandler.h --- Pontu/include/engine/TextureHandler.h | 39 ++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/Pontu/include/engine/TextureHandler.h b/Pontu/include/engine/TextureHandler.h index f1e5f96..4696d6b 100644 --- a/Pontu/include/engine/TextureHandler.h +++ b/Pontu/include/engine/TextureHandler.h @@ -1,3 +1,10 @@ +/** + * \file TextureHandler.h + * \brief Define a structure, an enum and associated functions to handle textures loading, accessing and freeing + * \author Martin Rouault + * \date 16/12/2021 + */ + #ifndef TEXTURE_HANDLER_INCLUDED #define TEXTURE_HANDLER_INCLUDED @@ -5,28 +12,52 @@ #include #include "engine/TextureLoader.h" +// List here the different texture to handle +// In the enum +// Island become TEXTURE_Island +// In file +// Island become Island.png #define MACRO_FOR_ALL_TEXTURES(M) \ M(Island) \ M(Bridge) \ M(Piece) \ M(Water) -#define MACRO_IDENTITY_COMMA(E) TEXTURE_##E, +// Allow the generation of enum +#define MACRO_TEXTURE_ENUM_GEN(E) TEXTURE_##E, +/** + * \enum EnumTextures + * \brief Indexes for textures in TextureHandler + */ typedef enum { - MACRO_FOR_ALL_TEXTURES(MACRO_IDENTITY_COMMA) - NB_TEXTURES_DEFINED + MACRO_FOR_ALL_TEXTURES(MACRO_TEXTURE_ENUM_GEN) + NB_TEXTURES_DEFINED ///< Contains the number of textures } EnumTextures; +/** + * \struct TextureHandler + * \brief A struct to handle all textures + */ typedef struct { - SDL_Texture* textures[NB_TEXTURES_DEFINED]; + SDL_Texture* textures[NB_TEXTURES_DEFINED]; ///< An array of texture (indexed with EnumTextures) } TextureHandler; + +/** + * \brief Create a TextureHandler and load each texture defined in MACRO_FOR_ALL_TEXTURES in it + * \param renderer The renderer which is passed to texture when they are created + * \return ** TextureHandler filled with textures + */ TextureHandler newTextureHandler(SDL_Renderer* renderer); +/** + * @brief Free every textures in the TextureHandler + * @param textureHandler The texturehandler containing textures to free (textures array will be filled with NULL after calling this function) + */ void freeTextureHandler(TextureHandler* textureHandler); #endif // TEXTURE_HANDLER_INCLUDED \ No newline at end of file