How do you show fps?

Hi,

This Is a really noob question but does anyone now how you do this.
I know there is a really simple way but i cant remember this :confused:

There are a variety of ways, and some folks have written classes to display them. The simplest is just parameter.watch("1/DeltaTime"), but that can flicker too fast to see. Slightly better is parameter.watch("math.floor(1/DeltaTime)") which rounds it down to the nearest integer.

What I tend to do is average the frame rate over the last few frames. In setup, I put:

fps = {}
nf = 10
for k=1,nf do
    table.insert(fps,1/60)
end
parameter.watch(afps)

then in draw I have:

table.remove(fps,1)
table.insert(fps,DeltaTime)
afps = 0
for _,v in ipairs(fps) do
    afps = afps + v
end
afps = math.floor(10/afps)

If using FULLSCREEN (or FULLSCREEN_NO_BUTTONS) then instead of parameter.watch you need to draw the text to the screen.

@Andrew_Stacey Yes but thats not exactly what im looking for :confused:

I’m not sure how Andrew’s response wasn’t what you were after… But you can also check out this tutorial which has FPS as part of it.

http://codeatuts.blogspot.com.au/2012/06/tutorial-4-splash-screen.html

@Jessevanderheide Then you need to be a bit more precise about what it is you want.

FPS is frames per second, DeltaTime is the time it took to draw the current frame from the previous frame, this should be 1/60 but if we do 1/DeltaTime it will give you around 57-65 which is a rough estimate of the frame rate or Frames Per Second (FPS)

Sorry!

I remember what i was meaning!
It was almost the same as andrew but a few things were different.
Thanks for the help!