summaryrefslogtreecommitdiff
path: root/asset.h
blob: 370ad15fa22558d7001ca5729966bfab5e193406 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef asset_h
#define asset_h

#include "memory.h"

struct Mesh;

#define assets_xmacro() \
	x( \
		asset_id_cube, \
		asset_type_mesh, \
		"cube.msh" \
	) \
	x( \
		asset_id_monkey, \
		asset_type_mesh, \
		"monkey.msh" \
	) \
	x( \
		asset_id_gun_mesh, \
		asset_type_mesh, \
		"gun.msh" \
	) \
	x( \
		asset_id_gun_texture, \
		asset_type_texture, \
		"gun.bc1" \
	) \
	x( \
		asset_id_brick_texture, \
		asset_type_texture, \
		"brick.bc1" \
	) \
	x( \
		asset_id_floorboards_texture, \
		asset_type_texture, \
		"floorboards.bc1" \
	) \
	x( \
		asset_id_floorboardsbot_texture, \
		asset_type_texture, \
		"floorboardsbot.bc1" \
	) \

typedef enum {
#define x(id, type, path) id,
	assets_xmacro()
#undef x
	asset_id_count
} Asset_ID;

typedef enum {
	asset_type_mesh,
	asset_type_texture
} Asset_Type;

typedef struct {
	Asset_ID id;
	Asset_Type type;
	const void* payload;
	int payload_size;
} Asset;

typedef struct {
	Asset_Type type;
	const char* name;
} Asset_Meta;

typedef struct {
	int size;
	int offset;
	char* buffer;
} Asset_Data;

void preload_assets(Arena* mem);
const Asset* get_asset(Asset_ID id);
const Asset_Meta* get_asset_meta(Asset_ID id);

Asset_Data* read_asset_data(
	const char* name,
	Arena* arena
);

const struct Mesh* get_mesh(Asset_ID id);
const struct Texture* get_texture(Asset_ID id);

#endif