diff --git a/src/headers/linked_list.h b/src/headers/linked_list.h index e15a54a..88f3a3e 100644 --- a/src/headers/linked_list.h +++ b/src/headers/linked_list.h @@ -24,7 +24,7 @@ typedef struct elem_t { * * During the initialisation of linked lists you can pass in argument a deleter. * It is used during the destruction of an element. - * You can pass NULL to the initialisation to use the default deleter (kfree(elem->data)). + * You can pass NULL to the initialisation to use the default deleter (free(elem->data)). * Your deleter_t function declaration must look like this : * * void name_of_your_deleter(void *data); @@ -45,7 +45,7 @@ typedef void (*deleter_t)(void *data); * bool name_of_your_condition(elem_t *elem, va_list); * * Then return true if you want the element to be removed from the list or false if not. - * You should always define your function with "static", and "inline" if the condition is not too long. + * You should always define your function with "static", and "inline". */ typedef bool (*condition_t)(elem_t *elem, va_list args); @@ -60,7 +60,7 @@ typedef bool (*condition_t)(elem_t *elem, va_list args); * void name_of_your_condition(elem_t *elem, va_list); * * Then do whatever you want with the element data, just don't remove it. - * You should always define your function with "static", and "inline" if the action is short. + * You should always define your function with "static", and "inline". */ typedef void (*action_t)(elem_t *elem, va_list args); diff --git a/src/headers/texture_manager.h b/src/headers/texture_manager.h index a623c6a..5d5e412 100644 --- a/src/headers/texture_manager.h +++ b/src/headers/texture_manager.h @@ -5,77 +5,100 @@ #include "vector2d.h" #include "linked_list.h" -/* texture_t: Texture struct - This struct is the base for textures - - @name Name of the texture - @image Image of type image_t */ +/** + * @brief This struct is the base for textures. + * + * @param name Name of the texture + * @param image Image of type image_t +*/ typedef struct texture_t { const char *name; image_t *image; } texture_t; -/* create_texture(): Create a texture with the given image and name +/** + * @brief Create a texture with the given image and name. + * + * @param name Name of the texture + * @param image Texture of type image_t + * + * @return The created texture, NULL on error. +*/ +texture_t *create_texture(image_t *image, const char *name); - @name Name of the texture - @image Texture of type image_t - Return the created texture, NULL on error. */ -texture_t *create_texture(image_t *, const char *); +/** + * @brief Destroy the given texture. + * + * @param texture Texture to destroy +*/ +void destroy_texture(texture_t *texture); -/* destroy_texture(): Destroy the given texture +/** + * @brief Draw the given texture from given src rect to dst rect. + * + * @param texture Texture to draw + * @param src Source rectangle of the texture to draw + * @param dst Destination of the drawing +*/ +void draw_texture(const texture_t *texture, const rect_t *src_rect, const rect_t *dst_rect, bool flip); - @texture Texture to destroy */ -void destroy_texture(texture_t *); - -/* draw_texture(): Draw the given texture from given src rect to dst rect - - @texture Texture to draw - @src Source rectangle of the texture to draw - @dst Destination of the drawing */ -void draw_texture(const texture_t *, const rect_t *, const rect_t *, bool); - -/* texture_manager_t: Texture manager - - @textures Textures loaded in memory */ +/** + * @brief Texture manager struct. + * + * @param textures Textures loaded in memory +*/ typedef struct texture_manager_t { linked_list_t textures; } texture_manager_t; -/* texture_manager_init(): Initialise the given texture_manager +/** + * @brief Initialise the given texture_manager. + * + * @param texture_manager Pointer to a texture manager +*/ +void texture_manager_init(texture_manager_t *texture_manager); - @texture_manager Pointer to a texture manager */ -void texture_manager_init(texture_manager_t *); +/** + * @brief Load a texture from asset file in the texture manager. + * + * @param texture_manager Pointer to a texture manager + * @param name Name of the texture to add in the texture manager +*/ +void texture_manager_load_texture(texture_manager_t *texture_manager, const char *name); -/* texture_manager_add_texture(): Add a texture in the texture manager +/** + * @brief Get a texture in the texture manager. + * + * @param texture_manager Pointer to a texture manager + * @param name Name of the texture to get + * + * @return The texture, NULL on error or if the texture is not found. +*/ +texture_t *texture_manager_get_texture(texture_manager_t *texture_manager, const char *name); - @texture_manager Pointer to a texture manager - @texture Texture to add in the texture manager */ -void texture_manager_add_texture(texture_manager_t *, texture_t *); +/** + * @brief Remove a texture in the texture manager. + * Does nothing if the texture is not found. + * + * @param texture_manager Pointer to a texture manager + * @param name Name of the texture to remove +*/ +void texture_manager_remove_texture(texture_manager_t *texture_manager, const char *name); -/* texture_manager_get_texture(): Get a texture in the texture manager +/** + * @brief Clear the texture manager. + * + * @param texture_manager Pointer to a texture manager +*/ +void texture_manager_clear(texture_manager_t *texture_manager); - @texture_manager Pointer to a texture manager - @name Name of the texture to get - Return the texture, NULL on error or if the texture is not found. */ -texture_t *texture_manager_get_texture(texture_manager_t *, const char *); - -/* texture_manager_remove_texture(): Remove a texture in the texture manager - - @texture_manager Pointer to a texture manager - @name Name of the texture to remove - Do nothing if the texture is not found. */ -void texture_manager_remove_texture(texture_manager_t *, const char *); - -/* texture_manager_clear(): Clear the texture manager - - @texture_manager Pointer to a texture manager */ -void texture_manager_clear(texture_manager_t *); - -/* texture_manager_draw_texture(): Draw a texture in the texture manager - - @texture_manager Pointer to a texture manager - @name Name of the texture to draw - Do nothing if the texture is not found. */ -void texture_manager_draw_texture(texture_manager_t *, const char *, const rect_t *, const rect_t *, bool); +/** + * @brief Draw a texture in the texture manager. + * Do nothing if the texture is not found. + * + * @param texture_manager Pointer to a texture manager + * @param name Name of the texture to draw +*/ +void texture_manager_draw_texture(texture_manager_t *texture_manager, const char *name, const rect_t *src_rect, const rect_t *dst_rect, bool flip); #endif // TEXTURE_MANAGER_H \ No newline at end of file diff --git a/src/texture_manager.c b/src/texture_manager.c index 7874fc0..07a3da6 100644 --- a/src/texture_manager.c +++ b/src/texture_manager.c @@ -35,7 +35,7 @@ inline void texture_manager_init(texture_manager_t *texture_manager) linked_list_init(&texture_manager->textures, sizeof(texture_t), NULL); } -inline void texture_manager_add_texture(texture_manager_t *texture_manager, texture_t *texture) +inline void texture_manager_load_texture(texture_manager_t *texture_manager, const char *name) { linked_list_push_back(&texture_manager->textures, texture); }