62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
////////////////////////////////
|
|
//~ Resource types
|
|
|
|
#define RES_ResourceNameLenMax 256
|
|
|
|
Struct(RES_Resource)
|
|
{
|
|
String _data;
|
|
b32 _exists;
|
|
#if RESOURCES_EMBEDDED
|
|
String _name;
|
|
#else
|
|
P_File _file;
|
|
P_FileMap _file_map;
|
|
u8 _name_text[RES_ResourceNameLenMax];
|
|
u8 _name_len;
|
|
#endif
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ Shared state
|
|
|
|
Struct(RES_SharedState)
|
|
{
|
|
Arena *arena;
|
|
#if RESOURCES_EMBEDDED
|
|
TAR_Archive archive;
|
|
#endif
|
|
};
|
|
|
|
extern RES_SharedState RES_shared_state;
|
|
|
|
////////////////////////////////
|
|
//~ Startup
|
|
|
|
Struct(RES_StartupReceipt) { i32 _; };
|
|
RES_StartupReceipt RES_Startup(void);
|
|
|
|
////////////////////////////////
|
|
//~ Open / close
|
|
|
|
RES_Resource RES_OpenResource(String name);
|
|
|
|
#if RESOURCES_EMBEDDED
|
|
# define RES_CloseResource(res_ptr) (MaybeUnused)res_ptr
|
|
#else
|
|
void RES_CloseResource(RES_Resource *res_ptr);
|
|
#endif
|
|
|
|
////////////////////////////////
|
|
//~ Resource data operations
|
|
|
|
#define RES_GetResourceData(res_ptr) (res_ptr)->_data
|
|
|
|
#define RES_ResourceExists(res_ptr) (res_ptr)->_exists
|
|
|
|
#if RESOURCES_EMBEDDED
|
|
# define RES_GetResourceName(res_ptr) (res_ptr)->_name
|
|
#else
|
|
# define RES_GetResourceName(res_ptr) STRING((res_ptr)->_name_len, (res_ptr)->_name_text)
|
|
#endif
|