libdragon
Loading...
Searching...
No Matches
sprite.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_SPRITE_H
7#define __LIBDRAGON_SPRITE_H
8
9#include <stdint.h>
10#include <stdbool.h>
11#include <surface.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
18typedef struct rdpq_texparms_s rdpq_texparms_t;
20
21
39typedef struct sprite_s
40{
42 uint16_t width;
44 uint16_t height;
46 uint8_t bitdepth __attribute__((deprecated("use TEX_FORMAT_BITDEPTH(sprite->format) instead")));
47 union {
49 uint8_t format __attribute__((deprecated("use sprite_get_format() instead")));
51 uint8_t flags;
52 };
54 uint8_t hslices;
56 uint8_t vslices;
57
59 uint32_t data[0];
60} sprite_t;
61
78typedef struct sprite_detail_s
79{
85
86#define SPRITE_FLAGS_TEXFORMAT 0x1F
87#define SPRITE_FLAGS_OWNEDBUFFER 0x20
88#define SPRITE_FLAGS_EXT 0x80
89
90
105sprite_t *sprite_load(const char *fn);
106
123sprite_t *sprite_load_buf(void *buf, int sz);
124
126void sprite_free(sprite_t *sprite);
127
135 return (tex_format_t)(sprite->flags & SPRITE_FLAGS_TEXFORMAT);
136}
137
151
170surface_t sprite_get_lod_pixels(sprite_t *sprite, int num_level);
171
193
210surface_t sprite_get_tile(sprite_t *sprite, int h, int v);
211
223uint16_t* sprite_get_palette(sprite_t *sprite);
224
237bool sprite_get_texparms(sprite_t *sprite, rdpq_texparms_t *parms);
238
245int sprite_get_lod_count(sprite_t *sprite);
246
269bool sprite_fits_tmem(sprite_t *sprite);
270
271
272#ifdef __cplusplus
273}
274#endif
275
276#endif
Texture sampling parameters for rdpq_tex_upload.
Definition rdpq_tex.h:39
uint16_t height
Height in pixels.
Definition sprite.h:44
surface_t sprite_get_lod_pixels(sprite_t *sprite, int num_level)
Create a surface_t pointing to the contents of a LOD level.
Definition sprite.c:97
int sprite_get_lod_count(sprite_t *sprite)
Return the number of LOD levels stored within the sprite (including the main image).
Definition sprite.c:205
surface_t sprite_get_detail_pixels(sprite_t *sprite, sprite_detail_t *info, rdpq_texparms_t *infoparms)
Create a surface_t pointing to the contents of a detail texture.
Definition sprite.c:137
uint8_t vslices
Number of vertical sub-tiles.
Definition sprite.h:56
float blend_factor
Blend factor of the detail texture in range of 0 to 1.
Definition sprite.h:83
surface_t sprite_get_pixels(sprite_t *sprite)
Create a surface_t pointing to the full sprite contents.
Definition sprite.c:92
bool sprite_fits_tmem(sprite_t *sprite)
Return true if the sprite fits in TMEM without splitting.
Definition sprite.c:217
sprite_t * sprite_load_buf(void *buf, int sz)
Load a sprite from a buffer.
Definition sprite.c:59
sprite_t * sprite_load(const char *fn)
Load a sprite from a filesystem (eg: ROM)
Definition sprite.c:69
#define SPRITE_FLAGS_TEXFORMAT
Pixel format of the sprite.
Definition sprite.h:86
tex_format_t sprite_get_format(sprite_t *sprite)
Get the sprite texture format.
Definition sprite.h:134
uint8_t hslices
Number of horizontal sub-tiles
Definition sprite.h:54
uint16_t width
Width in pixels.
Definition sprite.h:42
void sprite_free(sprite_t *sprite)
Deallocate a sprite.
Definition sprite.c:78
bool use_main_tex
Is the detail texture the same as the main surface of the sprite, used for fractal detailing.
Definition sprite.h:81
surface_t sprite_get_tile(sprite_t *sprite, int h, int v)
Return a surface_t pointing to a specific tile of the spritemap.
Definition sprite.c:166
uint16_t * sprite_get_palette(sprite_t *sprite)
Access the sprite palette (if any)
Definition sprite.c:159
bool sprite_get_texparms(sprite_t *sprite, rdpq_texparms_t *parms)
Get a copy of the RDP texparms, optionally stored within the sprite.
Definition sprite.c:185
Sprite detail texture information structure.
Definition sprite.h:79
Sprite structure.
Definition sprite.h:40
Surface buffers used to draw images.
tex_format_t
Pixel format enum.
Definition surface.h:103
A surface buffer for graphics.
Definition surface.h:138