Changed assets and shader path functions, removed asset download script

This commit is contained in:
Sascha Willems 2023-05-09 21:05:01 +02:00
parent 99b226237a
commit c13ba757b7
4 changed files with 26 additions and 42 deletions

View file

@ -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

View file

@ -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

View file

@ -61,6 +61,7 @@
#endif
const std::string getAssetPath();
const std::string getShaderBasePath();
namespace vks
{

View file

@ -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()