Tweaked help messages, and model loading
This commit is contained in:
parent
87e7db0c87
commit
b25c3d8360
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"date": "2026-08-25T23:21:08.955141949+02:00",
|
"date": "2026-08-26T14:26:46.281424105+02:00",
|
||||||
"data": {
|
"data": {
|
||||||
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/cmake/CLI11GeneratePkgConfig.cmake": [
|
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/cmake/CLI11GeneratePkgConfig.cmake": [
|
||||||
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
|
"/home/alex/Developer/Code/Vulkan-Git/include/CLI11/CMakeLists.txt"
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"date": "2026-08-25T23:21:08.955046741+02:00",
|
"date": "2026-08-26T14:26:46.281337341+02:00",
|
||||||
"data": {
|
"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/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/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/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/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/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/book/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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,6 +221,18 @@ endfunction()
|
|||||||
|
|
||||||
|
|
||||||
# Adds the main binary
|
# Adds the main binary
|
||||||
|
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
lib_list
|
||||||
|
# Libs used
|
||||||
|
glfw
|
||||||
|
fmt
|
||||||
|
vk-bootstrap
|
||||||
|
vulkan
|
||||||
|
CLI11::CLI11
|
||||||
|
fastgltf
|
||||||
|
)
|
||||||
addBinary (
|
addBinary (
|
||||||
engine
|
engine
|
||||||
SOURCE Engine/main
|
SOURCE Engine/main
|
||||||
@ -229,9 +241,9 @@ addBinary (
|
|||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
SHADERS shaders/*
|
SHADERS shaders/*
|
||||||
MODELS assets/models*
|
MODELS *
|
||||||
|
|
||||||
LIBS glfw fmt vk-bootstrap vulkan CLI11::CLI11
|
LIBS ${lib_list}
|
||||||
)
|
)
|
||||||
|
|
||||||
addBinary (
|
addBinary (
|
||||||
|
|||||||
@ -130,7 +130,7 @@ class Engine {
|
|||||||
GPUMeshBuffers rectangle;
|
GPUMeshBuffers rectangle;
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
std::string _modelPath { "models/default.gltf" };
|
std::string _modelPath { "models/basicmesh.glb" };
|
||||||
|
|
||||||
|
|
||||||
void parseConfig(
|
void parseConfig(
|
||||||
@ -221,6 +221,7 @@ class Engine {
|
|||||||
#define ENGINE_IMPL_H
|
#define ENGINE_IMPL_H
|
||||||
//========== Implementation ==========
|
//========== Implementation ==========
|
||||||
// Implementation defines
|
// Implementation defines
|
||||||
|
#define LOADER_IMPL
|
||||||
#define IMAGES_IMPL
|
#define IMAGES_IMPL
|
||||||
#define INITIALIZERS_IMPL
|
#define INITIALIZERS_IMPL
|
||||||
#define DESCRIPTORS_IMPL
|
#define DESCRIPTORS_IMPL
|
||||||
@ -237,6 +238,7 @@ class Engine {
|
|||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "descriptors.h"
|
#include "descriptors.h"
|
||||||
#include "pipelines.h"
|
#include "pipelines.h"
|
||||||
|
#include "loader.h"
|
||||||
#include "Common/Types.h"
|
#include "Common/Types.h"
|
||||||
#include "Common/Timer.h"
|
#include "Common/Timer.h"
|
||||||
#include "Common/Logger.h"
|
#include "Common/Logger.h"
|
||||||
@ -292,7 +294,6 @@ void Engine::parseConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Engine::init() {
|
void Engine::init() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::ifstream infile("LICENSE");
|
std::ifstream infile("LICENSE");
|
||||||
|
|||||||
@ -14,13 +14,69 @@ struct GeoSurface {
|
|||||||
uint32_t count;
|
uint32_t count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MeshAsset {
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
std::vector<GeoSurface> surfaces;
|
||||||
|
GPUMeshBuffers meshBuffers;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Forward declaration
|
||||||
|
|
||||||
|
class Engine;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOADER_IMPL
|
#ifdef LOADER_IMPL
|
||||||
#ifndef LOADER_IMPL_H
|
#ifndef LOADER_IMPL_H
|
||||||
#define LOADER_IMPL_H
|
#define LOADER_IMPL_H
|
||||||
// Main code file
|
// Main code file
|
||||||
|
// Includes
|
||||||
|
#include <fastgltf/core.hpp>
|
||||||
|
#include <fastgltf/types.hpp>
|
||||||
|
#include <fastgltf/glm_element_traits.hpp>
|
||||||
|
#include <fastgltf/tools.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
std::optional<std::vector<std::shared_ptr<MeshAsset>>> 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<std::shared_ptr<MeshAsset>> meshes;
|
||||||
|
// Use the same vectors for all meshes
|
||||||
|
// so that the memory doesn't reallocate
|
||||||
|
// as often
|
||||||
|
|
||||||
|
std::vector<uint32_t> indices;
|
||||||
|
std::vector<Vertex> vertices;
|
||||||
|
|
||||||
|
|
||||||
|
// Debug things
|
||||||
|
return meshes;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -20,10 +20,16 @@ class ArgHandler {
|
|||||||
void buildArgs() {
|
void buildArgs() {
|
||||||
// Setup
|
// Setup
|
||||||
// Subcommands
|
// Subcommands
|
||||||
_run = _app.add_subcommand("run", "Starts the Engine");
|
_run = _app.add_subcommand("run");
|
||||||
|
|
||||||
// Main options/flags
|
// 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
|
// Subcommand options/flags
|
||||||
// Run
|
// Run
|
||||||
@ -59,6 +65,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
handler.printHelp();
|
handler.printHelp();
|
||||||
|
fmt::println("Please use -h or --help to see all available options.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user