diff --git a/CMakeLists.txt b/CMakeLists.txt index 90a05c8b..f6e2194f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,10 +120,10 @@ function(buildExamples) endfunction(buildExamples) if(RESOURCE_INSTALL_DIR) - add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${RESOURCE_INSTALL_DIR}/\") + add_definitions(-DVK_EXAMPLE_ASSETS_DIR=\"${RESOURCE_INSTALL_DIR}/\") install(DIRECTORY data/ DESTINATION ${RESOURCE_INSTALL_DIR}/) else() - add_definitions(-DVK_EXAMPLE_DATA_DIR=\"${CMAKE_SOURCE_DIR}/data/\") + add_definitions(-DVK_EXAMPLE_ASSETS_DIR=\"${CMAKE_SOURCE_DIR}/assets/\") endif() # Compiler specific stuff diff --git a/base/VulkanTools.cpp b/base/VulkanTools.cpp index 25b1ce07..b36b3296 100644 --- a/base/VulkanTools.cpp +++ b/base/VulkanTools.cpp @@ -1,10 +1,10 @@ /* -* Assorted commonly used Vulkan helper functions -* -* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de -* -* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) -*/ + * Assorted commonly used Vulkan helper functions + * + * Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de + * + * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + */ #include "VulkanTools.h" @@ -14,10 +14,24 @@ const std::string getAssetPath() { #if defined(VK_USE_PLATFORM_ANDROID_KHR) return ""; -#elif defined(VK_EXAMPLE_DATA_DIR) - return VK_EXAMPLE_DATA_DIR; +#elif defined(DVK_EXAMPLE_ASSETS_DIR) + return DVK_EXAMPLE_ASSETS_DIR; #else - return "./../data/"; + return "./../assets/"; +#endif +} +#endif + +#if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) +// iOS & macOS: VulkanExampleBase::getAssetPath() implemented externally to allow access to Objective-C components +const std::string getShaderBasePath() +{ +#if defined(VK_USE_PLATFORM_ANDROID_KHR) + return "shaders/"; +#elif defined(DVK_EXAMPLE_SHADERS_DIR) + return DVK_EXAMPLE_SHADERS_DIR; +#else + return "./../shaders/"; #endif } #endif diff --git a/base/VulkanTools.h b/base/VulkanTools.h index c597b696..dc2323ce 100644 --- a/base/VulkanTools.h +++ b/base/VulkanTools.h @@ -61,6 +61,7 @@ #endif const std::string getAssetPath(); +const std::string getShaderBasePath(); namespace vks { diff --git a/download_assets.py b/download_assets.py deleted file mode 100755 index 93a509bf..00000000 --- a/download_assets.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 - -import sys -from urllib.request import urlretrieve -from zipfile import ZipFile - -ASSET_PACK_URL = 'http://vulkan.gpuinfo.org/downloads/vulkan_asset_pack_gltf.zip' -ASSET_PACK_FILE_NAME = 'vulkan_asset_pack_gltf.zip' - -print("Downloading asset pack from '%s'" % ASSET_PACK_URL) - -def reporthook(blocknum, blocksize, totalsize): - bytesread = blocknum * blocksize - if totalsize > 0: - percent = bytesread * 1e2 / totalsize - s = "\r%5.1f%% (%*d / %d bytes)" % (percent, len(str(totalsize)), bytesread, totalsize) - sys.stderr.write(s) - if bytesread >= totalsize: - sys.stderr.write("\n") - else: - sys.stderr.write("read %d\n" % (bytesread,)) - -urlretrieve(ASSET_PACK_URL, ASSET_PACK_FILE_NAME, reporthook) - -print("Download finished") - -print("Extracting assets") - -zip = ZipFile(ASSET_PACK_FILE_NAME, 'r') -zip.extractall("./") -zip.close()