From b25c3d83602aea3b58fe59d76c0a9202bb0abfec Mon Sep 17 00:00:00 2001 From: Alexandre Date: Mon, 31 Aug 2026 01:40:02 +0200 Subject: [PATCH] Tweaked help messages, and model loading --- .cache/neocmakelsp/tree_cmake_map_cache.json | 2 +- .cache/neocmakelsp/tree_map_cache.json | 12 ++--- CMakeLists.txt | 16 +++++- src/Engine/engine/engine.h | 5 +- src/Engine/engine/loader.h | 56 ++++++++++++++++++++ src/Engine/main.cpp | 11 +++- 6 files changed, 89 insertions(+), 13 deletions(-) diff --git a/.cache/neocmakelsp/tree_cmake_map_cache.json b/.cache/neocmakelsp/tree_cmake_map_cache.json index 68c25db..5d7f499 100644 --- a/.cache/neocmakelsp/tree_cmake_map_cache.json +++ b/.cache/neocmakelsp/tree_cmake_map_cache.json @@ -1,5 +1,5 @@ { - "date": "2026-08-25T23:21:08.955141949+02:00", + "date": "2026-08-26T14:26:46.281424105+02:00", "data": { "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/cmake/CLI11GeneratePkgConfig.cmake": [ "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt" diff --git a/.cache/neocmakelsp/tree_map_cache.json b/.cache/neocmakelsp/tree_map_cache.json index 64901c6..bd50fc9 100644 --- a/.cache/neocmakelsp/tree_map_cache.json +++ b/.cache/neocmakelsp/tree_map_cache.json @@ -1,15 +1,15 @@ { - "date": "2026-08-25T23:21:08.955046741+02:00", + "date": "2026-08-26T14:26:46.281337341+02:00", "data": { + "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/docs/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/CMakeLists.txt", "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/modules/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt", + "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/single-include/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", + "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", + "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/subcom_in_files/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt", "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/fuzz/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", - "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/single-include/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/tests/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", - "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/src/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", - "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/docs/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", - "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/book/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt", - "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/subcom_in_files/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/examples/CMakeLists.txt" + "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/book/CMakeLists.txt": "/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt" } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 268b0f8..e026fea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,6 +221,18 @@ endfunction() # Adds the main binary + +list( + APPEND + lib_list + # Libs used + glfw + fmt + vk-bootstrap + vulkan + CLI11::CLI11 + fastgltf +) addBinary ( engine SOURCE Engine/main @@ -229,9 +241,9 @@ addBinary ( LICENSE SHADERS shaders/* - MODELS assets/models* + MODELS * - LIBS glfw fmt vk-bootstrap vulkan CLI11::CLI11 + LIBS ${lib_list} ) addBinary ( diff --git a/src/Engine/engine/engine.h b/src/Engine/engine/engine.h index 12ca13f..b7ae452 100644 --- a/src/Engine/engine/engine.h +++ b/src/Engine/engine/engine.h @@ -130,7 +130,7 @@ class Engine { GPUMeshBuffers rectangle; // Model - std::string _modelPath { "models/default.gltf" }; + std::string _modelPath { "models/basicmesh.glb" }; void parseConfig( @@ -221,6 +221,7 @@ class Engine { #define ENGINE_IMPL_H //========== Implementation ========== // Implementation defines +#define LOADER_IMPL #define IMAGES_IMPL #define INITIALIZERS_IMPL #define DESCRIPTORS_IMPL @@ -237,6 +238,7 @@ class Engine { #include "callbacks.h" #include "descriptors.h" #include "pipelines.h" +#include "loader.h" #include "Common/Types.h" #include "Common/Timer.h" #include "Common/Logger.h" @@ -292,7 +294,6 @@ void Engine::parseConfig( } } - void Engine::init() { #ifdef DEBUG std::ifstream infile("LICENSE"); diff --git a/src/Engine/engine/loader.h b/src/Engine/engine/loader.h index 278e44b..43a4917 100644 --- a/src/Engine/engine/loader.h +++ b/src/Engine/engine/loader.h @@ -14,13 +14,69 @@ struct GeoSurface { uint32_t count; }; +struct MeshAsset { + std::string name; + + std::vector surfaces; + GPUMeshBuffers meshBuffers; +}; + +// Forward declaration + +class Engine; + #endif #ifdef LOADER_IMPL #ifndef LOADER_IMPL_H #define LOADER_IMPL_H // Main code file +// Includes +#include +#include +#include +#include +std::optional>> loadGltfMeshes( + Engine* engine, + std::filesystem::path filePath +) { + auto& logger = engine->_logger; // Uses the main logger + logger.logAll(LogModule::ENGINE, LogLevel::EINFO, "Loading GLTF: {}", filePath.string()); + + fastgltf::Parser parser; + fastgltf::Asset gltf; + auto data = fastgltf::GltfDataBuffer::FromPath(filePath); + + constexpr auto gltfOptions { + fastgltf::Options::LoadExternalBuffers + }; + + auto load = parser.loadGltf( + data.get(), + filePath.parent_path(), + gltfOptions + ); + + if(load) { + gltf = std::move(load.get()); + } else { + logger.logFatal(LogModule::ENGINE, "Failed to load gltf: {}", fastgltf::to_underlying(load.error())); + } + + std::vector> meshes; + // Use the same vectors for all meshes + // so that the memory doesn't reallocate + // as often + + std::vector indices; + std::vector vertices; + + + // Debug things + return meshes; +} + #endif #endif diff --git a/src/Engine/main.cpp b/src/Engine/main.cpp index 7d972ff..647c360 100644 --- a/src/Engine/main.cpp +++ b/src/Engine/main.cpp @@ -20,10 +20,16 @@ class ArgHandler { void buildArgs() { // Setup // Subcommands - _run = _app.add_subcommand("run", "Starts the Engine"); + _run = _app.add_subcommand("run"); // Main options/flags - _app.add_flag("--list-gpu", _listGPU, "Lists available Graphics cards, useful for debugging"); + _app.add_flag("--list-gpu, -l", _listGPU, "Lists available Graphics cards, useful for debugging"); + _app.set_version_flag("--version, -v", BUILD_ID); + + // Help + //_app.set_help_all_flag("--help-all", "Expand all help"); + _app.set_help_flag(); + _app.set_help_all_flag("--help, -h", "Print help for all subcommands"); // Subcommand options/flags // Run @@ -59,6 +65,7 @@ int main(int argc, char* argv[]) { if (argc == 1) { handler.printHelp(); + fmt::println("Please use -h or --help to see all available options."); return 0; }