mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 07:24:34 +00:00
example: Add config file to locate shaders
The example triangle now will have a absolute filepath to the shaders. This allows running the exe from directories other than the location of the shaders in the filesystem. Alternative solutions would be to copy/paste the shader binary into the source code.
This commit is contained in:
parent
82459b10c0
commit
23dcdd59bf
@ -5,6 +5,7 @@ target_link_libraries(vk-bootstrap-triangle
|
|||||||
vk-bootstrap
|
vk-bootstrap
|
||||||
vk-bootstrap-compiler-warnings
|
vk-bootstrap-compiler-warnings
|
||||||
vk-boostrap-vulkan-headers)
|
vk-boostrap-vulkan-headers)
|
||||||
|
target_include_directories(vk-bootstrap-triangle PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) #path to build directory for shaders
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET vk-bootstrap-triangle
|
TARGET vk-bootstrap-triangle
|
||||||
@ -13,3 +14,8 @@ add_custom_command(
|
|||||||
${CMAKE_COMMAND} -E copy_directory
|
${CMAKE_COMMAND} -E copy_directory
|
||||||
${CMAKE_SOURCE_DIR}/example/shaders ${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_SOURCE_DIR}/example/shaders ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR})
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/example/example_config.h.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/example_config.h"
|
||||||
|
)
|
4
example/example_config.h.in
Normal file
4
example/example_config.h.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define EXAMPLE_SOURCE_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
#define EXAMPLE_BUILD_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "../tests/common.h"
|
#include "../tests/common.h"
|
||||||
|
|
||||||
|
#include "example_config.h"
|
||||||
|
|
||||||
const int MAX_FRAMES_IN_FLIGHT = 2;
|
const int MAX_FRAMES_IN_FLIGHT = 2;
|
||||||
|
|
||||||
struct Init {
|
struct Init {
|
||||||
@ -184,8 +186,8 @@ VkShaderModule createShaderModule (Init& init, const std::vector<char>& code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int create_graphics_pipeline (Init& init, RenderData& data) {
|
int create_graphics_pipeline (Init& init, RenderData& data) {
|
||||||
auto vert_code = readFile ("vert.spv");
|
auto vert_code = readFile(std::string(EXAMPLE_BUILD_DIRECTORY) + "/vert.spv");
|
||||||
auto frag_code = readFile ("frag.spv");
|
auto frag_code = readFile(std::string(EXAMPLE_BUILD_DIRECTORY) + "/frag.spv");
|
||||||
|
|
||||||
VkShaderModule vert_module = createShaderModule (init, vert_code);
|
VkShaderModule vert_module = createShaderModule (init, vert_code);
|
||||||
VkShaderModule frag_module = createShaderModule (init, frag_code);
|
VkShaderModule frag_module = createShaderModule (init, frag_code);
|
||||||
|
Loading…
Reference in New Issue
Block a user