citro2d
spritesheet.h
Go to the documentation of this file.
1 /**
2  * @file spritesheet.h
3  * @brief Spritesheet (texture atlas) loading and management
4  */
5 #pragma once
6 #include "base.h"
7 
8 struct C2D_SpriteSheet_s;
9 typedef struct C2D_SpriteSheet_s* C2D_SpriteSheet;
10 
11 /** @defgroup SpriteSheet Sprite sheet functions
12  * @{
13  */
14 
15 /** @brief Load a sprite sheet from file
16  * @param[in] filename Name of the sprite sheet file (.t3x)
17  * @returns Sprite sheet handle
18  * @retval NULL Error
19  */
20 C2D_SpriteSheet C2D_SpriteSheetLoad(const char* filename);
21 
22 /** @brief Load a sprite sheet from memory
23  * @param[in] data Data to load
24  * @param[in] size Size of the data to load
25  * @returns Sprite sheet handle
26  * @retval NULL Error
27  */
28 C2D_SpriteSheet C2D_SpriteSheetLoadFromMem(const void* data, size_t size);
29 
30 /** @brief Load sprite sheet from file descriptor
31  * @param[in] fd File descriptor used to load data
32  * @returns Sprite sheet handle
33  * @retval NULL Error
34  */
35 C2D_SpriteSheet C2D_SpriteSheetFromFD(int fd);
36 
37 /** @brief Load sprite sheet from stdio file handle
38  * @param[in] f File handle used to load data
39  * @returns Sprite sheet handle
40  * @retval NULL Error
41  */
42 C2D_SpriteSheet C2D_SpriteSheetLoadFromHandle(FILE* f);
43 
44 /** @brief Free a sprite sheet
45  * @param[in] sheet Sprite sheet handle
46  */
47 void C2D_SpriteSheetFree(C2D_SpriteSheet sheet);
48 
49 /** @brief Retrieves the number of sprites in the specified sprite sheet
50  * @param[in] sheet Sprite sheet handle
51  * @returns Number of sprites
52  */
53 size_t C2D_SpriteSheetCount(C2D_SpriteSheet sheet);
54 
55 /** @brief Retrieves the specified image from the specified sprite sheet
56  * @param[in] sheet Sprite sheet handle
57  * @param[in] index Index of the image to retrieve
58  * @returns Image object
59  */
60 C2D_Image C2D_SpriteSheetGetImage(C2D_SpriteSheet sheet, size_t index);
61 
62 /** @} */
C2D_Image C2D_SpriteSheetGetImage(C2D_SpriteSheet sheet, size_t index)
Retrieves the specified image from the specified sprite sheet.
C2D_SpriteSheet C2D_SpriteSheetLoadFromHandle(FILE *f)
Load sprite sheet from stdio file handle.
C2D_SpriteSheet C2D_SpriteSheetLoad(const char *filename)
Load a sprite sheet from file.
Definition: base.h:56
C2D_SpriteSheet C2D_SpriteSheetLoadFromMem(const void *data, size_t size)
Load a sprite sheet from memory.
void C2D_SpriteSheetFree(C2D_SpriteSheet sheet)
Free a sprite sheet.
size_t C2D_SpriteSheetCount(C2D_SpriteSheet sheet)
Retrieves the number of sprites in the specified sprite sheet.
C2D_SpriteSheet C2D_SpriteSheetFromFD(int fd)
Load sprite sheet from file descriptor.
Basic citro2d initialization and drawing API.