mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
656007cf01
script are now simple function-scripts, not classes. git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@82 ea6a568a-9f4f-0410-981a-c910a81bb256
28 lines
600 B
Plaintext
28 lines
600 B
Plaintext
// Small script that prints the FPS to screen with regular intervals.
|
|
|
|
import io, timer, frames;
|
|
|
|
// Sleep one frame. This makes sure that we won't start running until
|
|
// the rendering begins. Not critically important, but it prevents the
|
|
// first printed value from being 'nan'.
|
|
fsleep(1);
|
|
|
|
ulong lastFrame = counter;
|
|
float lastTime = totalTime;
|
|
|
|
float delay = 1.5;
|
|
|
|
while(true)
|
|
{
|
|
sleep(delay);
|
|
|
|
// Calculate differences since last frame
|
|
ulong fdiff = counter-lastFrame;
|
|
float tdiff = totalTime-lastTime;
|
|
|
|
print("fps:", fdiff / tdiff);
|
|
|
|
lastFrame = counter;
|
|
lastTime = totalTime;
|
|
}
|