fix loading error when loading from Chinese path
parent
59ea17fe3f
commit
d8f01324d0
|
@ -1,10 +1,3 @@
|
|||
/*
|
||||
* Vulkan utilities
|
||||
*
|
||||
* Copyright(C) 2018 by Sascha Willems - www.saschawillems.de
|
||||
*
|
||||
* This code is licensed under the MIT license(MIT) (http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1687,23 +1687,27 @@ PlumageRender::PlumageRender()
|
|||
// TO DO : language switch
|
||||
if (gui->header(chineseUI.model)) {
|
||||
if (gui->button(chineseUI.openNewModel)) {
|
||||
std::string filename = "";
|
||||
char buffer[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
std::wstring filename = L"";
|
||||
wchar_t buffer[MAX_PATH];
|
||||
OPENFILENAMEW ofn;
|
||||
ZeroMemory(&buffer, sizeof(buffer));
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.lpstrFilter = "glTF files\0*.gltf;*.glb\0";
|
||||
ofn.lpstrFilter = L"glTF files\0*.gltf;*.glb\0";
|
||||
ofn.lpstrFile = buffer;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrTitle = "Select a glTF file to load";
|
||||
ofn.lpstrTitle = L"Select a glTF file to load";
|
||||
ofn.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
|
||||
if (GetOpenFileNameA(&ofn)) {
|
||||
if (GetOpenFileNameW(&ofn)) {
|
||||
filename = buffer;
|
||||
|
||||
}
|
||||
|
||||
if (!filename.empty()) {
|
||||
vkDeviceWaitIdle(device);
|
||||
loadScene(filename);
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
std::string stringFilename = converter.to_bytes(filename);
|
||||
loadScene(stringFilename);
|
||||
setupDescriptors();
|
||||
updateCBs = true;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include<io.h>
|
||||
#include <io.h>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "algorithm"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue