I have made a couter that is part of a class, that I am trying to get right.
So, far I am able to accurately assess the frames per second in a scene. But, I am having problems calculating the time since the last frame, so that movement and animations run at the same speed on any computer.
But I am finding, different PC's are giving different movement speeds although I want them to be the same.
int Engine::counterFramerate()
{
// get curent PC frequecy (incase of overclocking during test)
LARGE_INTEGER li;
start=current;
QueryPerformanceCounter(&li);
current=(double(li.QuadPart))/1000;
nCounter++;
total=total+current-start;
tslf=(current-start);
if((total)>=1000)
{
nFramesPerSecond=nCounter;
nCounter=0;
QueryPerformanceCounter(&li);
PCCounter=double(li.QuadPart);
start=PCCounter;
total=0;
}
return nFramesPerSecond;
}
double Engine::counterTimeSinceLastFrame()
{
return tslf;
}
counterFramerate() returns FPS and counterTimeSinceLastFrame() should return the time lapsed since the last frame but doesn't seem to be doing so correctly.
Can anyone see where I might have gone wrong?
Thanks in advance