Original Post
I am drawing an FPS graph in my game. For that I go over an array and get the last stored FPS values. However, there is something weird. If I use the following code: Then I get a small jump ni the drawing of the FPS about every cycle of the array. As if it doesnt advance the drawing of the FPS graph in one frame, once in every full cycle of the array. However, if I use the following code, then it works fine:
DWORD
FPSTimer::GetFPSHistory(DWORD Backward)
{
double Time;
Time = this->CycleTime[(this->CycleCounter-Backward)%this->CycleTime.GetObjectsAmount()]; // <= HERE
double FPSCalc;
FPSCalc = ceil((1/Time)-0.5);
return static_cast<DWORD>(FPSCalc);
}
void
FPSTimer::UpdatedFPS()
{
// TODO: Non exclude here
this->CycleTime[this->CycleCounter] = this->pTimer->GetLastDelta();
this->CycleCounter=(this->CycleCounter+1)%this->CycleTime.GetObjectsAmount();
}
DWORD
FPSTimer::GetFPSHistory(DWORD Backward)
{
double Time;
Time = this->CycleTime[(this->CycleTime.GetObjectsAmount()+this->CycleCounter-Backward)%this->CycleTime.GetObjectsAmount()]; // <= Here
double FPSCalc;
FPSCalc = ceil((1/Time)-0.5);
return static_cast<DWORD>(FPSCalc);
}