Added filesystem stuff on Linux
More includes for Linux Update build script to copy assets and compile shaders Added base code directory as include path Added FS_SystemPath Made asset loading work directory agnostic
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
void G_ImagesLoad(G_State *game) {
|
||||
M_TempScope(0, 0) {
|
||||
FS_List assets = FS_PathList(temp.arena, S("assets"));
|
||||
Str8 exe_path = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
|
||||
Str8 path = Sf(temp.arena, "%.*s/assets", exe_path);
|
||||
|
||||
FS_List assets = FS_PathList(temp.arena, path);
|
||||
|
||||
Vk_Buffer staging = { 0 };
|
||||
staging.size = MB(256);
|
||||
@@ -14,21 +17,15 @@ void G_ImagesLoad(G_State *game) {
|
||||
|
||||
Vk_CommandBuffer *cmds = Vk_CommandBufferPush();
|
||||
|
||||
U32 n_images = 0;
|
||||
|
||||
for (FS_Entry *it = assets.first; it != 0; it = it->next) {
|
||||
if (Str8_EndsWith(it->basename, S("png"))) {
|
||||
if (Str8_Equal(it->basename, S("saloon_ext.png"), 0)) {
|
||||
printf("IMAGE SALOON == %d\n", n_images);
|
||||
}
|
||||
|
||||
n_images += 1;
|
||||
game->n_images += 1;
|
||||
}
|
||||
}
|
||||
|
||||
VkBufferImageCopy copy = { 0 };
|
||||
game->images = M_ArenaPush(game->arena, G_Image, .count = n_images);
|
||||
n_images = 0;
|
||||
game->images = M_ArenaPush(game->arena, G_Image, .count = game->n_images);
|
||||
game->n_images = 0;
|
||||
|
||||
// Image upload is sbi_load -> copy to staging -> upload to gpu texture
|
||||
|
||||
@@ -38,7 +35,7 @@ void G_ImagesLoad(G_State *game) {
|
||||
stbi_uc *data = stbi_load((const char *) it->path.data, &w, &h, &c, 4);
|
||||
|
||||
if (data) {
|
||||
G_Image *image = &game->images[n_images];
|
||||
G_Image *image = &game->images[game->n_images];
|
||||
|
||||
U64 image_sz = 4 * w * h;
|
||||
|
||||
@@ -62,10 +59,12 @@ void G_ImagesLoad(G_State *game) {
|
||||
|
||||
Assert(offset <= staging.size);
|
||||
|
||||
n_images += 1;
|
||||
game->n_images += 1;
|
||||
|
||||
image->name = Str8_Copy(game->arena, Str8_RemoveAfterLast(it->basename, '.'));
|
||||
|
||||
printf("[Info] :: Loaded %.*s from %.*s\n", Sv(image->name), Sv(it->basename));
|
||||
|
||||
image->image.width = w;
|
||||
image->image.height = h;
|
||||
|
||||
@@ -133,8 +132,9 @@ void G_PipelinesLoad(G_State *game) {
|
||||
|
||||
VkShaderModule vshader = 0, fshader = 0;
|
||||
M_TempScope(0, 0) {
|
||||
Str8 vshader_code = FS_ReadEntireFile(temp.arena, S("assets/shaders/basic.vert.spv"));
|
||||
Str8 fshader_code = FS_ReadEntireFile(temp.arena, S("assets/shaders/basic.frag.spv"));
|
||||
Str8 exe_path = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
|
||||
Str8 vshader_code = FS_ReadEntireFile(temp.arena, Sf(temp.arena, "%.*s/assets/shaders/basic.vert.spv", Sv(exe_path)));
|
||||
Str8 fshader_code = FS_ReadEntireFile(temp.arena, Sf(temp.arena, "%.*s/assets/shaders/basic.frag.spv", Sv(exe_path)));
|
||||
|
||||
VkShaderModuleCreateInfo create_info = { 0 };
|
||||
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
|
||||
Reference in New Issue
Block a user