update UI for file open dialog (BROKEN!)

pull/2/head
InkSoul 2023-06-01 00:05:36 +08:00
parent 88660a8f35
commit e5d0cb92cf
4 changed files with 40 additions and 18 deletions

View File

@ -3,10 +3,15 @@
// win32 api IFileOpenDialog // win32 api IFileOpenDialog
PWSTR GUIFunction::openFileFolderDialog(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
// TO DO: rewrite this function to bool and get file path through public value
bool GUIFunction::openFileFolderDialog()
{ {
//initialize COM lib //initialize COM lib
HRESULT hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); HRESULT hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hResult)) if (SUCCEEDED(hResult))
{ {
IFileOpenDialog* pFileOpen = nullptr; IFileOpenDialog* pFileOpen = nullptr;
@ -27,21 +32,25 @@ PWSTR GUIFunction::openFileFolderDialog(HINSTANCE hInstance, HINSTANCE, PWSTR pC
{ {
PWSTR pszFilePath; PWSTR pszFilePath;
hResult = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath); hResult = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
filePath = pszFilePath;
// Display the file name to the user. // Display the file name to the user.
if (SUCCEEDED(hResult)) if (SUCCEEDED(hResult))
{ {
MessageBoxW(NULL, pszFilePath, L"File Path", MB_OK); MessageBoxW(NULL, pszFilePath, L"File Path", MB_OK);
CoTaskMemFree(pszFilePath); CoTaskMemFree(pszFilePath);
stringFilePath == pszFilePath;
} }
pItem->Release(); pItem->Release();
} }
return true;
} }
pFileOpen->Release(); pFileOpen->Release();
return false;
} }
CoUninitialize(); CoUninitialize();
return false;
} }
return stringFilePath; return false;
}; };

View File

@ -8,20 +8,16 @@
class GUIFunction class GUIFunction
{ {
public: public:
GUIFunction();
~GUIFunction();
PWSTR openFileFolderDialog(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow); PWSTR filePath;
bool openFileFolderDialog();
private: private:
PWSTR stringFilePath;
}; };
GUIFunction::GUIFunction()
{
}
GUIFunction::~GUIFunction()
{
}

View File

@ -1,4 +1,3 @@
#pragma once
/* /*
* Vulkan Example - glTF scene loading and rendering * Vulkan Example - glTF scene loading and rendering
@ -31,6 +30,7 @@
#include "render.h" #include "render.h"
#include "GUIFunction.h"
@ -1287,7 +1287,7 @@
auto tEnd = std::chrono::high_resolution_clock::now(); auto tEnd = std::chrono::high_resolution_clock::now();
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count(); auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
std::cout << "Generating pre-filtered enivornment cube with " << numMips << " mip levels took " << tDiff << " ms" << std::endl; std::cout << "Generating pre-filtered environment cube with " << numMips << " mip levels took " << tDiff << " ms" << std::endl;
} }
void VulkanExample::GenerateBRDFLUT() void VulkanExample::GenerateBRDFLUT()
@ -1650,6 +1650,22 @@
{ {
overlay->checkBox("Pause", &paused); overlay->checkBox("Pause", &paused);
} }
if (overlay->header("file"))
{
if (overlay->button("select model"))
{
GUIFunction guiFunc{};
if (guiFunc.openFileFolderDialog())
{
std::cout << guiFunc.filePath << std::endl;
}
else
{
std::cerr << "file select error" << std::endl;
}
}
}
} }

View File

@ -27,6 +27,7 @@
#include "vulkanexamplebase.h" #include "vulkanexamplebase.h"
#include "glTFModel.h" #include "glTFModel.h"
#define ENABLE_VALIDATION false #define ENABLE_VALIDATION false