Code: Select all
[Game.h]
FrameTimer ft;
float totalFrameTime = 0.0f;
int frameCounter = 0;
float fps = 0.0f;
[Game.cpp]
void Game::Go()
{
gfx.BeginFrame();
UpdateModel();
ComposeFrame();
gfx.EndFrame();
frameCounter += 1;
}
void Game::UpdateModel()
{
totalFrameTime += ft.GetFrameTime();
fps = frameCounter / (totalFrameTime / 1.0f);
std::wstringstream stream;
stream << std::setprecision(4) << fps;
wnd.SetWindowTitle(stream.str());
}
How do I prevent this? Or is there a proper way to calculate frame rate? Any advice is welcome!