1.3k views
in System Integration by
In some cases it might be interesting to know the resulting frame rate during a certain animation. How to implement a simple frames-per-second (fps) counter for debugging purposes?

2 Answers

0 votes
by
 
Best answer

Meanwhile, there is a more simple way to display the current frame rate in frames per second (FPS), which displays the frame rate directly on top of your GUI application:

  • Open your application class within Embedded Wizard Studio.
  • Add a Text view to your application class, rename it to 'PerformanceText', select a suitable font and a set a default string, e.g. 'FPS: 0'
  • Add a Slot method to your application class and rename it to 'PerformanceSlot'
  • Add a Timer to your application class, set the Period to 1000 ms, set OnTrigger to 'PerformanceSlot' and enable the timer.
  • Now write the following code into the slot method 'PerformanceSlot':
PerformanceText.String = "FPS: " + string(GetRoot().GetFPS());

As a result, the slot method is called every second and the number of frames that have been drawn is shown within the text item.

Please note, that this FPS counter does not show the frame rate of the display - it shows the number of updates from the GUI application. If there is nothing to draw, then the resulting frame rate will drop down to 0.

I hope this helps...

Manfred.

0 votes
by

Displaying the current frame rate in frames-per-second (fps) within an Embedded Wizard UI application can be done in the following way:

  • Open your application class within Embedded Wizard Studio.
  • Declare a Int32 variable with the name frameCounter.
  • Override the method Draw() and insert the following implementation:
{
  /* make the super call to ensure that the content is drawn as usual */
  super( aCanvas, aClip, aOffset, aOpacity, aBlend );

  /* just increment the frame counter */
  frameCounter = frameCounter + 1;
}
  • Add a timer object to your application and let the timer signal a slot method every second.
  • Within the slot method you can now print your current frameCounter value (e.g. by using trace) and reset the counter variable:
{
  trace frameCounter;
  frameCounter = 0;
}

Embedded Wizard Website | Privacy Policy | Imprint

...