Sprite atlases

Typedefs

typedef enum binocle_atlas_file_format binocle_atlas_file_format

The format of the atlas. We currently support libGDX and TexturePacker

typedef struct binocle_atlas_animation binocle_atlas_animation
typedef struct binocle_atlas_slice_key binocle_atlas_slice_key
typedef struct binocle_atlas_slice binocle_atlas_slice
typedef struct binocle_atlas_tp_meta binocle_atlas_tp_meta
typedef struct binocle_atlas_tp_frame binocle_atlas_tp_frame
typedef struct binocle_atlas_texturepacker binocle_atlas_texturepacker

Enums

enum binocle_atlas_file_format

The format of the atlas. We currently support libGDX and TexturePacker

Values:

enumerator BINOCLE_ATLAS_FILE_FORMAT_TEXTUREPACKER
enumerator BINOCLE_ATLAS_FILE_FORMAT_LIBGDX

Functions

bool binocle_atlas_load_texturepacker(char *filename, binocle_atlas_texturepacker *atlas)

Load a TexturePacker JSON atlas

Parameters

filename – the JSON file path and name

Returns

an instance of binocle_atlas_texturepacker with the data of the atlas

void binocle_atlas_texturepacker_create_subtextures(binocle_atlas_texturepacker *atlas, struct sg_image *texture, struct binocle_subtexture *subtextures, int *num_subtextures)

Load a TexturePacker JSON atlas

Parameters
  • atlas – an instance of binocle_atlas_texturepacker with the data of the atlas

  • texture – the corresponding texture that we already loaded

  • subtextures – an array of subtextures to store those coming from the JSON

  • num_subtextures – the number of subtextures that have been loaded by this function

void binocle_atlas_destroy_texturepacker(binocle_atlas_texturepacker *atlas)

Frees the resources of the atlas

Parameters

atlas – an instance of binocle_atlas_texturepacker to release

void binocle_atlas_load_libgdx(char *filename, struct sg_image *texture, struct binocle_subtexture *subtextures, int *num_subtextures)

Load a libGDX atlas

Note

Not yet implemented

Parameters
  • filename – the JSON file path and name

  • texture – the corresponding texture that we already loaded

  • subtextures – an array of subtextures to store those coming from the JSON

  • num_subtextures – the number of subtextures that have been loaded by this function

void binocle_atlas_animation_destroy(binocle_atlas_animation *animations, size_t num_animations)

Frees the memory allocated while loading animations

Parameters
  • animations – a pointer to the binocle_atlas_animation struct to free

  • num_animations – the number of animations previously loaded

struct binocle_atlas_animation

Public Members

const char *name
const char *direction
int from
int to
struct binocle_atlas_slice_key

Public Members

int frame
kmAABB2 bounds
kmVec2 pivot
struct binocle_atlas_slice

Public Members

const char *name
const char *color
binocle_atlas_slice_key *keys
size_t num_keys
struct binocle_atlas_tp_meta

Public Members

char *app
char *version
char *image
char *format
char *scale
char *smartupdate
kmVec2 size
binocle_atlas_animation *frame_tags
size_t num_frame_tags
binocle_atlas_slice *slices
size_t num_slices
struct binocle_atlas_tp_frame

Public Members

char *filename
kmAABB2 frame
bool rotated
bool trimmed
kmAABB2 sprite_source_size
kmVec2 source_size
kmVec2 pivot
struct binocle_atlas_texturepacker

Public Members

binocle_atlas_tp_frame *frames
size_t num_frames
binocle_atlas_tp_meta meta