Do anyone know how to get/calculate current FPS on Urho?
Get current FPS


As far as I know, there’s no built in for it. Two ways come to mind:
Quick and dirty:
FrameInfo frameInfo = GetSubsystem<Renderer>()->GetFrameInfo();
text->SetText("FPS: " + String(1.0 / frameInfo.timeStep_));
Or more standard:
void FPSCounter::Update(float deltaTime)
{
counter += 1;
timer += deltaTime;
if (timer >= 0.5f)
{
text->SetText("FPS: " + String(counter/timer));
timer = 0.0f;
counter = 0;
}
}
You would need to set up a ‘Text* text’ object in the above examples, and an object or event to do the update event in.

Urho3D has a Profiler class that does just that and more. In the samples, you can press F2 to see it in action.

Thanks for all the answer. It works now!
I never thought it was so simple.
@weitjong I haven’t tried profiler class, but terima kasih buat tipsnya!

I can’t find the FPS information on the current Profiler lots of data! But the data it shows looks pretty cool.

It is the “Cnt” at the outer block.