Realtime engine framerate display


(robejms) #1

Hi, does anyone know how i can get to the framerate through python. I need to display the framerate on a published blender file for testing purposes.

Thanks

Rob


(theeth) #2

isn’t there already an option to display the frame rate? Without using Python I mean…

Martin


(robejms) #3

yeah, there is an option in the publisher, but when you create a runtime file you lose any of these debug features. It’s in the runtime file (self contained .exe) that i need to display the framerate. The only way i can see to do this is by accessing some module which contains the framerate information and then displaying this as text within the runtime environment.


(chacademus) #4

Yes, I too am in the same predicament. I was told by a work collegue that there was a blend file which someone had created to do this exact thing. It was some sort of grand prix demo. I will ask my collegue if he knows where this file is and will pass it on to you if he still has it.


(wiseman303) #5

I think calli made a script that did this, but it was lost when the blender site went down :frowning:


(blendedHKU) #6

Well what you can do is create a timer property (which shows time in seconds), then attach a script that watches if the time has passed one second, and use a counter to increment framerate.

So make 2 props

fps (int)
time (time)

Add a script which is run always:

import GameLogic
owner = GameLogic.getCurrentController().getOwner()

try:
GameLogic.counter
except:
GameLogic.counter=0
GameLogic.time=owner.time

GameLogic.counter += 1

if GameLogic.time != owner.time: #a sec passed
GameLogic.time = onwer.time
owner.fps = GameLogic.counter
GameLogic.counter=0

print ‘fps:’,owner.fps

I didn’t test this, but it should work. The problem with this is that the framerate off the python script doesn’t have to be the same as the framerate of the engine,
So it would be better if you build something similar like this in logic bricks, and use the script only to display the result, or use bmp txt thingie, than maybe you could do it without a script.

Hope this helps,

Jasper