diff --git a/CMakeLists.txt b/CMakeLists.txt index c86dea3..6cee3d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ if(APPLE) set(CMAKE_Swift_LANGUAGE_VERSION 5.0) enable_language(Swift) file(GLOB_RECURSE sources CONFIGURE_DEPENDS "openVulkanoCpp/*.mm" "openVulkanoCpp/*.m" "openVulkanoCpp/*.c" "openVulkanoCpp/*.cpp" "openVulkanoCpp/*.swift" "examples/*.hpp" "examples/*.cpp") - add_executable(openVulkanoCpp examples/main.cpp ${resources}) + add_executable(openVulkanoCpp examples/main.cpp ${resources} ${GENERATED_SHADER_SOURCES}) else() file(GLOB_RECURSE sources CONFIGURE_DEPENDS "openVulkanoCpp/*.h" "openVulkanoCpp/*.c" "openVulkanoCpp/*.hpp" "openVulkanoCpp/*.cpp" "examples/*.hpp" "examples/*.cpp") file(GLOB SHADER_SRC_FILES ${ROOT_FOLDER}/openVulkanoCpp/Shader/*) diff --git a/cmake/Filter.cmake b/cmake/Filter.cmake index 2cdf3d2..d030112 100644 --- a/cmake/Filter.cmake +++ b/cmake/Filter.cmake @@ -2,6 +2,7 @@ function(FilterPlatformPaths sourcesVar) if (IOS) list(FILTER ${sourcesVar} EXCLUDE REGEX ".*GLFW.*") + list(FILTER ${sourcesVar} EXCLUDE REGEX ".*[\\/]Host[\\/]MacOS[\\/].*") else () list(FILTER ${sourcesVar} EXCLUDE REGEX ".*[\\/]Host[\\/]iOS[\\/].*") list(FILTER ${sourcesVar} EXCLUDE REGEX ".*[\\/]AR[\\/]Provider[\\/]ArKit[\\/].*") diff --git a/openVulkanoCpp/AR/ArSession.cpp b/openVulkanoCpp/AR/ArSession.cpp index cbf3395..cd36b97 100644 --- a/openVulkanoCpp/AR/ArSession.cpp +++ b/openVulkanoCpp/AR/ArSession.cpp @@ -8,7 +8,12 @@ #include "Provider/Playback/ArSessionPlayback.hpp" #include "Provider/Network/ArSessionStream.h" #ifdef __APPLE__ +#include +#if TARGET_OS_MAC +#include "Provider/ArSessionNull.hpp" +#else #include "Provider/ArKit/ArSessionArKit.h" +#endif #else #ifdef ANDROID #include "Provider/ArCore/ArSessionArCore.h" diff --git a/openVulkanoCpp/Host/iOS/BundledResoureLoaderIos.h b/openVulkanoCpp/Host/Apple/BundledResoureLoaderIos.h similarity index 100% rename from openVulkanoCpp/Host/iOS/BundledResoureLoaderIos.h rename to openVulkanoCpp/Host/Apple/BundledResoureLoaderIos.h diff --git a/openVulkanoCpp/Host/iOS/BundledResoureLoaderIos.mm b/openVulkanoCpp/Host/Apple/BundledResoureLoaderIos.mm similarity index 100% rename from openVulkanoCpp/Host/iOS/BundledResoureLoaderIos.mm rename to openVulkanoCpp/Host/Apple/BundledResoureLoaderIos.mm diff --git a/openVulkanoCpp/Host/iOS/MetalViewWindow.h b/openVulkanoCpp/Host/Apple/MetalViewWindow.h similarity index 100% rename from openVulkanoCpp/Host/iOS/MetalViewWindow.h rename to openVulkanoCpp/Host/Apple/MetalViewWindow.h diff --git a/openVulkanoCpp/Host/iOS/MetalViewWindow.mm b/openVulkanoCpp/Host/Apple/MetalViewWindow.mm similarity index 100% rename from openVulkanoCpp/Host/iOS/MetalViewWindow.mm rename to openVulkanoCpp/Host/Apple/MetalViewWindow.mm diff --git a/openVulkanoCpp/Host/iOS/NamedEventProcessor.h b/openVulkanoCpp/Host/Apple/NamedEventProcessor.h similarity index 100% rename from openVulkanoCpp/Host/iOS/NamedEventProcessor.h rename to openVulkanoCpp/Host/Apple/NamedEventProcessor.h diff --git a/openVulkanoCpp/Host/iOS/NamedEventProcessor.mm b/openVulkanoCpp/Host/Apple/NamedEventProcessor.mm similarity index 100% rename from openVulkanoCpp/Host/iOS/NamedEventProcessor.mm rename to openVulkanoCpp/Host/Apple/NamedEventProcessor.mm diff --git a/openVulkanoCpp/Host/MacOS/SystemInfo.mm b/openVulkanoCpp/Host/MacOS/SystemInfo.mm new file mode 100644 index 0000000..4e37d0f --- /dev/null +++ b/openVulkanoCpp/Host/MacOS/SystemInfo.mm @@ -0,0 +1,183 @@ +/* + * 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 "Host/SystemInfo.hpp" +#include "Base/Logger.hpp" +#include + +#include +#include + +#import +#import + +namespace OpenVulkano +{ + Event<> SystemInfo::OnLowPowerModeChanged; + Event<> SystemInfo::OnBatteryStateChanged; + Event<> SystemInfo::OnBatteryLevelChanged; + Event<> SystemInfo::OnDeviceOrientationChanged; + + size_t SystemInfo::GetSystemRam() + { + return [NSProcessInfo processInfo].physicalMemory; + } + + size_t SystemInfo::GetSystemRamAvailable() + { + return 0; //TODO + } + + size_t SystemInfo::GetAppRamMax() + { + return GetAppRamAvailable() + GetAppRamUsed(); + } + + size_t SystemInfo::GetAppVirtualMemoryMax() + { + return INT64_MAX; + } + + size_t SystemInfo::GetAppRamAvailable() + { + return 0; //TODO + } + + size_t SystemInfo::GetAppRamUsed() + { + struct task_basic_info info; + mach_msg_type_number_t size = sizeof(info); + kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size); + if( kerr == KERN_SUCCESS ) + { + return info.resident_size; + } + Logger::PERF->error("Failed to read memory consumption: {}", mach_error_string(kerr)); + return 0; + } + + std::string SystemInfo::GetUserName() + { + return ""; + } + + std::string SystemInfo::GetHostName() + { + return [[NSProcessInfo processInfo].hostName UTF8String]; + } + + std::string SystemInfo::GetDeviceName() + { + return "Mac"; //TODO + } + + std::string SystemInfo::GetDeviceVendorName() + { + return "Apple"; + } + + std::string SystemInfo::GetDeviceModelName() + { + return ""; //TODO + } + + std::string SystemInfo::GetOsName() + { + return ""; //TODO + } + + OsVersion SystemInfo::GetOsVersion() + { + NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion; + return { static_cast(osVersion.majorVersion), static_cast(osVersion.minorVersion), static_cast(osVersion.patchVersion), 0 }; + } + + std::string SystemInfo::GetOsNameHumanReadable() + { + std::stringstream name; + name << GetOsName() << ' ' << GetOsVersion().major; + return name.str(); + } + + DeviceType SystemInfo::GetDeviceType() + { + return DeviceType::PC; + } + + size_t SystemInfo::GetCpuCoreCount() + { + return [NSProcessInfo processInfo].processorCount; + } + + size_t SystemInfo::GetCpuThreadCount() + { + return [NSProcessInfo processInfo].activeProcessorCount; + } + + int32_t SystemInfo::GetCpuTemperature() + { + switch([NSProcessInfo processInfo].thermalState) + { + case NSProcessInfoThermalStateNominal: return 20; + case NSProcessInfoThermalStateFair: return 50; + case NSProcessInfoThermalStateSerious: return 80; + case NSProcessInfoThermalStateCritical: return 100; + } + return -1; + } + + CpuThermalState SystemInfo::GetCpuThermalState() + { + switch([NSProcessInfo processInfo].thermalState) + { + case NSProcessInfoThermalStateNominal: return CpuThermalState::Normal; + case NSProcessInfoThermalStateFair: return CpuThermalState::Fair; + case NSProcessInfoThermalStateSerious: return CpuThermalState::Serious; + case NSProcessInfoThermalStateCritical: return CpuThermalState::Critical; + } + return CpuThermalState::Normal; + } + + bool SystemInfo::IsDeviceInLowPowerMode() + { + return [NSProcessInfo processInfo].lowPowerModeEnabled; + } + + void SystemInfo::EnableEnergyEvents() + { + //TODO + } + + BatteryState SystemInfo::GetDeviceBatteryState() + { + return BatteryState::Unavailable; //TODO + } + + float SystemInfo::GetDeviceBatteryLevel() + { + return 0; //TODO + } + + bool SystemInfo::IsMultitaskingSupported() + { + return true; + } + + DeviceOrientation SystemInfo::GetDeviceOrientation() + { + return DeviceOrientation::LandscapeRight; + } + + void SystemInfo::EnableDeviceOrientationEvents() + { + //TODO? + } + + InterfaceOrientation SystemInfo::GetInterfaceOrientation() + { + return InterfaceOrientation::Landscape; //TODO? + } +}