1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/mscripts/fpsticker.mn
nkorslund 17a2c67d26 - Integrated MyGUI and made a small test case.
- Made a (very experimental) Morrowind skin
- Decoded the fnt/tex font files, but they aren't used yet


git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@84 ea6a568a-9f4f-0410-981a-c910a81bb256
2009-02-01 02:21:08 +00:00

39 lines
853 B
Plaintext

// Small script that prints the FPS to screen with regular intervals.
class FPSTicker;
import frames;
// Set the FPS widget text
native setText(char[][] args...);
run()
{
// 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);
setText("hello!");
// 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;
setText("fps: ", fdiff / tdiff);
lastFrame = counter;
lastTime = totalTime;
}
}