set data_path to exe location on Windows because the open file dialog change the working directory, change the render loop to update only in case of an event or the animated or redraw is true
This commit is contained in:
@@ -91,9 +91,9 @@ std::string win32_open_file()
|
||||
ofn.lpstrFilter = "Image Files (*.jpg, *.png)\0*.jpg;*.png";
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
||||
ofn.lpstrDefExt = "";
|
||||
ofn.lpstrInitialDir = "Missions\\";
|
||||
ofn.lpstrInitialDir = "";
|
||||
if (GetOpenFileNameA(&ofn) != NULL)
|
||||
{
|
||||
return fileName;
|
||||
@@ -387,26 +387,20 @@ int main(int argc, char** argv)
|
||||
while (running)
|
||||
{
|
||||
// If there any message in the queue process it
|
||||
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||
auto present = App::I.animate || App::I.redraw ?
|
||||
PeekMessage(&msg, 0, 0, 0, PM_REMOVE) : GetMessage(&msg, 0, 0, 0);
|
||||
|
||||
if (present)
|
||||
{
|
||||
running = !(msg.message == WM_QUIT/* || gl.keys[VK_ESCAPE]*/);
|
||||
DispatchMessage(&msg);
|
||||
TranslateMessage(&msg);
|
||||
}
|
||||
else // Otherwise render next frame
|
||||
//else // Otherwise render next frame
|
||||
{
|
||||
t1 = GetTickCount();
|
||||
float dt = (float)(t1 - t0) / 1000.0f;
|
||||
|
||||
// force redraw every one second
|
||||
one_sec += dt;
|
||||
if (one_sec > 1.f)
|
||||
{
|
||||
one_sec = 0;
|
||||
App::I.redraw = true;
|
||||
}
|
||||
|
||||
if (dt > 1.0f / 60.0f)
|
||||
if (dt > 1.0f / 60.0f || App::I.redraw)
|
||||
{
|
||||
t0 = t1;
|
||||
if (App::I.redraw)
|
||||
@@ -421,10 +415,6 @@ int main(int argc, char** argv)
|
||||
//LOG("swap main");
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// Sleep((DWORD)(1.0f / 60.0f * 1000.f));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user