Massive update to start work on asset loading.
This commit is contained in:
parent
8f58570b21
commit
2b312f3494
17 changed files with 346 additions and 58 deletions
|
@ -4,6 +4,7 @@ set(hdrs
|
|||
include/pw/system/input.hpp
|
||||
include/pw/system/path.hpp
|
||||
include/pw/system/window.hpp
|
||||
src/path_internal.in.hpp
|
||||
)
|
||||
|
||||
set(srcs
|
||||
|
@ -13,6 +14,15 @@ set(srcs
|
|||
src/window.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
configure_file(src/path_internal.in.hpp
|
||||
${CMAKE_BINARY_DIR}/include/pw/system/path_internal.hpp
|
||||
@ONLY
|
||||
)
|
||||
|
||||
|
||||
add_library(pwsystem
|
||||
STATIC
|
||||
${hdrs}
|
||||
|
@ -23,6 +33,8 @@ target_include_directories(
|
|||
pwsystem
|
||||
PUBLIC
|
||||
include
|
||||
PRIVATE
|
||||
${CMAKE_BINARY_DIR}/include/
|
||||
)
|
||||
|
||||
target_link_libraries(pwsystem pwcore pwvisual glfw glad)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "pw/system/path.hpp"
|
||||
|
||||
#include "pw/system/path_internal.hpp"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -28,7 +30,14 @@ struct path::impl {
|
|||
|
||||
path &host;
|
||||
|
||||
impl(path &host_) : host(host_) {}
|
||||
std::vector<std::string> internal_paths;
|
||||
|
||||
impl(path &host_) : host(host_)
|
||||
{
|
||||
// TODO: this should only be done in debug/develop mode!!!
|
||||
internal_paths.push_back(std::string(internal::pixwerx_binary_dir));
|
||||
internal_paths.push_back(std::string(internal::pixwerx_source_dir));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -77,8 +86,13 @@ std::string path::executable_path() const
|
|||
DWORD ret = GetModuleFileName( NULL, &lpFname[0], MAXPATHLEN );
|
||||
result.assign(&lpFname[0]);
|
||||
#elif defined(__USE_POSIX)
|
||||
readlink("/proc/self/exe", buf.data(), buf.size());
|
||||
auto read_bytes = readlink("/proc/self/exe", buf.data(), buf.size()); // data is not null-terminated
|
||||
|
||||
// make buffer null - terminated
|
||||
if (read_bytes < buf.size()) buf[read_bytes] = '\0';
|
||||
|
||||
#endif
|
||||
|
||||
result.assign(buf.data());
|
||||
|
||||
return result;
|
||||
|
@ -98,6 +112,9 @@ std::string path::find_file(const std::string&) const
|
|||
path::path()
|
||||
{
|
||||
_impl = std::make_unique<impl>(*this);
|
||||
|
||||
// preset by implementation which should add package resource paths
|
||||
_resource_paths.assign(_impl->internal_paths.begin(),_impl->internal_paths.end());
|
||||
}
|
||||
|
||||
std::string path::get_filename(const std::string& filepath,
|
||||
|
|
16
src/system/src/path_internal.in.hpp
Normal file
16
src/system/src/path_internal.in.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef PW_SYSTEM_PATH_INTERNAL_HPP
|
||||
#define PW_SYSTEM_PATH_INTERNAL_HPP 1
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace pw {
|
||||
namespace internal {
|
||||
|
||||
constexpr std::string_view pixwerx_source_dir { "@CMAKE_SOURCE_DIR@" };
|
||||
constexpr std::string_view pixwerx_binary_dir { "@CMAKE_BINARY_DIR@" };
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue