Castle Game Engine: CastleTimeUtils: Class TFramesPerSecond

# Class TFramesPerSecond
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleTimeUtils ## Declaration `type TFramesPerSecond = class(TObject)` ## Description Utility to measure frames per second, independent of actual rendering API. For example, it can be easily "plugged" into TCastleWindowCustom (see TCastleWindowCustom.FPS) or Lazarus GL control (see TCastleControlCustom.FPS). Things named "_" here are supposed to be internal to the TCastleWindowCustom / TCastleControlCustom and such implementations. Other properties can be controlled by the user of TCastleWindowCustom / TCastleControlCustom. ## Hierarchy TObject TFramesPerSecond ## Overview ### Methods
| `constructor Create;`
| `procedure _RenderBegin;`
| `procedure _RenderEnd;`
| `procedure _UpdateBegin;`
| `procedure ZeroNextSecondsPassed;`
### Properties
| `property FrameTime: Double read FFrameTime;`
| `property RealTime: Double read FRealTime;`
| `property UpdateSecondsPassed: Single read FUpdateSecondsPassed;`
| `property MaxSensibleSecondsPassed: Single read FMaxSensibleSecondsPassed write FMaxSensibleSecondsPassed;`
| `property UpdateStartTime: TTimerResult read FUpdateStartTime;`
## Description ### Methods
| `constructor Create;`
| `procedure _RenderBegin;`
| `procedure _RenderEnd;`
| `procedure _UpdateBegin;`
| `procedure ZeroNextSecondsPassed;`
Forces UpdateSecondsPassed for the next Update call (using _UpdateBegin) to be zero. This is useful if you just came back from some lenghty state, like a GUI dialog box (like TCastleWindowCustom.FileDialog or modal boxes in CastleMessages — but actually all our stuff already calls this as needed, TGLMode takes care of this). UpdateSecondsPassed would be ridicoulously long in such case (if our loop is totally stopped) or not relevant (if we do our loop, but with totally different callbacks, like CastleMessages). Instead, it's most sensible in such case to fake that UpdateSecondsPassed is 0.0, so things such as TCastleSceneCore.Time should not advance wildly just because we did GUI box. This forces the UpdateSecondsPassed to zero only once, that is only on the next update event (_UpdateBegin). Following update event (_UpdateBegin) will have UpdateSecondsPassed as usual (unless you call `ZeroNextSecondsPassed` again, of course).
### Properties
| `property FrameTime: Double read FFrameTime;`
Rendering speed in frames per second. This tells FPS, if we would only call Render (EventRender, OnRender) all the time. That is, this doesn't take into account time spent on other activities, like OnUpdate, and it doesn't take into account that frames are possibly not rendered continously (when AutoRedisplay = `False`, we may render frames seldom, because there's no need to do it more often). ###### See also RealTime How many frames per second were rendered.
| `property RealTime: Double read FRealTime;`
How many frames per second were rendered. This is a real number of EventRender (OnRender) calls per second. This means that it's actual speed of your program. Anything can slow this down, not only long EventRender (OnRender), but also slow processing of other events (like OnUpdate). Also, when AutoRedisplay = `False`, this may be very low, since you just don't need to render frames continously. ###### See also FrameTime Rendering speed in frames per second.
| `property UpdateSecondsPassed: Single read FUpdateSecondsPassed;`
Track how much time passed since last Update call, using _UpdateBegin. The time is in seconds, 1.0 = 1 second. For two times faster computer `UpdateSecondsPassed` = 0.5, for two times slower `UpdateSecondsPassed` = 2.0. This is useful for doing time-based rendering, when you want to scale some changes by computer speed, to get perceived animation speed the same on every computer, regardless of computer's speed. This is calculated as a time between start of previous Update event and start of current Update event. So this really measures your whole loop time (unlike previous RenderSpeed that measured only EventRender (OnRender) speed). You can sanely use this only within EventUpdate (OnUpdate).
| `property MaxSensibleSecondsPassed: Single read FMaxSensibleSecondsPassed write FMaxSensibleSecondsPassed;`
Limit the UpdateSecondsPassed variable, to avoid increasing time in game a lot when a game was hanging or otherwise waiting for some exceptional event from OS. Used only when non-zero.
| `property UpdateStartTime: TTimerResult read FUpdateStartTime;`
Time of last Update call.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:12