aboutsummaryrefslogtreecommitdiff
path: root/src/asset/asset_cache.h
blob: b2a35ed62fe447d7d613da76962bbb0a8cbb75af (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
#pragma once

#include <gfx/sizes.h>

#include <cstring.h>
#include <mempool.h>

typedef struct Model   Model;
typedef struct Texture Texture;

typedef uint64_t Hash;

typedef enum AssetType {
  ModelAsset,
  TextureAsset,
} AssetType;

typedef struct Asset {
  AssetType type;
  Hash      hash;
  union {
    Model*         model;
    const Texture* texture;
  };
} Asset;

DEF_MEMPOOL(asset_pool, Asset, GFX_MAX_NUM_ASSETS)

typedef struct AssetCache {
  asset_pool assets;
} AssetCache;

/// Create a new asset cache.
void gfx_init_asset_cache(AssetCache*);

/// Destroy the asset cache.
void gfx_destroy_asset_cache(AssetCache*);