#include <Windows.h>
int main()
{
int FPS = 60;
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
LARGE_INTEGER lastUpdate = counter;
while (true)
{
QueryPerformanceCounter(&counter);
if (counter.QuadPart > (lastUpdate.QuadPart + (frequency.QuadPart / FPS)))
{
lastUpdate = counter;
// ...
// Are things in here happening every 60 second? \(^o^)/
}
}
}
Will this limit Things to exactly 60 FPS, and will it change correctly when I change the FPS variable?
I'm not quite sure how I can measure if it works, because if I add code to show the FPS somehow, that code would rely on what I'm trying to do, which would make it wrong if the code is wrong >:D