From 29108cab21dc8e415408d13a5e7db0f71f5cb091 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Thu, 23 May 2024 23:58:45 +0300 Subject: [PATCH] Minor code fixes in order to compile on windows --- openVulkanoCpp/AR/ArRecorder.cpp | 10 +++--- openVulkanoCpp/Base/Version.cpp | 2 +- openVulkanoCpp/Host/ResourceLoader.hpp | 1 + openVulkanoCpp/Host/Windows/SystemInfo.cpp | 36 ++++++++++++---------- openVulkanoCpp/IO/MemMappedFile.cpp | 6 ++-- openVulkanoCpp/Scene/Drawable.hpp | 4 +++ 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/openVulkanoCpp/AR/ArRecorder.cpp b/openVulkanoCpp/AR/ArRecorder.cpp index 24f413f..280485c 100644 --- a/openVulkanoCpp/AR/ArRecorder.cpp +++ b/openVulkanoCpp/AR/ArRecorder.cpp @@ -160,11 +160,11 @@ namespace OpenVulkano::AR { if (!m_colorWriter) { - m_colorWriter = std::make_unique(m_settings.path, "color_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); - m_depthWriter = std::make_unique(m_settings.path, "depth_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); - m_confidenceWriter = std::make_unique(m_settings.path, "confidence_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true); - m_metadataWriter = std::make_unique(m_settings.path, "meta_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true); - m_highResWriter = std::make_unique(m_settings.path, "highres_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); + m_colorWriter = std::make_unique(m_settings.path.string(), "color_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); + m_depthWriter = std::make_unique(m_settings.path.string(), "depth_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); + m_confidenceWriter = std::make_unique(m_settings.path.string(), "confidence_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true); + m_metadataWriter = std::make_unique(m_settings.path.string(), "meta_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true); + m_highResWriter = std::make_unique(m_settings.path.string(), "highres_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true); std::ofstream platformInfoStream(m_settings.path / RECORDING_METADATA_FILENAME); platformInfoStream << m_session->GetSessionMetadata().ToXML(); diff --git a/openVulkanoCpp/Base/Version.cpp b/openVulkanoCpp/Base/Version.cpp index 149ca06..5e8abb3 100644 --- a/openVulkanoCpp/Base/Version.cpp +++ b/openVulkanoCpp/Base/Version.cpp @@ -50,7 +50,7 @@ namespace OpenVulkano { if (numberStr.empty()) return 0; int tmp = 0; - std::from_chars(numberStr.begin(), numberStr.end(), tmp); + std::from_chars(numberStr.data(), numberStr.data() + numberStr.size(), tmp); return tmp; } diff --git a/openVulkanoCpp/Host/ResourceLoader.hpp b/openVulkanoCpp/Host/ResourceLoader.hpp index 50622fe..fb0360b 100644 --- a/openVulkanoCpp/Host/ResourceLoader.hpp +++ b/openVulkanoCpp/Host/ResourceLoader.hpp @@ -6,6 +6,7 @@ #include "Data/Containers/Array.hpp" #include +#include namespace OpenVulkano { diff --git a/openVulkanoCpp/Host/Windows/SystemInfo.cpp b/openVulkanoCpp/Host/Windows/SystemInfo.cpp index 0787450..49a5c70 100644 --- a/openVulkanoCpp/Host/Windows/SystemInfo.cpp +++ b/openVulkanoCpp/Host/Windows/SystemInfo.cpp @@ -13,6 +13,10 @@ #include #include +// NOTE(vb): Windows defines macros like GetUserName that are used to automatically select the appropriate function version (GetUserNameA for ANSI and GetUserNameW for Unicode) +// based on whether the _UNICODE macro is defined, so we manually undefine these macros to avoid naming collisions. +#undef GetUserName + namespace OpenVulkano { namespace @@ -44,7 +48,7 @@ namespace OpenVulkano { switch(type) { - case APP_MEM_TYPE::VM_MAX return counters.PeakWorkingSetSize; + case APP_MEM_TYPE::VM_MAX: return counters.PeakWorkingSetSize; case APP_MEM_TYPE::USED: return counters.PrivateUsage; } } @@ -55,12 +59,12 @@ namespace OpenVulkano size_t SystemInfo::GetSystemRam() { - return ReadSystemMemInfo(MEM_TYPE::TOTAL_PHYS); + return ReadSystemMemInfo(SYS_MEM_TYPE::TOTAL_PHYS); } size_t SystemInfo::GetSystemRamAvailable() { - return ReadSystemMemInfo(MEM_TYPE::AVAIL_PHYS); + return ReadSystemMemInfo(SYS_MEM_TYPE::AVAIL_PHYS); } size_t SystemInfo::GetAppRamMax() @@ -87,7 +91,7 @@ namespace OpenVulkano { char username[UNLEN+1]; DWORD username_len = UNLEN+1; - GetUserName(username, &username_len); + ::GetUserNameA(username, &username_len); return username; } @@ -121,21 +125,21 @@ namespace OpenVulkano return "Windows"; } - Version SystemInfo::GetOsVersion() + OsVersion SystemInfo::GetOsVersion() { - OSVERSIONINFOEX info; - ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx(&info); - return { info.dwMajorVersion, info.dwMinorVersion, 0, info.dwBuildNumber }; + OSVERSIONINFOA info; + ZeroMemory(&info, sizeof(OSVERSIONINFOA)); + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); + GetVersionExA(&info); + return { (int)info.dwMajorVersion, (int)info.dwMinorVersion, 0, (int)info.dwBuildNumber }; } std::string SystemInfo::GetOsNameHumanReadable() { - OSVERSIONINFOEX info; - ZeroMemory(&info, sizeof(OSVERSIONINFOEX)); - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx(&info); + OSVERSIONINFOEXA info; + ZeroMemory(&info, sizeof(OSVERSIONINFOEXA)); + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); + GetVersionEx((OSVERSIONINFOA *)&info); if (info.wProductType == VER_NT_WORKSTATION) { if (info.dwMajorVersion == 10) @@ -151,7 +155,7 @@ namespace OpenVulkano } } - return "Windows " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion); + return "Windows " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion); } else { @@ -168,7 +172,7 @@ namespace OpenVulkano } } - return "Windows Server " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion); + return "Windows Server " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion); } } diff --git a/openVulkanoCpp/IO/MemMappedFile.cpp b/openVulkanoCpp/IO/MemMappedFile.cpp index 71eaf83..f298e7c 100644 --- a/openVulkanoCpp/IO/MemMappedFile.cpp +++ b/openVulkanoCpp/IO/MemMappedFile.cpp @@ -50,7 +50,7 @@ namespace OpenVulkano CloseHandle(fileHandle); return; } - size = fileSize; + size = fileSize.QuadPart; fileMappingHandle = CreateFileMapping( fileHandle, @@ -85,7 +85,7 @@ namespace OpenVulkano ~Internal() { - UnmapViewOfFile(lpMapAddress); + UnmapViewOfFile(address); CloseHandle(fileMappingHandle); CloseHandle(fileHandle); } @@ -120,7 +120,7 @@ namespace OpenVulkano MemMappedFile::MemMappedFile(const std::filesystem::path& path, FileMode fileMode) { - m_internal = std::make_shared(path.c_str(), fileMode); + m_internal = std::make_shared(path.string().c_str(), fileMode); m_data = m_internal->address; m_size = (m_data) ? m_internal->size : 0; } diff --git a/openVulkanoCpp/Scene/Drawable.hpp b/openVulkanoCpp/Scene/Drawable.hpp index db76b90..bc5b49a 100644 --- a/openVulkanoCpp/Scene/Drawable.hpp +++ b/openVulkanoCpp/Scene/Drawable.hpp @@ -11,6 +11,10 @@ #include #include +#ifdef _WIN32 +# undef TRANSPARENT +#endif + namespace OpenVulkano::Scene { class Node;