I'm writing a Direct2D game in c++ / WinAPI. I need to render things 60 times every a second using fixed time step.
__int64 time_before = 0;
__int64 time_now;
__int64 frequency;
__int64 time_elapsed;
double frameTime;
if (QueryPerformanceFrequency((LARGE_INTEGER*)&frequency)) {
frameTime = (double)frequency / 60;
while (true) {
//process incoming messages here
QueryPerformanceCounter((LARGE_INTEGER*)&time_now);
time_elapsed = time_now - time_before;
if (time_elapsed >= frameTime) {
//update and render things here:
time_start = time_before;
}
}
}
Are there any problems, or are there any improvements that can be made?