android 平台跑通中文路径

This commit is contained in:
xsl
2025-10-28 22:24:24 +08:00
parent 1dfc63543f
commit 13357ab256
20 changed files with 149 additions and 39 deletions
+19 -1
View File
@@ -17,6 +17,7 @@
#define logOut std::cout
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <windows.h>
#else
#include "../app/src/main/cpp/AndroidOut.h"
#define logOut aout
@@ -69,7 +70,7 @@ public:
//std::string getPath(const std::string path);
VkShaderModule createShaderModule(VkDevice& device, const std::vector<char>& code);
const std::vector<const char*> validationLayers = {"VK_LAYER_KHRONOS_validation"};
protected:
long long getCurrentTimeMillis() {
auto now = std::chrono::system_clock::now();
auto duration = now.time_since_epoch();
@@ -87,6 +88,23 @@ protected:
void pickPhysicalDevice(VkPhysicalDevice& physicalDevice, VkSurfaceKHR& surface);
#ifdef _WIN32
GLFWwindow *window;
std::vector<unsigned char> readFileUnsignedCharWin32(const std::wstring path, bool example);
static std::wstring UTF8ToWideString(const std::string& utf8str)
{
if (utf8str.empty()) return L"";
int wideLen = MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(),
-1, nullptr, 0);
if (wideLen == 0) {
throw std::runtime_error("UTF-8转换失败");
}
std::vector<wchar_t> buffer(wideLen);
MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), -1,
buffer.data(), wideLen);
return std::wstring(buffer.data());
}
#endif
bool enableValidationLayers = true;