diff --git a/Game/Data/World.cpp b/Game/Data/World.cpp index 0c57179..8167c4b 100644 --- a/Game/Data/World.cpp +++ b/Game/Data/World.cpp @@ -236,18 +236,18 @@ void RenderWorldEditorUI(World& world) static char worldFilePath[256] = "/world.bin"; ImGui::InputText("World File", worldFilePath, sizeof(worldFilePath)); - String path = GetAssetPath(temp.Arena, AssetType::JAsset, ConstString(worldFilePath)); + Path path = GetAssetPath(temp.Arena, AssetType::JAsset, ConstString(worldFilePath)); if (ImGui::Button("Save World")) { Archive data = { .arena = temp.Arena, .loading = false }; - Serialize(data, world, path); + Serialize(data, world, path.FullPath); } ImGui::SameLine(); if (ImGui::Button("Load World")) { Archive data{ .arena = temp.Arena, .loading = true }; - Serialize(data, world, path); + Serialize(data, world, path.FullPath); } scratch_end(temp); diff --git a/Juliet/include/Core/HAL/Filesystem/Filesystem.h b/Juliet/include/Core/HAL/Filesystem/Filesystem.h index 445c38c..d628fb5 100644 --- a/Juliet/include/Core/HAL/Filesystem/Filesystem.h +++ b/Juliet/include/Core/HAL/Filesystem/Filesystem.h @@ -9,15 +9,27 @@ enum class AssetType Config, }; +struct Path +{ + String Directories; + String FullPath; +}; + +JULIET_API bool IsValid(Path path); + // Returns the path to the application directory -JULIET_API String GetBasePath(); +JULIET_API Path GetBasePath(); // Path to the /Assets/ folder -JULIET_API String GetAssetBasePath(); +JULIET_API Path GetAssetBasePath(); // Builds a full path to an asset file given its filename (e.g. "Triangle.vert.dxil"). -JULIET_API String GetAssetPath(NonNullPtr arena, AssetType type, String filename); +JULIET_API Path GetAssetPath(NonNullPtr arena, AssetType type, String filename); JULIET_API bool IsAbsolutePath(String path); JULIET_API String CleanPath(NonNullPtr arena, String path); + +JULIET_API bool fs_create_directory(String path, bool recursive); + +JULIET_API bool fs_path_exists(String path); diff --git a/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp b/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp index bcfd8ce..a0bdafa 100644 --- a/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp +++ b/Juliet/src/Core/HAL/Filesystem/Filesystem.cpp @@ -11,9 +11,9 @@ namespace { - String CachedBasePath = {}; - String CachedAssetBasePath = {}; - String CachedShaderBasePath = {}; + Path CachedBasePath = {}; + Path CachedAssetBasePath = {}; + Path CachedShaderBasePath = {}; bool DirectoryExists(const char* path) { @@ -23,19 +23,24 @@ namespace } } // namespace -String GetBasePath() +bool IsValid(Path path) +{ + return IsValid(path.Directories) && IsValid(path.FullPath); +} + +Path GetBasePath() { Assert(IsValid(CachedBasePath)); return CachedBasePath; } -String GetAssetBasePath() +Path GetAssetBasePath() { Assert(IsValid(CachedAssetBasePath)); - return CachedAssetBasePath; + return { CachedAssetBasePath }; } -String GetAssetPath(NonNullPtr arena, AssetType type, String filename) +Path GetAssetPath(NonNullPtr arena, AssetType type, String filename) { // ICI on va vouloir 1) avoir une fonction create file path a partir de base + file qui fait un string copy // On va passer le path au clean path @@ -48,39 +53,36 @@ String GetAssetPath(NonNullPtr arena, AssetType type, String filename) { case AssetType::Shader: { - Assert(IsValid(CachedShaderBasePath)); + totalSize = CachedShaderBasePath.Directories.Size + filename.Size + 1; - totalSize = CachedShaderBasePath.Size + filename.Size + 1; - - juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedShaderBasePath), CStr(filename)); + juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedShaderBasePath.Directories), CStr(filename)); } break; case AssetType::Config: { - Assert(IsValid(CachedAssetBasePath)); - constexpr char kConfig_str[] = "config/"; constexpr size_t kConfig_size = sizeof(kConfig_str) - 1; - totalSize = CachedAssetBasePath.Size + kConfig_size + filename.Size + 1; + totalSize = CachedAssetBasePath.Directories.Size + kConfig_size + filename.Size + 1; - juliet_snprintf(buffer, totalSize, "%s%s%s", CStr(CachedAssetBasePath), kConfig_str, CStr(filename)); + juliet_snprintf(buffer, totalSize, "%s%s%s", CStr(CachedAssetBasePath.Directories), kConfig_str, CStr(filename)); } break; case AssetType::JAsset: [[fallthrough]]; default: { - Assert(IsValid(CachedAssetBasePath)); + totalSize = CachedAssetBasePath.Directories.Size + filename.Size + 1; - totalSize = CachedAssetBasePath.Size + filename.Size + 1; - - juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedAssetBasePath), CStr(filename)); + juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedAssetBasePath.Directories), CStr(filename)); } break; } - String asset_path = CleanPath(arena, { buffer, totalSize - 1 }); - return asset_path; + String asset_path = CleanPath(arena, { buffer, totalSize - 1 }); + String directories = asset_path; + directories.Size -= filename.Size; + Path path = { directories, asset_path }; + return path; } bool IsAbsolutePath(String path) @@ -97,11 +99,21 @@ String CleanPath(NonNullPtr arena, String path) return Platform::CleanPath(arena, path); } +bool fs_create_directory(String path, bool recursive) +{ + return Platform::fs_create_directory(path, recursive); +} + +bool fs_path_exists(String path) +{ + return Platform::fs_path_exists(path); +} + void InitFilesystem(NonNullPtr arena) { CachedBasePath = Platform::GetBasePath(arena); - String basePath = GetBasePath(); + Path basePath = GetBasePath(); Assert(IsValid(basePath)); // Probe candidate paths base asset folder @@ -112,13 +124,13 @@ void InitFilesystem(NonNullPtr arena) for (const char* candidate : kCandidates) { char probePath[512]; - juliet_snprintf(probePath, sizeof(probePath), "%s%s", CStr(basePath), candidate); + juliet_snprintf(probePath, sizeof(probePath), "%s%s", CStr(basePath.Directories), candidate); if (DirectoryExists(probePath)) { // Clean the path first to remove any relative parts String abs_path = CleanPath(arena, WrapString(probePath)); - CachedAssetBasePath = abs_path; + CachedAssetBasePath = { abs_path, abs_path }; Log(LogLevel::Message, LogCategory::Core, "Asset base path: %s", CStr(abs_path)); break; } @@ -132,13 +144,13 @@ void InitFilesystem(NonNullPtr arena) for (const char* candidate : kCandidatesShader) { char probePath[512]; - juliet_snprintf(probePath, sizeof(probePath), "%s%s", CStr(CachedAssetBasePath), candidate); + juliet_snprintf(probePath, sizeof(probePath), "%s%s", CStr(CachedAssetBasePath.Directories), candidate); if (DirectoryExists(probePath)) { // Clean the path first to remove any relative parts String abs_path = CleanPath(arena, WrapString(probePath)); - CachedShaderBasePath = abs_path; + CachedShaderBasePath = { abs_path, abs_path }; Log(LogLevel::Message, LogCategory::Core, "Asset base path: %s", CStr(abs_path)); break; } @@ -147,10 +159,7 @@ void InitFilesystem(NonNullPtr arena) void ShutdownFilesystem() { - CachedBasePath.Size = 0; - CachedBasePath.Str = nullptr; - CachedAssetBasePath.Size = 0; - CachedAssetBasePath.Str = nullptr; - CachedShaderBasePath.Size = 0; - CachedShaderBasePath.Str = nullptr; + CachedBasePath = {}; + CachedAssetBasePath = {}; + CachedShaderBasePath = {}; } diff --git a/Juliet/src/Core/HAL/Filesystem/Filesystem_Platform.h b/Juliet/src/Core/HAL/Filesystem/Filesystem_Platform.h index 1af6ada..571366d 100644 --- a/Juliet/src/Core/HAL/Filesystem/Filesystem_Platform.h +++ b/Juliet/src/Core/HAL/Filesystem/Filesystem_Platform.h @@ -1,8 +1,12 @@ #pragma once +#include + namespace Platform { - String GetBasePath(NonNullPtr arena); + Path GetBasePath(NonNullPtr arena); bool IsAbsolutePath(String path); String CleanPath(NonNullPtr arena, String path); + bool fs_create_directory(String path, bool recursive); + bool fs_path_exists(String path); } // namespace Platform diff --git a/Juliet/src/Core/HAL/Filesystem/Win32/Win32Filesystem.cpp b/Juliet/src/Core/HAL/Filesystem/Win32/Win32Filesystem.cpp index 72ec360..4cb7b93 100644 --- a/Juliet/src/Core/HAL/Filesystem/Win32/Win32Filesystem.cpp +++ b/Juliet/src/Core/HAL/Filesystem/Win32/Win32Filesystem.cpp @@ -4,10 +4,11 @@ #include #include #include +#include namespace Platform { - String GetBasePath(NonNullPtr arena) + Path GetBasePath(NonNullPtr arena) { // Allocate a buffer that could fit the module size. // Max Path is a good start but could be bigger if the path include long path prefix @@ -53,7 +54,8 @@ namespace Platform Assert(idx > 0 && "Path is not absolute!"); buffer[idx + 1] = '\0'; // Chop chop - return WrapString(buffer); + String result = WrapString(buffer); + return { result, result }; } bool IsAbsolutePath(String path) @@ -104,4 +106,78 @@ namespace Platform return StringCopy(arena, WrapString(clean_path_buffer)); } + + bool fs_create_directory(String path, bool recursive) + { + bool result = true; + TempArena temp = scratch_begin(nullptr, 0); + + String temp_path = StringCopy(temp.Arena, path); + + if (recursive) + { + for (char* c = temp_path.Str; *c != '\0'; c++) + { + if (*c == '\\' || *c == '/') + { + // Found separator, need to skip it in case its "\\NetworkDrive" or "C:\" + if (c == temp_path.Str || *(c - 1) == ':') + { + continue; + } + + // Keep pointer to the separator and "end" the string using a \0 + char separator = *c; + *c = '\0'; + + const bool create_result_recursive = CreateDirectoryA(CStr(temp_path), nullptr); + if (!create_result_recursive) + { + const DWORD error = GetLastError(); + if (error != ERROR_ALREADY_EXISTS) + { + LogError(LogCategory::Core, "Create directory (parent) failed, error %d", error); + result = false; + } + } + + // Restore the string (remove \0) + *c = separator; + } + } + } + + // Final folder + if (result) + { + const bool create_result = CreateDirectoryA(CStr(temp_path), nullptr); + if (!create_result) + { + const DWORD error = GetLastError(); + if (error != ERROR_ALREADY_EXISTS) + { + LogDebug(LogCategory::Core, "Folder already exists"); + result = false; + } + else + { + LogError(LogCategory::Core, "Create directory failed, error %d", error); + result = false; + } + } + } + + scratch_end(temp); + + return result; + } + + bool fs_path_exists(String path) + { + DWORD attribs = GetFileAttributesA(CStr(path)); + + // If the function fails, the file or directory does not exist (or path is invalid) + bool result = (attribs == INVALID_FILE_ATTRIBUTES); + return result; + } } // namespace Platform diff --git a/Juliet/src/Core/HAL/IO/IOStream.cpp b/Juliet/src/Core/HAL/IO/IOStream.cpp index 7c5aafe..6f15eb5 100644 --- a/Juliet/src/Core/HAL/IO/IOStream.cpp +++ b/Juliet/src/Core/HAL/IO/IOStream.cpp @@ -13,6 +13,7 @@ IOStream* IOFromFile(NonNullPtr arena, String filename, String mode) Log(LogLevel::Error, LogCategory::Core, "Trying to open IOStream on invalid filename"); return nullptr; } + if (!IsValid(mode)) { Log(LogLevel::Error, LogCategory::Core, "Trying to open IOStream with invalid mode"); @@ -220,4 +221,3 @@ bool IOClose(NonNullPtr stream) } return result; } - diff --git a/Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp b/Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp index 39d3dcc..a3aca19 100644 --- a/Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp +++ b/Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp @@ -225,7 +225,6 @@ namespace Internal return nullptr; } - // TODO: Detect when folder is missing and create it if in w or a mode. HANDLE hFile = CreateFileA(CStr(filename), (canWrite | canRead), (canWrite) ? 0 : FILE_SHARE_READ, nullptr, (openExisting | createAlways | openAlways), FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) diff --git a/Juliet/src/Core/HotReload/HotReload.cpp b/Juliet/src/Core/HotReload/HotReload.cpp index 7cda30d..98df5d5 100644 --- a/Juliet/src/Core/HotReload/HotReload.cpp +++ b/Juliet/src/Core/HotReload/HotReload.cpp @@ -10,20 +10,19 @@ void InitHotReloadCode(NonNullPtr arena, HotReloadCode& code, String dllName, String transientDllName, String lockFilename) { // Get the app base path and build the dll path from there. - String basePath = GetBasePath(); - size_t basePathLength = StringLength(basePath); + Path basePath = GetBasePath(); + size_t basePathLength = basePath.Directories.Size; // Assign Transient dll path code.TransientDLLName = transientDllName; // First allocate all the full path. // TODO: Add path composition into filesystem + string format + string builder - const size_t dllFullPathLength = - basePathLength + StringLength(dllName) + 1; // Need +1 because snprintf needs 0 terminated strings + const size_t dllFullPathLength = basePathLength + StringLength(dllName) + 1; // Need +1 because snprintf needs 0 terminated strings - code.DLLFullPath.Str = static_cast( - ArenaPush(arena, dllFullPathLength, alignof(char), true JULIET_DEBUG_PARAM("Hot Reload DLL Path"))); - int writtenSize = snprintf(CStr(code.DLLFullPath), dllFullPathLength, "%s%s", CStr(basePath), CStr(dllName)); + code.DLLFullPath.Str = + static_cast(ArenaPush(arena, dllFullPathLength, alignof(char), true JULIET_DEBUG_PARAM("Hot Reload DLL Path"))); + int writtenSize = snprintf(CStr(code.DLLFullPath), dllFullPathLength, "%s%s", CStr(basePath.Directories), CStr(dllName)); if (writtenSize < static_cast(dllFullPathLength) - 1) { Log(LogLevel::Error, LogCategory::Core, "Cannot create DLL Full Path"); @@ -32,11 +31,10 @@ void InitHotReloadCode(NonNullPtr arena, HotReloadCode& code, String dllN code.DLLFullPath.Size = static_cast(writtenSize); // Lock filename path - const size_t lockPathLength = - basePathLength + StringLength(lockFilename) + 1; // Need +1 because snprintf needs 0 terminated strings + const size_t lockPathLength = basePathLength + StringLength(lockFilename) + 1; // Need +1 because snprintf needs 0 terminated strings code.LockFullPath.Str = static_cast( ArenaPush(arena, lockPathLength, alignof(char), true JULIET_DEBUG_PARAM("Hot Reload Lock File Path"))); - writtenSize = snprintf(CStr(code.LockFullPath), lockPathLength, "%s%s", CStr(basePath), CStr(lockFilename)); + writtenSize = snprintf(CStr(code.LockFullPath), lockPathLength, "%s%s", CStr(basePath.Directories), CStr(lockFilename)); if (writtenSize < static_cast(lockPathLength) - 1) { code.LockFullPath.Size = 0; diff --git a/Juliet/src/Core/HotReload/Win32/Win32HotReload.cpp b/Juliet/src/Core/HotReload/Win32/Win32HotReload.cpp index f8a606a..5674b6e 100644 --- a/Juliet/src/Core/HotReload/Win32/Win32HotReload.cpp +++ b/Juliet/src/Core/HotReload/Win32/Win32HotReload.cpp @@ -45,8 +45,8 @@ void LoadCode(HotReloadCode& code) // We'll see for better later. // Get the app base path and build the dll path from there. - String basePath = GetBasePath(); - size_t basePathLength = StringLength(basePath); + Path basePath = GetBasePath(); + size_t basePathLength = basePath.Directories.Size; const size_t tempDllMaxBufferSize = basePathLength + StringLength(code.TransientDLLName) + /* _ */ 1 + kTempDLLBufferSizeForID + 1 /* \0 */; @@ -67,8 +67,8 @@ void LoadCode(HotReloadCode& code) return; } - int writtenSize = snprintf(tempDllPath, tempDllMaxBufferSize, "%s%s_%s", CStr(basePath), idToStr, - CStr(code.TransientDLLName)); + int writtenSize = snprintf(tempDllPath, tempDllMaxBufferSize, "%s%s_%s", CStr(basePath.Directories), + idToStr, CStr(code.TransientDLLName)); if (writtenSize < 0) { // Scratch memory, no free needed diff --git a/Juliet/src/Engine/user.cpp b/Juliet/src/Engine/user.cpp index ebace17..13ccae1 100644 --- a/Juliet/src/Engine/user.cpp +++ b/Juliet/src/Engine/user.cpp @@ -15,14 +15,18 @@ void initialize_user_system() // User name is basically found in a env variable, if not, the local windows user will be used. TempArena temp = scratch_begin(nullptr, 0); - String user_system_path = GetAssetPath(temp.Arena, AssetType::Config, ConstString("users.ini")); - ByteBuffer user_file = LoadFile(temp.Arena, user_system_path); + Path user_system_path = GetAssetPath(temp.Arena, AssetType::Config, ConstString("users.ini")); + const bool file_exists = fs_path_exists(user_system_path.FullPath); String username = os_get_username(temp.Arena); - if (user_file.Size == 0) + if (file_exists) { - IOStream* stream = IOFromFile(temp.Arena, user_system_path, ConstString("w+")); + fs_create_directory(user_system_path.Directories, true); + + Assert(fs_path_exists(user_system_path.Directories), "Couldn't create config folder"); + + IOStream* stream = IOFromFile(temp.Arena, user_system_path.FullPath, ConstString("w+")); Archive ar = { .arena = temp.Arena, .loading = false, .stream = stream }; uint8 id = 1; @@ -32,6 +36,8 @@ void initialize_user_system() } else { + ByteBuffer user_file = LoadFile(temp.Arena, user_system_path.FullPath); + ParsedArchive parsed_archive = tokenize_archive(temp.Arena, user_file); Archive ar = { .arena = temp.Arena, .loading = true, .base = parsed_archive }; diff --git a/Juliet/src/Graphics/DebugDisplayRenderer.cpp b/Juliet/src/Graphics/DebugDisplayRenderer.cpp index baac7dc..b0b9595 100644 --- a/Juliet/src/Graphics/DebugDisplayRenderer.cpp +++ b/Juliet/src/Graphics/DebugDisplayRenderer.cpp @@ -86,13 +86,13 @@ namespace TempArena path = scratch_begin(0, 0); - String vertPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Debug.vert.dxil")); + Path vertPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Debug.vert.dxil")); shaderCI.Stage = ShaderStage::Vertex; - Shader* vertexShader = CreateShader(device, vertPath, shaderCI); + Shader* vertexShader = CreateShader(device, vertPath.FullPath, shaderCI); - String fragPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Debug.frag.dxil")); + Path fragPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Debug.frag.dxil")); shaderCI.Stage = ShaderStage::Fragment; - Shader* fragmentShader = CreateShader(device, fragPath, shaderCI); + Shader* fragmentShader = CreateShader(device, fragPath.FullPath, shaderCI); scratch_end(path); diff --git a/Juliet/src/Graphics/Graphics.cpp b/Juliet/src/Graphics/Graphics.cpp index b5eaa35..8b45a8d 100644 --- a/Juliet/src/Graphics/Graphics.cpp +++ b/Juliet/src/Graphics/Graphics.cpp @@ -196,8 +196,7 @@ void SubmitCommandLists(NonNullPtr commandList) commandListHeader->Device->SubmitCommandLists(commandList); } -RenderPass* BeginRenderPass(NonNullPtr commandList, ColorTargetInfo& colorTargetInfo, - DepthStencilTargetInfo* depthStencilTargetInfo) +RenderPass* BeginRenderPass(NonNullPtr commandList, ColorTargetInfo& colorTargetInfo, DepthStencilTargetInfo* depthStencilTargetInfo) { return BeginRenderPass(commandList, &colorTargetInfo, 1, depthStencilTargetInfo); } @@ -287,16 +286,15 @@ void DrawPrimitives(NonNullPtr renderPass, uint32 numVertices, uint3 commandListHeader->Device->DrawPrimitives(commandList, numVertices, numInstances, firstVertex, firstInstance); } -void DrawIndexedPrimitives(NonNullPtr renderPass, uint32 numIndices, uint32 numInstances, - uint32 firstIndex, uint32 vertexOffset, uint32 firstInstance) +void DrawIndexedPrimitives(NonNullPtr renderPass, uint32 numIndices, uint32 numInstances, uint32 firstIndex, + uint32 vertexOffset, uint32 firstInstance) { auto* commandList = reinterpret_cast(renderPass.Get())->CommandList; auto* commandListHeader = reinterpret_cast(commandList); if (commandListHeader->Device->DrawIndexedPrimitives) { - commandListHeader->Device->DrawIndexedPrimitives(commandList, numIndices, numInstances, firstIndex, - vertexOffset, firstInstance); + commandListHeader->Device->DrawIndexedPrimitives(commandList, numIndices, numInstances, firstIndex, vertexOffset, firstInstance); } } @@ -324,15 +322,6 @@ Shader* CreateShader(NonNullPtr device, String filename, ShaderC { shaderByteCode = LoadFile(fileArena.Arena, filename); } - else - { - // TODO: Add path builder in the lib - String base = GetBasePath(); - char inplaceBuffer[256]; - juliet_snprintf(inplaceBuffer, sizeof(inplaceBuffer), "%s%s", base.Str, filename.Str); - String absolutePath = WrapString(inplaceBuffer); - shaderByteCode = LoadFile(fileArena.Arena, absolutePath); - } if (!IsValid(shaderByteCode)) { @@ -371,8 +360,7 @@ bool UpdateGraphicsPipelineShaders(NonNullPtr device, NonNullPtr GraphicsBuffer* CreateGraphicsBuffer(NonNullPtr device, const BufferCreateInfo& createInfo) { - return device->CreateGraphicsBuffer(device->Driver, createInfo.Size, createInfo.Stride, createInfo.Usage, - createInfo.IsDynamic); + return device->CreateGraphicsBuffer(device->Driver, createInfo.Size, createInfo.Stride, createInfo.Usage, createInfo.IsDynamic); } GraphicsTransferBuffer* CreateGraphicsTransferBuffer(NonNullPtr device, const TransferBufferCreateInfo& createInfo) diff --git a/Juliet/src/Graphics/ImGuiRenderer.cpp b/Juliet/src/Graphics/ImGuiRenderer.cpp index 7ab1a87..e407b5c 100644 --- a/Juliet/src/Graphics/ImGuiRenderer.cpp +++ b/Juliet/src/Graphics/ImGuiRenderer.cpp @@ -131,13 +131,13 @@ bool ImGuiRenderer_Initialize(GraphicsDevice* device) TempArena path = scratch_begin(0, 0); - String vertPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("ImGui.vert.dxil")); + Path vertPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("ImGui.vert.dxil")); shaderCI.Stage = ShaderStage::Vertex; - g_ImGuiState.VertexShader = CreateShader(device, vertPath, shaderCI); + g_ImGuiState.VertexShader = CreateShader(device, vertPath.FullPath, shaderCI); - String fragPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("ImGui.frag.dxil")); + Path fragPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("ImGui.frag.dxil")); shaderCI.Stage = ShaderStage::Fragment; - g_ImGuiState.FragmentShader = CreateShader(device, fragPath, shaderCI); + g_ImGuiState.FragmentShader = CreateShader(device, fragPath.FullPath, shaderCI); scratch_end(path); diff --git a/Juliet/src/Graphics/MeshRenderer.cpp b/Juliet/src/Graphics/MeshRenderer.cpp index a9e0984..31d10bb 100644 --- a/Juliet/src/Graphics/MeshRenderer.cpp +++ b/Juliet/src/Graphics/MeshRenderer.cpp @@ -81,13 +81,13 @@ bool InitializeMeshRendererGraphics(NonNullPtr device, NonNullPt TempArena path = scratch_begin(0, 0); - String shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Triangle.vert.dxil")); + Path shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Triangle.vert.dxil")); shaderCI.Stage = ShaderStage::Vertex; - Shader* vertexShader = CreateShader(graphicsDevice, shaderPath, shaderCI); + Shader* vertexShader = CreateShader(graphicsDevice, shaderPath.FullPath, shaderCI); shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("SolidColor.frag.dxil")); shaderCI.Stage = ShaderStage::Fragment; - Shader* fragmentShader = CreateShader(graphicsDevice, shaderPath, shaderCI); + Shader* fragmentShader = CreateShader(graphicsDevice, shaderPath.FullPath, shaderCI); scratch_end(path); @@ -550,13 +550,13 @@ void ReloadMeshRendererShaders() String entryPoint = WrapString("main"); ShaderCreateInfo shaderCI = {}; shaderCI.EntryPoint = entryPoint; - String shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Triangle.vert.dxil")); + Path shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("Triangle.vert.dxil")); shaderCI.Stage = ShaderStage::Vertex; - Shader* vertexShader = CreateShader(device, shaderPath, shaderCI); + Shader* vertexShader = CreateShader(device, shaderPath.FullPath, shaderCI); shaderPath = GetAssetPath(path.Arena, AssetType::Shader, ConstString("SolidColor.frag.dxil")); shaderCI.Stage = ShaderStage::Fragment; - Shader* fragmentShader = CreateShader(device, shaderPath, shaderCI); + Shader* fragmentShader = CreateShader(device, shaderPath.FullPath, shaderCI); scratch_end(path); diff --git a/Juliet/src/Graphics/SkyboxRenderer.cpp b/Juliet/src/Graphics/SkyboxRenderer.cpp index 36c8f75..244d68a 100644 --- a/Juliet/src/Graphics/SkyboxRenderer.cpp +++ b/Juliet/src/Graphics/SkyboxRenderer.cpp @@ -24,15 +24,15 @@ bool InitializeSkyboxRenderer(NonNullPtr device, NonNullPtr platformArena) { Log(LogLevel::Message, LogCategory::Tool, "Initializing Juliet Application..."); - Log(LogLevel::Message, LogCategory::Tool, "%s", CStr(GetBasePath())); + Log(LogLevel::Message, LogCategory::Tool, "%s", CStr(GetBasePath().Directories)); GraphicsConfig config; #if JULIET_DEBUG