i'm trying to calculate the FPS of my game, but the value is not stable, so i wanted to implement linear interpolation to make the displayed text smooth.. The problem is that i'm getting 1.#INF values, I tried googling but couldn't really find an explanation.
Here is the interpolation function:
float Lerp(float from, float to, float t)
{
return (from*(1 - t) + to*t);
}
How i calculate the FPS:
void CalculateTime()
{
deltaTime = (float)(SDL_GetTicks() - lastFrameTime) / 1000.0f; // this is around 0.02 each frame
fps = 1.0f / deltaTime; // this is 50-60 every frame
lastFps = Lerp(fps, lastFps, 0.5f); // lastFps is initialized at 60.0
printf("%2.4f\n", lastFps);
}
Everything seems to be fine.. deltaTime, fps, lastFps are all floats (i tried double too but no difference) but when printf executes i get 1.#INF
Any ideas?