implement global tick routine in windows

This commit is contained in:
2018-10-08 12:55:01 +02:00
parent 6352f5afe1
commit 365af43891

View File

@@ -483,6 +483,7 @@ int main(int argc, char** argv)
std::thread renderer([&] {
BT_SetTerminate();
const float target_fps = 10;
const float target_tick_rate = 60;
unsigned long t0 = GetTickCount();
unsigned long t1;
int frames = 0;
@@ -514,16 +515,21 @@ int main(int argc, char** argv)
working_list = std::move(tasklist);
}
async_lock();
while (!working_list.empty())
if (!working_list.empty())
{
async_lock();
while (!working_list.empty())
{
working_list.front()();
working_list.pop_front();
working_list.front()();
working_list.pop_front();
}
async_unlock();
}
async_unlock();
}
App::I.tick(dt);
std::unique_lock<std::mutex> lock(render_mutex);
if (render_timer > 1.0f / target_fps)
{
@@ -541,10 +547,10 @@ int main(int argc, char** argv)
async_unlock();
frame_timer = 0;
//LOG("swap main");
frames++;
}
frames++;
const int framerate = (1.f / target_fps) * 1000;
const int framerate = (1.f / target_tick_rate) * 1000;
const int diff = framerate - (t1 - t0);
render_cv.wait_for(lock, std::chrono::milliseconds(diff));
}