Fix resource path handling on macOS
This commit is contained in:
parent
45977b4ac1
commit
f213d3d548
3 changed files with 24 additions and 8 deletions
|
@ -8,7 +8,7 @@
|
||||||
#include "path.hpp"
|
#include "path.hpp"
|
||||||
|
|
||||||
void app_main(prism::engine* engine) {
|
void app_main(prism::engine* engine) {
|
||||||
prism::set_domain_path(prism::domain::app, "data");
|
prism::set_domain_path(prism::domain::app, "{resource_dir}/data");
|
||||||
prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders");
|
prism::set_domain_path(prism::domain::internal, "{resource_dir}/shaders");
|
||||||
|
|
||||||
platform::open_window("Example", {-1, -1, 1280, 720}, WindowFlags::Resizable);
|
platform::open_window("Example", {-1, -1, 1280, 720}, WindowFlags::Resizable);
|
||||||
|
@ -30,8 +30,8 @@ void ExampleApp::initialize_render() {
|
||||||
|
|
||||||
auto sphere_obj = scene->add_object();
|
auto sphere_obj = scene->add_object();
|
||||||
auto& sphere_render = scene->add<Renderable>(sphere_obj);
|
auto& sphere_render = scene->add<Renderable>(sphere_obj);
|
||||||
sphere_render.mesh = assetm->get<Mesh>(prism::path("data/models/sphere.model"));
|
sphere_render.mesh = assetm->get<Mesh>(prism::path(prism::app_domain / "models/sphere.model"));
|
||||||
sphere_render.materials = { assetm->get<Material>(prism::path("data/materials/Material.material")) };
|
sphere_render.materials = { assetm->get<Material>(prism::path(prism::app_domain / "materials/Material.material")) };
|
||||||
|
|
||||||
auto probe_obj = scene->add_object();
|
auto probe_obj = scene->add_object();
|
||||||
scene->add<EnvironmentProbe>(probe_obj);
|
scene->add<EnvironmentProbe>(probe_obj);
|
||||||
|
|
|
@ -15,7 +15,11 @@ add_platform(
|
||||||
|
|
||||||
function(add_platform_commands target)
|
function(add_platform_commands target)
|
||||||
if(NOT SKIP_DATA)
|
if(NOT SKIP_DATA)
|
||||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/data)
|
if(ENABLE_MACOS)
|
||||||
|
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/../Resources/data)
|
||||||
|
else()
|
||||||
|
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/data)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# we HAVE to create this dummy target to convince CMake to properly copy over shader files.
|
# we HAVE to create this dummy target to convince CMake to properly copy over shader files.
|
||||||
|
@ -27,10 +31,18 @@ function(add_platform_commands target)
|
||||||
|
|
||||||
add_custom_target(${DUMMY_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/dummy)
|
add_custom_target(${DUMMY_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/dummy)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/dummy
|
if(ENABLE_MACOS)
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/shaders
|
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/dummy
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/dummy
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/shaders
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_dependencies(${target} ${DUMMY_NAME})
|
add_dependencies(${target} ${DUMMY_NAME})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
#include "string_utils.hpp"
|
#include "string_utils.hpp"
|
||||||
|
|
||||||
void prism::set_domain_path(const prism::domain domain, const prism::path path) {
|
void prism::set_domain_path(const prism::domain domain, const prism::path path) {
|
||||||
|
#ifdef PLATFORM_MACOS
|
||||||
|
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "../Resources/");
|
||||||
|
#else
|
||||||
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
prism::path prism::get_writeable_directory() {
|
prism::path prism::get_writeable_directory() {
|
||||||
|
|
Reference in a new issue