From 4d91720ccce576bc2b7bf33f0eab49ae571c97fe Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Sat, 23 Nov 2024 15:09:18 +0100 Subject: [PATCH] Minor code cleanup --- base/VulkanTools.cpp | 13 +++---------- base/VulkanTools.h | 4 +--- base/vulkanexamplebase.cpp | 3 +-- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/base/VulkanTools.cpp b/base/VulkanTools.cpp index 1281c02b..d2a4afc5 100644 --- a/base/VulkanTools.cpp +++ b/base/VulkanTools.cpp @@ -1,7 +1,7 @@ /* * Assorted commonly used Vulkan helper functions * - * Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de + * Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ @@ -12,7 +12,7 @@ // iOS & macOS: getAssetPath() and getShaderBasePath() implemented externally for access to Obj-C++ path utilities const std::string getAssetPath() { -if(vks::tools::resourcePathSet){ +if (vks::tools::resourcePath != "") { return vks::tools::resourcePath + "/assets/"; } #if defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -24,15 +24,9 @@ if(vks::tools::resourcePathSet){ #endif } -void setResourcePath(std::string path) -{ - vks::tools::resourcePath = path; - vks::tools::resourcePathSet = true; -} - const std::string getShaderBasePath() { -if(vks::tools::resourcePathSet){ +if (vks::tools::resourcePath != "") { return vks::tools::resourcePath + "/shaders/"; } #if defined(VK_USE_PLATFORM_ANDROID_KHR) @@ -50,7 +44,6 @@ namespace vks namespace tools { bool errorModeSilent = false; - bool resourcePathSet = false; std::string resourcePath = ""; std::string errorString(VkResult errorCode) diff --git a/base/VulkanTools.h b/base/VulkanTools.h index c504d6a9..83fde608 100644 --- a/base/VulkanTools.h +++ b/base/VulkanTools.h @@ -61,16 +61,14 @@ #endif const std::string getAssetPath(); -void setResourcePath(std::string path); const std::string getShaderBasePath(); namespace vks { namespace tools { - /** @brief Variables for Command Line Resource Path */ + /** @brief Setting this path chnanges the place where the samples looks for assets and shaders */ extern std::string resourcePath; - extern bool resourcePathSet; /** @brief Disable message boxes on fatal errors */ extern bool errorModeSilent; diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 713b682a..2564252a 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -856,8 +856,7 @@ VulkanExampleBase::VulkanExampleBase() } #if (!(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))) if(commandLineParser.isSet("resourcepath")) { - std::string path = commandLineParser.getValueAsString("resourcepath", ""); - setResourcePath(path); + vks::tools::resourcePath = commandLineParser.getValueAsString("resourcepath", ""); } #endif