From 29ac49fb6a43ced4bfb72d0858385b11801d293d Mon Sep 17 00:00:00 2001 From: saschawillems Date: Mon, 21 Mar 2016 20:10:09 +0100 Subject: [PATCH] Function fro getting asset base path depending on operating system --- base/vulkanexamplebase.cpp | 15 ++++++++++++--- base/vulkanexamplebase.h | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 6ffa175b..879f3965 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -86,6 +86,15 @@ std::string VulkanExampleBase::getWindowTitle() return windowTitle; } +const std::string VulkanExampleBase::getAssetPath() +{ +#if defined(__ANDROID__) + return ""; +#else + return "./../data/"; +#endif +} + bool VulkanExampleBase::checkCommandBuffers() { for (auto& cmdBuffer : drawCmdBuffers) @@ -213,15 +222,15 @@ void VulkanExampleBase::prepare() textureLoader = new vkTools::VulkanTextureLoader(physicalDevice, device, queue, cmdPool); } -VkPipelineShaderStageCreateInfo VulkanExampleBase::loadShader(const char * fileName, VkShaderStageFlagBits stage) +VkPipelineShaderStageCreateInfo VulkanExampleBase::loadShader(std::string fileName, VkShaderStageFlagBits stage) { VkPipelineShaderStageCreateInfo shaderStage = {}; shaderStage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shaderStage.stage = stage; #if defined(__ANDROID__) - shaderStage.module = vkTools::loadShader(androidApp->activity->assetManager, fileName, device, stage); + shaderStage.module = vkTools::loadShader(androidApp->activity->assetManager, fileName.c_str(), device, stage); #else - shaderStage.module = vkTools::loadShader(fileName, device, stage); + shaderStage.module = vkTools::loadShader(fileName.c_str(), device, stage); #endif shaderStage.pName = "main"; // todo : make param assert(shaderStage.module != NULL); diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 48aef9e5..32300304 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -112,10 +112,10 @@ protected: // Command buffer submission and execution VkSemaphore renderComplete; } semaphores; - - // Simple texture loader vkTools::VulkanTextureLoader *textureLoader = nullptr; + // Returns the base asset path (for shaders, models, textures) depending on the os + const std::string getAssetPath(); public: bool prepared = false; uint32_t width = 1280; @@ -247,7 +247,7 @@ public: virtual void prepare(); // Load a SPIR-V shader - VkPipelineShaderStageCreateInfo loadShader(const char* fileName, VkShaderStageFlagBits stage); + VkPipelineShaderStageCreateInfo loadShader(std::string fileName, VkShaderStageFlagBits stage); // Create a buffer, fill it with data and bind buffer memory // Can be used for e.g. vertex or index buffer based on mesh data