diff --git a/flake.nix b/flake.nix index a498e05..ff7453c 100644 --- a/flake.nix +++ b/flake.nix @@ -40,14 +40,12 @@ inherit (sources.${name}) pname version src; }; - fmt = mkPkg "fmt"; imgui = (mkPkg "imgui").override { IMGUI_BUILD_GLFW_BINDING = true; IMGUI_BUILD_VULKAN_BINDING = true; }; deps = with pkgs; [ - fmt glfw glm imgui diff --git a/meson.build b/meson.build index 166a91f..a2791b3 100644 --- a/meson.build +++ b/meson.build @@ -21,7 +21,6 @@ common_cpp_args = [ add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp') deps = [ - dependency('fmt', include_type: 'system'), dependency('glfw3', include_type: 'system'), dependency('glm', include_type: 'system'), dependency('vulkan', include_type: 'system'), diff --git a/nvfetcher.toml b/nvfetcher.toml index 2a9fc5e..a70874f 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -1,7 +1,3 @@ -[fmt] -src.github = "fmtlib/fmt" -fetch.github = "fmtlib/fmt" - [imgui] src.git = "https://github.com/ocornut/imgui.git" src.branch = "docking" diff --git a/src/gui/imgui_manager.cpp b/src/gui/imgui_manager.cpp index 78b592c..4fd8b0b 100644 --- a/src/gui/imgui_manager.cpp +++ b/src/gui/imgui_manager.cpp @@ -1,5 +1,3 @@ -#include - #include "imgui_manager.hpp" ImGuiManager::~ImGuiManager() { cleanup(); } diff --git a/src/init/debug_messenger.cpp b/src/init/debug_messenger.cpp index 079c845..5d5438a 100644 --- a/src/init/debug_messenger.cpp +++ b/src/init/debug_messenger.cpp @@ -1,9 +1,14 @@ -#define FMT_HEADER_ONLY -#include -#include - #include "debug_messenger.hpp" +namespace { + constexpr std::string_view ANSI_RESET = "\033[0m"; + constexpr std::string_view ANSI_BOLD = "\033[1m"; + constexpr std::string_view ANSI_RED = "\033[31m"; + constexpr std::string_view ANSI_YELLOW = "\033[33m"; + constexpr std::string_view ANSI_LIGHT_BLUE = "\033[94m"; + constexpr std::string_view ANSI_WHITE = "\033[97m"; +} + fn DebugMessenger::create(const vk::Instance& instance, Config config) -> std::expected { #ifdef NDEBUG @@ -19,7 +24,7 @@ fn DebugMessenger::create(const vk::Instance& instance, Config config) return instance.createDebugUtilsMessengerEXTUnique(createInfo); } catch (const vk::SystemError& e) { - return std::unexpected(fmt::format("Failed to create debug messenger: {}", e.what())); + return std::unexpected(std::format("Failed to create debug messenger: {}", e.what())); } #endif } @@ -44,9 +49,9 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessenger::debugCallback( if (config && config->use_stderr_for_errors && (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)) { - fmt::println(stderr, "{}", formattedMessage); + std::println(stderr, "{}", formattedMessage); } else { - fmt::println("{}", formattedMessage); + std::println("{}", formattedMessage); } return VK_FALSE; @@ -54,24 +59,24 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessenger::debugCallback( fn DebugMessenger::formatMessage(const Message& msg) -> std::string { // Color based on severity - fmt::color textColor = fmt::color::white; + std::string_view colorCode = ANSI_WHITE; std::string_view severityText; switch (msg.severity) { case vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose: - textColor = fmt::color::light_blue; + colorCode = ANSI_LIGHT_BLUE; severityText = "VERBOSE"; break; case vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo: - textColor = fmt::color::white; + colorCode = ANSI_WHITE; severityText = "INFO"; break; case vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning: - textColor = fmt::color::yellow; + colorCode = ANSI_YELLOW; severityText = "WARNING"; break; case vk::DebugUtilsMessageSeverityFlagBitsEXT::eError: - textColor = fmt::color::red; + colorCode = ANSI_RED; severityText = "ERROR"; break; } @@ -86,13 +91,15 @@ fn DebugMessenger::formatMessage(const Message& msg) -> std::string { typeStr += "PERFORMANCE "; // Format the message with color and structure - return fmt::format( - fmt::emphasis::bold | fg(textColor), - "[{}] {} {}{}: {}", + return std::format( + "{}{}[{}] {} {}{}: {}{}", + colorCode, + ANSI_BOLD, severityText, typeStr, - msg.function_name.has_value() ? fmt::format("in {} ", *msg.function_name) : "", + msg.function_name.has_value() ? std::format("in {} ", *msg.function_name) : "", msg.id, - msg.message + msg.message, + ANSI_RESET ); } diff --git a/src/init/device_manager.cpp b/src/init/device_manager.cpp index c2efde3..8ae0927 100644 --- a/src/init/device_manager.cpp +++ b/src/init/device_manager.cpp @@ -2,11 +2,9 @@ #include #include -#define FMT_HEADER_ONLY -#include +#include "device_manager.hpp" #include "../structs/swap_chain_support_details.hpp" -#include "device_manager.hpp" struct PhysicalDeviceInfo { vk::PhysicalDevice physical_device; @@ -33,7 +31,7 @@ fn DeviceManager::pickPhysicalDevice( return std::unexpected("Failed to find GPUs with Vulkan support!"); #ifndef NDEBUG - fmt::println("Available devices:"); + std::println("Available devices:"); #endif // Find the first suitable device using ranges @@ -47,9 +45,9 @@ fn DeviceManager::pickPhysicalDevice( vk::PhysicalDeviceProperties deviceProperties = suitableDevice->getProperties(); #ifndef NDEBUG - fmt::println("\t{}", deviceProperties.deviceName.data()); - fmt::println("Maximum supported line width: {}", deviceProperties.limits.lineWidthRange[1]); - fmt::println("Wide lines supported: {}", deviceProperties.limits.lineWidthRange[1] > 1.0F ? "yes" : "no"); + std::println("\t{}", deviceProperties.deviceName.data()); + std::println("Maximum supported line width: {}", deviceProperties.limits.lineWidthRange[1]); + std::println("Wide lines supported: {}", deviceProperties.limits.lineWidthRange[1] > 1.0F ? "yes" : "no"); #endif return PhysicalDeviceInfo { @@ -113,7 +111,7 @@ fn DeviceManager::createLogicalDevice( .present_queue = presentQueue, }; } catch (const vk::SystemError& e) { - return std::unexpected(fmt::format("Failed to create logical device: {}", e.what())); + return std::unexpected(std::format("Failed to create logical device: {}", e.what())); } } diff --git a/src/init/vulkan_instance.cpp b/src/init/vulkan_instance.cpp index 8771801..01424da 100644 --- a/src/init/vulkan_instance.cpp +++ b/src/init/vulkan_instance.cpp @@ -1,7 +1,5 @@ #define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 -#include - #include "vulkan_instance.hpp" #include "../util/constants.hpp" @@ -29,8 +27,8 @@ fn VulkanInstance::create() -> vk::UniqueInstance { std::vector extensions = getRequiredExtensions(); #ifndef NDEBUG - fmt::println("Available extensions:"); - for (const char* extension : extensions) { fmt::println("\t{}", extension); } + std::println("Available extensions:"); + for (const char* extension : extensions) { std::println("\t{}", extension); } #endif // Create the instance diff --git a/src/main.cpp b/src/main.cpp index 7792b9a..373e1fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,5 @@ // Include necessary headers -#include // For time-related functions -#define FMT_HEADER_ONLY -#include // For string formatting +#include // For time-related functions #include // For shader compilation #include // For unordered_set container #include @@ -258,9 +256,9 @@ class VulkanApp { try { mDevice->waitIdle(); createGraphicsPipeline(); - fmt::println("Shaders reloaded successfully!"); + std::println("Shaders reloaded successfully!"); } catch (const std::exception& e) { - fmt::println(stderr, "Failed to reload shaders: {}", e.what()); + std::println(stderr, "Failed to reload shaders: {}", e.what()); } } }, @@ -406,7 +404,7 @@ class VulkanApp { if (currentFrame - lastFpsUpdate > 1.0) { WindowManager::setTitle( mWindow.get(), - fmt::format("Vulkan - {:.0f}FPS", static_cast(frameCounter / (currentFrame - lastFpsUpdate))) + std::format("Vulkan - {:.0f}FPS", static_cast(frameCounter / (currentFrame - lastFpsUpdate))) ); lastFpsUpdate = currentFrame; frameCounter = 0; @@ -2542,7 +2540,7 @@ class VulkanApp { // Print the message to the console // Because pCallbackData already gives the message severity // and type, we don't need to print them, so they're unused. - fmt::println("Validation layer: {}", pCallbackData->pMessage); + std::println("Validation layer: {}", pCallbackData->pMessage); return vk::False; } @@ -2567,7 +2565,7 @@ fn main() -> i32 { try { app.run(); } catch (const std::exception& e) { - fmt::println("{}", e.what()); + std::println("{}", e.what()); return EXIT_FAILURE; } diff --git a/src/util/shaders.hpp b/src/util/shaders.hpp index b6d43a4..f728882 100644 --- a/src/util/shaders.hpp +++ b/src/util/shaders.hpp @@ -10,7 +10,6 @@ #pragma once #include -#include #include #include #include @@ -68,14 +67,14 @@ class ShaderCompiler { // Cache is up to date, load it vector spirvCode = loadCachedShader(cacheFile); if (!spirvCode.empty()) { - fmt::println("Loaded shader from cache: {}", cacheFile.string()); + std::println("Loaded shader from cache: {}", cacheFile.string()); return spirvCode; } } } // Need to compile the shader - fmt::println("Compiling shader: {}", absPath.string()); + std::println("Compiling shader: {}", absPath.string()); // Read shader source ifstream file(absPath); diff --git a/src/util/unique_image.hpp b/src/util/unique_image.hpp index 7714ce2..dc5e9e6 100644 --- a/src/util/unique_image.hpp +++ b/src/util/unique_image.hpp @@ -8,7 +8,6 @@ */ #include -#include #define STB_IMAGE_IMPLEMENTATION #include @@ -130,7 +129,7 @@ namespace stb { fn load(const char* path) -> void { mData = stbi_load(path, &mWidth, &mHeight, &mChannels, STBI_rgb_alpha); if (!mData) - throw std::runtime_error(fmt::format("Failed to load texture image: {}", path)); + throw std::runtime_error(std::format("Failed to load texture image: {}", path)); } u8* mData = nullptr; ///< Raw image data in memory diff --git a/src/window/window_manager.cpp b/src/window/window_manager.cpp index ec86f35..3763340 100644 --- a/src/window/window_manager.cpp +++ b/src/window/window_manager.cpp @@ -32,7 +32,7 @@ fn WindowManager::create(const char* title, const WindowCallbacks& callbacks) i32 ypos = (videoMode->height - HEIGHT) / 2; // Set window position - // window->setPos(xpos, ypos); + window->setPos(xpos, ypos); // Configure cursor for FPS-style camera control window->set(vkfw::CursorMode::eDisabled); @@ -72,5 +72,5 @@ fn WindowManager::setCursorMode(const vkfw::Window& window, vkfw::CursorMode mod } fn WindowManager::setPosition(const vkfw::Window& window, i32 xpos, i32 ypos) -> void { - // window.setPos(xpos, ypos); + window.setPos(xpos, ypos); }