summaryrefslogtreecommitdiff
path: root/asset.hpp
blob: 63ea047fd17b5543759b2a3ce122003f0aeb07e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef asset_hpp
#define asset_hpp

struct Arena;
struct Asset_Loader;
struct Pack_File;
struct Pack;

struct Asset {
	Asset_Loader* loader;
};

struct Asset_Loader {
	virtual Asset* load(
		Arena* a,
		Arena* s,
		const char* filename,
		Pack_File* f
	) = 0;
	virtual void unload(Asset* a) = 0;
};

struct Asset_Arena {
	Pack* p;
	Arena* a, * s;
	struct Bucket {
		char* name;
		Asset* asset;
	};
	Bucket* assets;
	int max_assets;

	void init(Arena* arena, const char* pack_name, int max);
	void destroy();

	Asset* load(const char* name);

	int bucket(const char* name);
};

void register_asset_loader(
	const char* magic,
	Asset_Loader* loader
);

#endif