LDK_TEXTURE_ATLAS_REGION_NAME_CAPACITY
#define LDK_TEXTURE_ATLAS_REGION_NAME_CAPACITY 96u
Manage sprite regions and other metadata stored in a texture atlas.
#define LDK_TEXTURE_ATLAS_REGION_NAME_CAPACITY 96u
typedef struct LDKTextureAtlasRegion{
u64 id;
char name[LDK_TEXTURE_ATLAS_REGION_NAME_CAPACITY];
u32 x, y, width, height;
float pivot_x, pivot_y;
}LDKTextureAtlasRegion;
typedef struct LDKTextureAtlas{
LDKAssetPath texture_path;
LDKTextureAtlasRegion *regions;
u32 region_count, region_capacity;
u64 next_region_id;
}LDKTextureAtlas;
Initialize an empty texture atlas.
LDK_API void ldk_texture_atlas_init(LDKTextureAtlas *atlas);
LDKTextureAtlas *atlasClear the state of the texture atlas.
LDK_API void ldk_texture_atlas_clear(LDKTextureAtlas *atlas);
LDKTextureAtlas *atlasCopy the texture atlas.
LDK_API bool ldk_texture_atlas_copy(
LDKTextureAtlas *dst,
const LDKTextureAtlas *src
);
LDKTextureAtlas *dstconst LDKTextureAtlas *srcTrue if the operation succeeds; false otherwise.
Validate the texture atlas.
LDK_API bool ldk_texture_atlas_validate(const LDKTextureAtlas *atlas);
const LDKTextureAtlas *atlasTrue if the operation succeeds; false otherwise.
Set the texture atlas texture.
LDK_API bool ldk_texture_atlas_texture_set(
LDKTextureAtlas *atlas,
const char *path
);
LDKTextureAtlas *atlasconst char *pathTrue if the operation succeeds; false otherwise.
Find the texture atlas region.
LDK_API LDKTextureAtlasRegion * ldk_texture_atlas_region_find(
LDKTextureAtlas *atlas,
u64 id
);
LDKTextureAtlas *atlasu64 idPointer to the requested object or data; NULL when unavailable.
Find a region by stable ID without exposing mutable access.
LDK_API const LDKTextureAtlasRegion * ldk_texture_atlas_region_find_const(
const LDKTextureAtlas *atlas,
u64 id
);
const LDKTextureAtlas *atlasu64 idPointer to the requested object or data; NULL when unavailable.
Add the texture atlas region.
LDK_API bool ldk_texture_atlas_region_add(
LDKTextureAtlas *atlas,
const char *name,
u32 x,
u32 y,
u32 width,
u32 height,
u64 *out_id
);
LDKTextureAtlas *atlasconst char *nameu32 xu32 yu32 widthu32 heightu64 *out_idTrue if the operation succeeds; false otherwise.
Remove the texture atlas region.
LDK_API bool ldk_texture_atlas_region_remove(
LDKTextureAtlas *atlas,
u64 id
);
LDKTextureAtlas *atlasu64 idTrue if the operation succeeds; false otherwise.
Rename a region without changing its stable identifier.
LDK_API bool ldk_texture_atlas_region_rename(
LDKTextureAtlas *atlas,
u64 id,
const char *name
);
LDKTextureAtlas *atlasu64 idconst char *nameTrue if the operation succeeds; false otherwise.
Add a grid of regions to the atlas.
LDK_API bool ldk_texture_atlas_grid_append(
LDKTextureAtlas *atlas,
u32 image_width,
u32 image_height,
u32 cell_width,
u32 cell_height,
u32 spacing_x,
u32 spacing_y,
u32 margin_x,
u32 margin_y
);
LDKTextureAtlas *atlasu32 image_widthu32 image_heightu32 cell_widthu32 cell_heightu32 spacing_xu32 spacing_yu32 margin_xu32 margin_yTrue if the operation succeeds; false otherwise.
Compute normalized UV coordinates for an atlas region. Atlas regions are specified in pixel coordinates; this operation converts them to normalized texture coordinates.
LDK_API bool ldk_texture_atlas_region_uv(
const LDKTextureAtlasRegion *region,
u32 image_width,
u32 image_height,
float out_uv[4]
);
const LDKTextureAtlasRegion *regionu32 image_widthu32 image_heightfloat out_uv[4]True if the operation succeeds; false otherwise.
Serialize the atlas and its regions to TML.
LDK_API bool ldk_texture_atlas_to_tml(
const LDKTextureAtlas *atlas,
char **out_text
);
const LDKTextureAtlas *atlaschar **out_textTrue if the operation succeeds; false otherwise.
Read an atlas and its regions from TML.
LDK_API bool ldk_texture_atlas_from_tml(
LDKTextureAtlas *atlas,
const char *text
);
LDKTextureAtlas *atlasconst char *textTrue if the operation succeeds; false otherwise.
Load the texture atlas.
LDK_API bool ldk_texture_atlas_load(
LDKTextureAtlas *atlas,
const char *filename
);
LDKTextureAtlas *atlasconst char *filenameTrue if the operation succeeds; false otherwise.
Save the texture atlas.
LDK_API bool ldk_texture_atlas_save(
const LDKTextureAtlas *atlas,
const char *filename
);
const LDKTextureAtlas *atlasconst char *filenameTrue if the operation succeeds; false otherwise.