first commit
This commit is contained in:
286
src/game/resource/RESOURCE_COMMON.h
Normal file
286
src/game/resource/RESOURCE_COMMON.h
Normal file
@ -0,0 +1,286 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../engine/file.h"
|
||||
#include "../../engine/shader.h"
|
||||
#include "../../engine/font.h"
|
||||
#include "../../engine/texture.h"
|
||||
#include "../../engine/sound.h"
|
||||
#include "../../engine/music.h"
|
||||
|
||||
#define SHADER_COUNT SHADER_TEXTURE_QUAD + 1
|
||||
typedef enum ShaderType
|
||||
{
|
||||
SHADER_TEXTURE_QUAD
|
||||
} ShaderType;
|
||||
|
||||
typedef struct ShaderPaths
|
||||
{
|
||||
const char* vertex;
|
||||
const char* fragment;
|
||||
} ShaderPaths;
|
||||
|
||||
static const ShaderPaths SHADER_PATHS[SHADER_COUNT] =
|
||||
{
|
||||
{
|
||||
.vertex = "res/shader/texture_quad.vs",
|
||||
.fragment = "res/shader/texture_quad.fs"
|
||||
}
|
||||
};
|
||||
|
||||
#define TEXTURE_COUNT TEXTURE_ENDING + 1
|
||||
typedef enum TextureType
|
||||
{
|
||||
TEXTURE_DEFAULT,
|
||||
TEXTURE_CURSOR,
|
||||
TEXTURE_LOGO,
|
||||
TEXTURE_TITLE_BG,
|
||||
TEXTURE_LEVEL_SELECT_BUTTONS,
|
||||
TEXTURE_LEVEL_SELECT_ICONS,
|
||||
TEXTURE_METER,
|
||||
TEXTURE_METER_STAMINA,
|
||||
TEXTURE_METER_POWER,
|
||||
TEXTURE_MEDALS,
|
||||
TEXTURE_GAME_BG,
|
||||
TEXTURE_GAME_PLANE,
|
||||
TEXTURE_SHADOW,
|
||||
TEXTURE_PLAYER,
|
||||
TEXTURE_TARGET,
|
||||
TEXTURE_COLLECTIBLE,
|
||||
TEXTURE_SMOKE,
|
||||
TEXTURE_TRAP,
|
||||
TEXTURE_CUTSCENE_ONE_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_ONE_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_ONE_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_ONE_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_TWO_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_TWO_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_TWO_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_TWO_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_TWO_SCENE_FIVE,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_FIVE,
|
||||
TEXTURE_CUTSCENE_THREE_SCENE_SIX,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_FIVE,
|
||||
TEXTURE_CUTSCENE_FOUR_SCENE_SIX,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_FIVE,
|
||||
TEXTURE_CUTSCENE_FIVE_SCENE_SIX,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_ONE,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_TWO,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_THREE,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_FOUR,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_FIVE,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_SIX,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_SEVEN,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_EIGHT,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_NINE,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_TEN,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_ELEVEN,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_TWELVE,
|
||||
TEXTURE_CUTSCENE_FINAL_SCENE_THIRTEEN,
|
||||
TEXTURE_ENDING
|
||||
} TextureType;
|
||||
|
||||
static const char* TEXTURE_PATHS[TEXTURE_COUNT] =
|
||||
{
|
||||
"res/gfx/default.png",
|
||||
"res/gfx/cursor.png",
|
||||
"res/gfx/logo.png",
|
||||
"res/gfx/titleBG.png",
|
||||
"res/gfx/levelSelectButtons.png",
|
||||
"res/gfx/levelSelectIcons.png",
|
||||
"res/gfx/meter.png",
|
||||
"res/gfx/meterStamina.png",
|
||||
"res/gfx/meterPower.png",
|
||||
"res/gfx/medals.png",
|
||||
"res/gfx/gameBG.png",
|
||||
"res/gfx/gamePlane.png",
|
||||
"res/gfx/shadow.png",
|
||||
"res/gfx/player.png",
|
||||
"res/gfx/target.png",
|
||||
"res/gfx/collectible.png",
|
||||
"res/gfx/smoke.png",
|
||||
"res/gfx/trap.png",
|
||||
"res/gfx/cutscene/c1s1.png",
|
||||
"res/gfx/cutscene/c1s2.png",
|
||||
"res/gfx/cutscene/c1s3.png",
|
||||
"res/gfx/cutscene/c1s4.png",
|
||||
"res/gfx/cutscene/c2s1.png",
|
||||
"res/gfx/cutscene/c2s2.png",
|
||||
"res/gfx/cutscene/c2s3.png",
|
||||
"res/gfx/cutscene/c2s4.png",
|
||||
"res/gfx/cutscene/c2s5.png",
|
||||
"res/gfx/cutscene/c3s1.png",
|
||||
"res/gfx/cutscene/c3s2.png",
|
||||
"res/gfx/cutscene/c3s3.png",
|
||||
"res/gfx/cutscene/c3s4.png",
|
||||
"res/gfx/cutscene/c3s5.png",
|
||||
"res/gfx/cutscene/c3s6.png",
|
||||
"res/gfx/cutscene/c4s1.png",
|
||||
"res/gfx/cutscene/c4s2.png",
|
||||
"res/gfx/cutscene/c4s3.png",
|
||||
"res/gfx/cutscene/c4s4.png",
|
||||
"res/gfx/cutscene/c4s5.png",
|
||||
"res/gfx/cutscene/c4s6.png",
|
||||
"res/gfx/cutscene/c5s1.png",
|
||||
"res/gfx/cutscene/c5s2.png",
|
||||
"res/gfx/cutscene/c5s3.png",
|
||||
"res/gfx/cutscene/c5s4.png",
|
||||
"res/gfx/cutscene/c5s5.png",
|
||||
"res/gfx/cutscene/c5s6.png",
|
||||
"res/gfx/cutscene/c6s1.png",
|
||||
"res/gfx/cutscene/c6s2.png",
|
||||
"res/gfx/cutscene/c6s3.png",
|
||||
"res/gfx/cutscene/c6s4.png",
|
||||
"res/gfx/cutscene/c6s5.png",
|
||||
"res/gfx/cutscene/c6s6.png",
|
||||
"res/gfx/cutscene/c6s7.png",
|
||||
"res/gfx/cutscene/c6s8.png",
|
||||
"res/gfx/cutscene/c6s9.png",
|
||||
"res/gfx/cutscene/c6s10.png",
|
||||
"res/gfx/cutscene/c6s11.png",
|
||||
"res/gfx/cutscene/c6s12.png",
|
||||
"res/gfx/cutscene/c6s13.png",
|
||||
"res/gfx/cutscene/ending.png"
|
||||
};
|
||||
|
||||
#define FONT_COUNT FONT_BIG + 1
|
||||
typedef enum FontType
|
||||
{
|
||||
FONT_DEFAULT,
|
||||
FONT_SMALL,
|
||||
FONT_BIG
|
||||
} FontType;
|
||||
|
||||
static const char* FONT_PATHS[FONT_COUNT] =
|
||||
{
|
||||
"res/font/default.ttf",
|
||||
"res/font/default.ttf",
|
||||
"res/font/default.ttf"
|
||||
};
|
||||
|
||||
static const u32 FONT_SIZES[FONT_COUNT] =
|
||||
{
|
||||
32,
|
||||
24,
|
||||
48
|
||||
};
|
||||
|
||||
#define SOUND_COUNT (SOUND_CANCEL + 1)
|
||||
#define SOUND_BURP_COUNT 3
|
||||
#define SOUND_GURGLE_COUNT 3
|
||||
#define SOUND_LUNGE_COUNT 3
|
||||
#define SOUND_GULP_COUNT 3
|
||||
typedef enum SoundType
|
||||
{
|
||||
SOUND_BLIP,
|
||||
SOUND_SELECT,
|
||||
SOUND_PAUSE,
|
||||
SOUND_UNPAUSE,
|
||||
SOUND_BRONZE,
|
||||
SOUND_SILVER,
|
||||
SOUND_GOLD,
|
||||
SOUND_EVENT,
|
||||
SOUND_LOW_TIMER_TICK,
|
||||
SOUND_FINISH,
|
||||
SOUND_LUNGE,
|
||||
SOUND_LUNGE_2,
|
||||
SOUND_LUNGE_3,
|
||||
SOUND_GULP,
|
||||
SOUND_GULP_2,
|
||||
SOUND_GULP_3,
|
||||
SOUND_BURP,
|
||||
SOUND_BURP_2,
|
||||
SOUND_BURP_3,
|
||||
SOUND_GURGLE,
|
||||
SOUND_GURGLE_2,
|
||||
SOUND_GURGLE_3,
|
||||
SOUND_APPEAR,
|
||||
SOUND_STICKY,
|
||||
SOUND_FOOD_COLLECT,
|
||||
SOUND_CANT_CARRY,
|
||||
SOUND_BLEH,
|
||||
SOUND_POWER,
|
||||
SOUND_STAMINA,
|
||||
SOUND_MAGNET,
|
||||
SOUND_EXTEND,
|
||||
SOUND_FORESIGHT,
|
||||
SOUND_INVIGORATE,
|
||||
SOUND_CANCEL
|
||||
} SoundType;
|
||||
|
||||
static const char* SOUND_PATHS[SOUND_COUNT] =
|
||||
{
|
||||
"res/sound/blip.ogg",
|
||||
"res/sound/select.ogg",
|
||||
"res/sound/pause.ogg",
|
||||
"res/sound/unpause.ogg",
|
||||
"res/sound/bronze.ogg",
|
||||
"res/sound/silver.ogg",
|
||||
"res/sound/gold.ogg",
|
||||
"res/sound/event.ogg",
|
||||
"res/sound/lowTimerTick.ogg",
|
||||
"res/sound/finish.ogg",
|
||||
"res/sound/lunge.ogg",
|
||||
"res/sound/lunge2.ogg",
|
||||
"res/sound/lunge3.ogg",
|
||||
"res/sound/gulp.ogg",
|
||||
"res/sound/gulp2.ogg",
|
||||
"res/sound/gulp3.ogg",
|
||||
"res/sound/burp.ogg",
|
||||
"res/sound/burp2.ogg",
|
||||
"res/sound/burp3.ogg",
|
||||
"res/sound/gurgle.ogg",
|
||||
"res/sound/gurgle2.ogg",
|
||||
"res/sound/gurgle3.ogg",
|
||||
"res/sound/appear.ogg",
|
||||
"res/sound/sticky.ogg",
|
||||
"res/sound/foodCollect.ogg",
|
||||
"res/sound/cantCarry.ogg",
|
||||
"res/sound/bleh.ogg",
|
||||
"res/sound/power.ogg",
|
||||
"res/sound/stamina.ogg",
|
||||
"res/sound/magnet.ogg",
|
||||
"res/sound/extend.ogg",
|
||||
"res/sound/foresight.ogg",
|
||||
"res/sound/invigorate.ogg",
|
||||
"res/sound/cancel.ogg"
|
||||
};
|
||||
|
||||
#define MUSIC_COUNT MUSIC_VICTORY + 1
|
||||
typedef enum MusicType
|
||||
{
|
||||
MUSIC_TITLE,
|
||||
MUSIC_CUTSCENE,
|
||||
MUSIC_WIND,
|
||||
MUSIC_GAME,
|
||||
MUSIC_VICTORY
|
||||
} MusicType;
|
||||
|
||||
static const char* MUSIC_PATHS[MUSIC_COUNT] =
|
||||
{
|
||||
"res/music/title.ogg",
|
||||
"res/music/cutscene.ogg",
|
||||
"res/music/wind.ogg",
|
||||
"res/music/game.ogg",
|
||||
"res/music/victory.ogg"
|
||||
};
|
||||
|
||||
typedef struct Resources
|
||||
{
|
||||
Shader shaders[SHADER_COUNT];
|
||||
Texture textures[TEXTURE_COUNT];
|
||||
Music music[MUSIC_COUNT];
|
||||
Sound sounds[SOUND_COUNT];
|
||||
Font fonts[FONT_COUNT];
|
||||
} Resources;
|
25
src/game/resource/resource_font.c
Normal file
25
src/game/resource/resource_font.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "resource_font.h"
|
||||
|
||||
bool
|
||||
resource_font_init(Resources* self, FontType type)
|
||||
{
|
||||
if (!font_init(&self->fonts[type], FONT_PATHS[type], FONT_SIZES[type]))
|
||||
{
|
||||
printf(STRING_RESOURCE_FONT_ERROR, FONT_PATHS[type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(STRING_RESOURCE_FONT_INIT, FONT_PATHS[type]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resource_font_free(Resources* self, FontType type)
|
||||
{
|
||||
if (self->fonts[type].isInit)
|
||||
{
|
||||
font_free(&self->fonts[type]);
|
||||
printf(STRING_RESOURCE_FONT_FREE, FONT_PATHS[type]);
|
||||
}
|
||||
}
|
10
src/game/resource/resource_font.h
Normal file
10
src/game/resource/resource_font.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RESOURCE_COMMON.h"
|
||||
|
||||
#define STRING_RESOURCE_FONT_ERROR "[ERROR] Unable to initialize font resource: %s\n"
|
||||
#define STRING_RESOURCE_FONT_FREE "[INFO] Freed font resource: %s\n"
|
||||
#define STRING_RESOURCE_FONT_INIT "[INFO] Initialized font resource: %s\n"
|
||||
|
||||
void resource_font_free(Resources* self, FontType type);
|
||||
bool resource_font_init(Resources* self, FontType type);
|
26
src/game/resource/resource_music.c
Normal file
26
src/game/resource/resource_music.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "resource_music.h"
|
||||
|
||||
bool
|
||||
resource_music_init(Resources* self, MusicType type)
|
||||
{
|
||||
if (!music_init(&self->music[type], MUSIC_PATHS[type]))
|
||||
{
|
||||
printf(STRING_RESOURCE_MUSIC_ERROR, MUSIC_PATHS[type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(STRING_RESOURCE_MUSIC_INIT, MUSIC_PATHS[type]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resource_music_free(Resources* self, MusicType type)
|
||||
{
|
||||
if (self->music[type].isInit)
|
||||
{
|
||||
music_free(&self->music[type]);
|
||||
|
||||
printf(STRING_RESOURCE_MUSIC_FREE, MUSIC_PATHS[type]);
|
||||
}
|
||||
}
|
10
src/game/resource/resource_music.h
Normal file
10
src/game/resource/resource_music.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RESOURCE_COMMON.h"
|
||||
|
||||
#define STRING_RESOURCE_MUSIC_ERROR "[ERROR] Unable to initialize music resource: %s\n"
|
||||
#define STRING_RESOURCE_MUSIC_FREE "[INFO] Freed music resource: %s\n"
|
||||
#define STRING_RESOURCE_MUSIC_INIT "[INFO] Initialized music resource: %s\n"
|
||||
|
||||
void resource_music_free(Resources* self, MusicType type);
|
||||
bool resource_music_init(Resources* self, MusicType type);
|
63
src/game/resource/resource_shader.c
Normal file
63
src/game/resource/resource_shader.c
Normal file
@ -0,0 +1,63 @@
|
||||
#include "resource_shader.h"
|
||||
|
||||
typedef struct ShaderData
|
||||
{
|
||||
char vertex[SHADER_BUFFER_SIZE];
|
||||
char fragment[SHADER_BUFFER_SIZE];
|
||||
} ShaderData;
|
||||
|
||||
static ShaderData shaderData[SHADER_COUNT];
|
||||
|
||||
void
|
||||
resource_shader_read(Resources* self)
|
||||
{
|
||||
for (s32 i = 0; i < SHADER_COUNT; i++)
|
||||
{
|
||||
file_read
|
||||
(
|
||||
SHADER_PATHS[i].vertex,
|
||||
(void*)shaderData[i].vertex,
|
||||
SHADER_BUFFER_SIZE,
|
||||
"r"
|
||||
);
|
||||
|
||||
file_read
|
||||
(
|
||||
SHADER_PATHS[i].fragment,
|
||||
(void*)shaderData[i].fragment,
|
||||
SHADER_BUFFER_SIZE,
|
||||
"r"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
resource_shader_init(Resources* self, ShaderType type)
|
||||
{
|
||||
if
|
||||
(
|
||||
!shader_init
|
||||
(
|
||||
&self->shaders[type],
|
||||
shaderData[type].vertex,
|
||||
shaderData[type].fragment
|
||||
)
|
||||
)
|
||||
{
|
||||
printf(STRING_RESOURCE_SHADER_ERROR, SHADER_PATHS[type].vertex, SHADER_PATHS[type].fragment);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(STRING_RESOURCE_SHADER_INIT, SHADER_PATHS[type].vertex, SHADER_PATHS[type].fragment);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resource_shader_free(Resources* self, ShaderType type)
|
||||
{
|
||||
if (self->shaders[type].isInit)
|
||||
{
|
||||
shader_free(&self->shaders[type]);
|
||||
printf(STRING_RESOURCE_SHADER_FREE, SHADER_PATHS[type].vertex, SHADER_PATHS[type].fragment);
|
||||
}
|
||||
}
|
13
src/game/resource/resource_shader.h
Normal file
13
src/game/resource/resource_shader.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "RESOURCE_COMMON.h"
|
||||
|
||||
#define SHADER_BUFFER_SIZE 2048
|
||||
|
||||
#define STRING_RESOURCE_SHADER_ERROR "[ERROR] Unable to initialize shader resource: %s & %s\n"
|
||||
#define STRING_RESOURCE_SHADER_FREE "[INFO] Freed shader resource: %s & %s\n"
|
||||
#define STRING_RESOURCE_SHADER_INIT "[INFO] Initialized shader resource: %s & %s\n"
|
||||
|
||||
void resource_shader_free(Resources* self, ShaderType type);
|
||||
bool resource_shader_init(Resources* self, ShaderType type);
|
||||
void resource_shader_read(Resources* self);
|
26
src/game/resource/resource_sound.c
Normal file
26
src/game/resource/resource_sound.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "resource_sound.h"
|
||||
|
||||
bool
|
||||
resource_sound_init(Resources* self, SoundType type)
|
||||
{
|
||||
if (!sound_init(&self->sounds[type], SOUND_PATHS[type]))
|
||||
{
|
||||
printf(STRING_RESOURCE_SOUND_ERROR, SOUND_PATHS[type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(STRING_RESOURCE_SOUND_INIT, SOUND_PATHS[type]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resource_sound_free(Resources* self, SoundType type)
|
||||
{
|
||||
if (self->sounds[type].isInit)
|
||||
{
|
||||
sound_free(&self->sounds[type]);
|
||||
|
||||
printf(STRING_RESOURCE_SOUND_FREE, SOUND_PATHS[type]);
|
||||
}
|
||||
}
|
10
src/game/resource/resource_sound.h
Normal file
10
src/game/resource/resource_sound.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RESOURCE_COMMON.h"
|
||||
|
||||
#define STRING_RESOURCE_SOUND_ERROR "[ERROR] Unable to initialize sound resource: %s\n"
|
||||
#define STRING_RESOURCE_SOUND_FREE "[INFO] Freed sound resource: %s\n"
|
||||
#define STRING_RESOURCE_SOUND_INIT "[INFO] Initialized sound resource: %s\n"
|
||||
|
||||
void resource_sound_free(Resources* self, SoundType type);
|
||||
bool resource_sound_init(Resources* self, SoundType type);
|
26
src/game/resource/resource_texture.c
Normal file
26
src/game/resource/resource_texture.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "resource_texture.h"
|
||||
|
||||
bool
|
||||
resource_texture_init(Resources* self, TextureType type)
|
||||
{
|
||||
if (!texture_from_path_init(&self->textures[type], TEXTURE_PATHS[type]))
|
||||
{
|
||||
printf(STRING_RESOURCE_TEXTURE_ERROR, TEXTURE_PATHS[type]);
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(STRING_RESOURCE_TEXTURE_INIT, TEXTURE_PATHS[type]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resource_texture_free(Resources* self, TextureType type)
|
||||
{
|
||||
if (self->textures[type].isInit)
|
||||
{
|
||||
texture_free(&self->textures[type]);
|
||||
|
||||
printf(STRING_RESOURCE_TEXTURE_FREE, TEXTURE_PATHS[type]);
|
||||
}
|
||||
}
|
10
src/game/resource/resource_texture.h
Normal file
10
src/game/resource/resource_texture.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "RESOURCE_COMMON.h"
|
||||
|
||||
#define STRING_RESOURCE_TEXTURE_ERROR "[ERROR] Unable to initialize texture resource: %s\n"
|
||||
#define STRING_RESOURCE_TEXTURE_FREE "[INFO] Freed texture resource: %s\n"
|
||||
#define STRING_RESOURCE_TEXTURE_INIT "[INFO] Initialized texture resource: %s\n"
|
||||
|
||||
void resource_texture_free(Resources* self, TextureType type);
|
||||
bool resource_texture_init(Resources* self, TextureType type);
|
46
src/game/resource/resources.c
Normal file
46
src/game/resource/resources.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include "resources.h"
|
||||
|
||||
bool
|
||||
resources_init(Resources* self)
|
||||
{
|
||||
for (s32 i = 0; i < SHADER_COUNT; i++)
|
||||
if (!resource_shader_init(self, (ShaderType)i))
|
||||
return false;
|
||||
|
||||
for (s32 i = 0; i < TEXTURE_COUNT; i++)
|
||||
if (!resource_texture_init(self, (TextureType)i))
|
||||
return false;
|
||||
|
||||
for (s32 i = 0; i < FONT_COUNT; i++)
|
||||
if (!resource_font_init(self, (FontType)i))
|
||||
return false;
|
||||
|
||||
for (s32 i = 0; i < SOUND_COUNT; i++)
|
||||
if (!resource_sound_init(self, (SoundType)i))
|
||||
return false;
|
||||
|
||||
for (s32 i = 0; i < MUSIC_COUNT; i++)
|
||||
if (!resource_music_init(self, (MusicType)i))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
resources_free(Resources* self)
|
||||
{
|
||||
for (s32 i = 0; i < SHADER_COUNT; i++)
|
||||
resource_shader_free(self, (ShaderType)i);
|
||||
|
||||
for (s32 i = 0; i < TEXTURE_COUNT; i++)
|
||||
resource_texture_free(self, (TextureType)i);
|
||||
|
||||
for (s32 i = 0; i < FONT_COUNT; i++)
|
||||
resource_font_free(self, (FontType)i);
|
||||
|
||||
for (s32 i = 0; i < SOUND_COUNT; i++)
|
||||
resource_sound_free(self, (SoundType)i);
|
||||
|
||||
for (s32 i = 0; i < MUSIC_COUNT; i++)
|
||||
resource_music_free(self, (MusicType)i);
|
||||
}
|
12
src/game/resource/resources.h
Normal file
12
src/game/resource/resources.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource_font.h"
|
||||
#include "resource_music.h"
|
||||
#include "resource_shader.h"
|
||||
#include "resource_sound.h"
|
||||
#include "resource_texture.h"
|
||||
|
||||
#define STRING_RESOURCE_ERROR "[ERROR] Unable to load resource! Exiting..."
|
||||
|
||||
void resources_free(Resources* self);
|
||||
bool resources_init(Resources* self);
|
Reference in New Issue
Block a user