summaryrefslogtreecommitdiff
path: root/src/resource.h
blob: 1e6a35424fe77091e8ca6bd5cad536316159d8a7 (plain)
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
#ifndef ANIMTOOL_RESOURCE_H_
#define ANIMTOOL_RESOURCE_H_

#include "util/container.h"
#include "draw.h"
#include "source.h"

struct texture_source
{
    enum texture_type type;
    struct loc_str path;   
};

struct texture
{
    union {
        texture_id id;
        struct texture_source source;
    };
};

enum mesh_source_type
{
    MESH_OBJ,
    MESH_CUBE,
};

struct mesh_source {
    enum mesh_source_type type;
    union {
        struct loc_str path;
    };
};

struct mesh
{
    union {
        mesh_id id;
        struct mesh_source source;
    };
};

struct cache
{
    option(mesh_id) cube_mesh;
    map(texture_id) textures[2];
    map(mesh_id) meshes;
};

void texture_load(struct texture *tex, struct source *src, struct draw_backend *draw, struct cache *cache);
void mesh_load(struct mesh *mesh, struct source *src, struct draw_backend *draw, struct cache *cache);

void cache_free(struct cache *cache);

#endif