implement pick_dir on windows, upload VS project,

This commit is contained in:
2018-10-08 03:51:05 +02:00
parent c9c7b9f1c4
commit bc64d3c241
7 changed files with 89 additions and 22 deletions

View File

@@ -107,14 +107,14 @@ void async_unlock()
}
}
std::string win32_open_file()
std::string win32_open_file(const char* filter)
{
OPENFILENAMEA ofn;
char fileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = "Image Files (*.jpg, *.png)\0*.jpg;*.png";
ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
@@ -127,6 +127,22 @@ std::string win32_open_file()
return "";
}
std::string win32_open_dir()
{
BROWSEINFOA bi;
char Buffer[MAX_PATH];
ZeroMemory(Buffer, MAX_PATH);
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = hWnd;
bi.pszDisplayName = Buffer;
bi.lpszTitle = "Title";
bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;
LPCITEMIDLIST pFolder = SHBrowseForFolderA(&bi);
if (pFolder == NULL) return "";
if (!SHGetPathFromIDListA(pFolder, Buffer)) return "";
return Buffer;
}
struct async_locker
{
async_locker() { async_lock(); }
@@ -472,12 +488,14 @@ int main(int argc, char** argv)
int frames = 0;
float one_sec = 0;
float render_timer = 0;
float frame_timer = 0;
while(running)
{
t1 = GetTickCount();
float dt = (float)(t1 - t0) / 1000.0f;
one_sec += dt;
render_timer += dt;
frame_timer += dt;
t0 = t1;
if (one_sec > 1.f)
@@ -507,20 +525,22 @@ int main(int argc, char** argv)
}
std::unique_lock<std::mutex> lock(render_mutex);
if (render_timer > 1.0f / target_fps || App::I.redraw)
if (render_timer > 1.0f / target_fps)
{
App::I.redraw = true;
render_timer = 0;
if (App::I.redraw)
{
async_lock();
App::I.redraw = true;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
App::I.clear();
App::I.update(dt);
SwapBuffers(hDC);
async_unlock();
//LOG("swap main");
}
}
if (App::I.redraw)
{
async_lock();
App::I.redraw = true;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
App::I.clear();
App::I.update(frame_timer);
SwapBuffers(hDC);
async_unlock();
frame_timer = 0;
//LOG("swap main");
}
frames++;