#ifndef _assets_h #define _assets_h #include #ifdef __cplusplus extern "C" { #endif #include "stddef.h" #include "SDL2/SDL.h" typedef enum resourcetype_t { RESOURCETYPE_MIN, RESOURCETYPE_TEXTURE, RESOURCETYPE_FONT, RESOURCETYPE_ARBITRARY, RESOURCETYPE_MAX } resourcetype_t; typedef void(*deleter_fn)(void* target); typedef struct resource_t { resourcetype_t type; uintptr_t hash; char* name; union { SDL_Texture* texture; struct { int size; TTF_Font* font; } font; struct { void* memory; deleter_fn deleter; } arbitrary_type; }; } resource_t; extern void add_arbitrary_asset(void* memory, deleter_fn deleter); extern void add_arbitrary_asset_by_name(void* memory, deleter_fn deleter, const char* name); extern SDL_Texture* load_texture(const char* file); extern TTF_Font* load_font(const char* file, int size); extern SDL_Texture* get_texture(const char* file); extern TTF_Font* get_font(const char* file, int size); extern resource_t* get_asset(const char* file); extern resourcetype_t asset_type(const char* name); extern int asset_exists(const char* name); extern int delete_by_name(const char* name); extern void clean_assets(); #ifdef __cplusplus } #endif #endif /* _assets_h */