Added animations

Added new assets for the player
Added lookups for assets
Initial sound testing
Re-enabled temp world drawing
This commit is contained in:
2025-10-06 00:52:16 +01:00
parent 3eb8683ce3
commit c721839dfa
30 changed files with 210 additions and 20 deletions

View File

@@ -1,5 +1,18 @@
// @Todo: These should move to draw/core.c
//
internal void G_AssetNameHash(D_Context *draw, Str8 name, U32 id) {
D_AssetHash *result = M_ArenaPush(draw->arena, D_AssetHash);
U64 hash = Str8_Hash(name);
U64 index = hash & (D_ASSET_HASH_COUNT - 1);
result->value = name;
result->hash = hash;
result->id = id;
SLL_Push(draw->lookup[index], result);
}
void G_ImagesLoad(G_State *game) {
M_TempScope(0, 0) {
D_Context *draw = &game->draw;
@@ -59,6 +72,9 @@ void G_ImagesLoad(G_State *game) {
white->name = S("_WHITE");
// This doesn't _really_ need one because its just zero and always will be zero
G_AssetNameHash(draw, white->name, 0);
white->image.width = 2;
white->image.height = 2;
white->image.format = VK_FORMAT_R8G8B8A8_SRGB;
@@ -71,7 +87,7 @@ void G_ImagesLoad(G_State *game) {
// and submitting them in one go. It doesn't really matter for now
//
VkImageMemoryBarrier2 transfer = { 0 };
VkImageMemoryBarrier2 transfer = { 0 };
VkImageMemoryBarrier2 shader_read = { 0 };
transfer.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2;
@@ -147,10 +163,11 @@ void G_ImagesLoad(G_State *game) {
Assert(offset <= staging->size);
draw->n_images += 1;
image->name = Str8_Copy(game->arena, Str8_RemoveAfterLast(it->basename, '.'));
G_AssetNameHash(draw, image->name, draw->n_images);
draw->n_images += 1;
printf("[Info] :: Loaded %.*s from %.*s\n", Sv(image->name), Sv(it->basename));
image->image.width = w;
@@ -290,6 +307,22 @@ void G_PipelinesLoad(G_State *game) {
Vk_PipelineCreate(basic);
}
void G_AudioLoad(G_State *game) {
(void) game;
M_TempScope(0, 0) {
Str8 exe_path = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
Str8 path = Sf(temp.arena, "%.*s/assets", Sv(exe_path));
FS_List assets = FS_PathList(temp.arena, path);
// @Incomplete: finish this
for (FS_Entry *it = assets.first; it != 0; it = it->next) {
}
}
}
void G_CalculateCamera(G_Camera *camera, F32 aspect) {
Mat4x4FInv proj = M4x4F_Perspective(camera->fov, aspect, camera->nearp, camera->farp);
Mat4x4FInv view = M4x4F_CameraView(camera->x, camera->y, camera->z, camera->p);

View File

@@ -25,6 +25,7 @@ struct G_State {
function void G_ImagesLoad(G_State *game);
function void G_PipelinesLoad(G_State *game);
function void G_AudioLoad(G_State *game);
function void G_CalculateCamera(G_Camera *camera, F32 aspect);

View File

@@ -42,15 +42,17 @@ void G_WorldDraw(G_State *game, World *world) {
(void) world;
for (F32 y = -128; y < 128; y += 1.1f) {
for (F32 x = -128; x < 128; x += 1.1f) {
U32 id = D_ImageHandle(&game->draw, S("tile_dirt_0"));
U32 alt_id = D_ImageHandle(&game->draw, S("tile_dirt_1"));
for (F32 y = -128; y < 128; y += 1.0f) {
for (F32 x = -128; x < 128; x += 1.0f) {
U32 ux = (U32) x;
U32 uy = (U32) y;
U32 tid = 15;
U32 tid = id;
if ((ux % 11) == 0 || ((uy % 7) == 0)) {
tid = 16;
tid = alt_id;
}
D_Rect(draw, x, y, .texture = tid);