Merge branch 'master' into tests_fs_utils
This commit is contained in:
8
3rdParty/msdf/CMakeLists.txt
vendored
8
3rdParty/msdf/CMakeLists.txt
vendored
@@ -13,11 +13,11 @@ if (ENABLE_MSDF)
|
||||
set(FREETYPE_REPO https://github.com/freetype/freetype.git)
|
||||
endif()
|
||||
|
||||
unset(Freetype_FOUND)
|
||||
if (NOT APPLE)
|
||||
find_package(Freetype QUIET)
|
||||
unset(freetype_FOUND)
|
||||
if (NOT IOS)
|
||||
find_package(freetype QUIET)
|
||||
endif ()
|
||||
if (NOT Freetype_FOUND OR NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/freetype-src/build")
|
||||
if (NOT freetype_FOUND OR NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/freetype-src/build")
|
||||
message("Installing freetype from sources")
|
||||
FetchContent_Declare(
|
||||
freetype
|
||||
|
||||
57
openVulkanoCpp/Host/MacOS/ResourceLoaderAppDirMacOS.cpp
Normal file
57
openVulkanoCpp/Host/MacOS/ResourceLoaderAppDirMacOS.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "ResourceLoaderAppDirMacOS.hpp"
|
||||
#include "Base/Utils.hpp"
|
||||
#include <unistd.h>
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void* HANDLE = ResourceLoader::RegisterResourceLoader(std::make_unique<ResourceLoaderAppDirMacOS>());
|
||||
|
||||
std::string FindAppDir()
|
||||
{
|
||||
char pathBuffer[PATH_MAX];
|
||||
uint32_t bufferSize = sizeof(pathBuffer);
|
||||
|
||||
if (_NSGetExecutablePath(pathBuffer, &bufferSize) == 0)
|
||||
{
|
||||
char resolvedPath[PATH_MAX];
|
||||
if (realpath(pathBuffer, resolvedPath) != nullptr)
|
||||
{
|
||||
std::string_view appDirPath(resolvedPath);
|
||||
appDirPath = appDirPath.substr(0, appDirPath.find_last_of('/') + 1);
|
||||
return std::string(appDirPath);
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "Failed to find real path to application!";
|
||||
return "";
|
||||
}
|
||||
|
||||
const std::string& GetAppDir()
|
||||
{
|
||||
static const std::string appDirPath = FindAppDir();
|
||||
return appDirPath;
|
||||
}
|
||||
}
|
||||
|
||||
std::string ResourceLoaderAppDirMacOS::GetResourcePath(const std::string& resourceName)
|
||||
{
|
||||
return GetAppDir() + resourceName;
|
||||
}
|
||||
|
||||
Array<char> ResourceLoaderAppDirMacOS::GetResource(const std::string& resourceName)
|
||||
{
|
||||
return Utils::ReadFile(GetAppDir() + resourceName, true);
|
||||
}
|
||||
}
|
||||
19
openVulkanoCpp/Host/MacOS/ResourceLoaderAppDirMacOS.hpp
Normal file
19
openVulkanoCpp/Host/MacOS/ResourceLoaderAppDirMacOS.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Host/ResourceLoader.hpp"
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
class ResourceLoaderAppDirMacOS final : public ResourceLoader
|
||||
{
|
||||
public:
|
||||
std::string GetResourcePath(const std::string& resourceName) override;
|
||||
Array<char> GetResource(const std::string& resourceName) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user