mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 12:42:11 +00:00
0dfdbe99ee
git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@89 ea6a568a-9f4f-0410-981a-c910a81bb256
36 lines
838 B
Plaintext
36 lines
838 B
Plaintext
// Small script that prints the FPS to screen with regular intervals.
|
|
import frames;
|
|
|
|
// Set up the text widget
|
|
Widget txt = gui.text("StaticText",
|
|
gui.getWidth()-90, 10, 120, 30,
|
|
"Statistic");
|
|
txt.setNeedMouseFocus(false);
|
|
txt.setTextColor(1,1,1);
|
|
txt.setCaption("hello!");
|
|
|
|
// Sleep until rendering begins. This just prevents the first printed
|
|
// value from being 'nan'
|
|
fsleep(0);
|
|
|
|
// counter and totalTime (in the 'frames' module) are updated
|
|
// automatically by the system.
|
|
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;
|
|
|
|
txt.setCaption("fps: ", fdiff/tdiff);
|
|
|
|
lastFrame = counter;
|
|
lastTime = totalTime;
|
|
}
|