aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets.c
blob: 09388b81f07f456577ef24844033a3fc26bf70c1 (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
#include "assets.h"

const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX] = {
  "mint.png",
  "nickel.png",
  "tree.png",
  "bush.png",
  "flower.png"
};

const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX] = {
  "skybox.png"
};

const char shaderAssetNames[SHADER_ASSET_COUNT][FT_NAMEMAX] = {
  "skybox"
};

const char modelAssetPaths[MODEL_ASSET_COUNT][FT_NAMEMAX] = {
  "UtilityPole.obj"
};

void initAssets(Assets* assets)
{
  // Textures.
  for (int index = 0; index < TEXTURE_ASSET_COUNT; ++index)
  {
    assets->textures[index] = LoadTexture(
      TextFormat("assets/images/%s", textureAssetPaths[index]));
  }

  // Images;
  for (int index = 0; index < IMAGE_ASSET_COUNT; ++index)
  {
    assets->images[index] = LoadImage(
      TextFormat("assets/images/%s", imageAssetPaths[index]));
  }

  // Shaders.
  for (int index = 0; index < SHADER_ASSET_COUNT; ++index)
  {
    assets->shaders[index] = LoadShader(
      TextFormat("assets/shaders/glsl%i/%s.vs", GLSL_VERSION,
                 shaderAssetNames[index]),
      TextFormat("assets/shaders/glsl%i/%s.fs", GLSL_VERSION,
                 shaderAssetNames[index]));
  }

  // Models.
  for (int index = 0; index < MODEL_ASSET_COUNT; ++index)
  {
    assets->models[index] = LoadModel(
      TextFormat("assets/models/%s", modelAssetPaths[index]));
  }
}

void closeAssets(Assets* assets)
{
  for (int index = 0; index < TEXTURE_ASSET_COUNT; ++index)
  {
    UnloadTexture(assets->textures[index]);
  }

  for (int index = 0; index < IMAGE_ASSET_COUNT; ++index)
  {
    UnloadImage(assets->images[index]);
  }

  for (int index = 0; index < SHADER_ASSET_COUNT; ++index)
  {
    UnloadShader(assets->shaders[index]);
  }

  for (int index = 0; index < MODEL_ASSET_COUNT; ++index)
  {
    UnloadModel(assets->models[index]);
  }
}