mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
2995f8b99f
- various gui-work - begun binding the GUI into Monster script - updated to latest Monster source (0.11 alpha) git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@87 ea6a568a-9f4f-0410-981a-c910a81bb256
37 lines
883 B
Plaintext
37 lines
883 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 one frame. This makes sure we only start running after
|
|
// rendering begins. It prevents the first printed value from being
|
|
// 'nan'
|
|
fsleep(1);
|
|
|
|
// 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;
|
|
}
|