PixelLightAPI  .
Public Member Functions | Static Public Member Functions
PLCore::Timing Class Reference

Timing stuff. More...

#include <Timing.h>

List of all members.

Public Member Functions

bool IsActive () const
 Returns whether the timing is active or not.
void SetActive (bool bActive=true)
 Sets whether the timing is active or not.
PLCORE_API void Reset ()
 Resets the timing.
PLCORE_API bool CheckUpdate (uint64 *pnTimeToWait=nullptr) const
 Checks whether the timing has to be updated or not.
PLCORE_API bool Update (uint64 *pnTimeToWait=nullptr)
 Updates all time relevant stuff.
float GetTimeDifference () const
 Returns the past time since last frame (seconds)
float GetTimeDifferenceNoCompensating () const
 Returns the past time since last frame without any compensating (seconds)
float GetMaxTimeDifference () const
 Returns the maximum time difference.
void SetMaxTimeDifference (float fMaxTimeDifference=0.15f)
 Sets the maximum time difference.
PLCORE_API uint64 GetPastTime () const
 Returns the past time in milliseconds since the application start.
float GetTimer () const
 Returns a general timing.
float GetFramesPerSecond () const
 Returns the current frames per second (FPS)
uint32 GetPastFrames () const
 Returns the number of past frames since timing start.
float GetFPSLimit () const
 Returns the FPS limit.
void SetFPSLimit (float fFPSLimit=0.0f)
 Sets the FPS limit.
bool IsFreezed () const
 Returns if the timing is currently freezed or not.
PLCORE_API void Freeze (bool bFreeze=true)
 Set freezed mode.
bool IsPaused () const
 Returns whether the timing is paused of not.
void Pause (bool bPause=true)
 Set pause mode.
float GetTimeScaleFactor () const
 Returns the time scale factor.
bool SetTimeScaleFactor (float fFactor=1.0f)
 Sets the time scale factor.
bool IsSlowMotion () const
 Returns if the slow motion is activated or not.
void SetSlowMotion (bool bSlowMotion=false)
 Activates/deactivates the slow motion mode.
float GetSlowMotionFactor (bool bRealUsed=true) const
 Returns the slow motion factor.
bool SetSlowMotionFactor (float fSlowMotionFactor=1.0f)
 Sets the slow motion factor.
float GetCustomSlowMotionFactor (bool bRealUsed=true) const
 Returns the custom slow motion factor.
bool SetCustomSlowMotionFactor (float fSlowMotionFactor=1.0f)
 Sets the custom slow motion factor.

Static Public Member Functions

static PLCORE_API TimingGetInstance ()
static PLCORE_API bool HasInstance ()

Detailed Description

Timing stuff.

Remarks:
This timing class offers a lot of timing tool functions you can for instance use to create timed movement. Have a look at the 'System'-singleton for the basic timing functions.

Member Function Documentation

static PLCORE_API Timing* PLCore::Timing::GetInstance ( ) [static]
static PLCORE_API bool PLCore::Timing::HasInstance ( ) [static]
bool PLCore::Timing::IsActive ( ) const [inline]

Returns whether the timing is active or not.

Returns:
'true' if the timing is active, else 'false'
void PLCore::Timing::SetActive ( bool  bActive = true) [inline]

Sets whether the timing is active or not.

Parameters:
[in]bActiveShould the timing be active?
Note:
  • If the timing is disabled the time difference between two frames will be always the maximum time difference
  • Use it only for testing
PLCORE_API void PLCore::Timing::Reset ( )

Resets the timing.

PLCORE_API bool PLCore::Timing::CheckUpdate ( uint64 *  pnTimeToWait = nullptr) const

Checks whether the timing has to be updated or not.

Parameters:
[in]pnTimeToWaitIf not a null pointer, if there's a FPS limit and it's not time for an update -> receives the time in milliseconds we need to wait until it's time for the next update, receives '0' in all other cases
Returns:
'true' if the timing has to be updated, else 'false'
Remarks:
Normally the timing must be updated every frame. But if theres a frame rate limitation it's not allowed to update the timing every frame!
PLCORE_API bool PLCore::Timing::Update ( uint64 *  pnTimeToWait = nullptr)

Updates all time relevant stuff.

Parameters:
[in]pnTimeToWaitIf not a null pointer, if there's a FPS limit and it's not time for an update -> receives the time in milliseconds we need to wait until it's time for the next update, receives '0' in all other cases
Returns:
'true' if all went fine, else 'false' (maybe there's a frame rate limitation)
See also:
float PLCore::Timing::GetTimeDifference ( ) const [inline]

Returns the past time since last frame (seconds)

Returns the past time since last frame (in seconds)

Returns:
Past time since last frame
Remarks:
The timing class tries to compensate irregularities in timing automatically to avoid for instance sudden jumps through half of the universe. Further a maximum time difference is applied to avoid any totally undesired results.

Returns the past time since last frame without any compensating (seconds)

Returns the past time since last frame without any clamping (seconds)

Returns:
Past time since last frame without any compensating
Note:
float PLCore::Timing::GetMaxTimeDifference ( ) const [inline]

Returns the maximum time difference.

Returns:
The maximum time difference since the last frame in seconds
Note:
  • The maximum time difference will avoid a too hight time difference value which would probably end in undefined problems.
  • A maximum time difference of 0.15 is a good value
void PLCore::Timing::SetMaxTimeDifference ( float  fMaxTimeDifference = 0.15f) [inline]

Sets the maximum time difference.

Parameters:
[in]fMaxTimeDifferenceThe maximum time difference since the last frame in seconds (> 0)
See also:
PLCORE_API uint64 PLCore::Timing::GetPastTime ( ) const

Returns the past time in milliseconds since the application start.

Returns:
Past time in milliseconds since the application start
float PLCore::Timing::GetTimer ( ) const [inline]

Returns a general timing.

Returns:
General timing
Remarks:
On each timing update, the current time difference is added to this general timing.
float PLCore::Timing::GetFramesPerSecond ( ) const [inline]

Returns the current frames per second (FPS)

Returns:
Current frames per second
uint32 PLCore::Timing::GetPastFrames ( ) const [inline]

Returns the number of past frames since timing start.

Returns:
Current frames per second (FPS)
float PLCore::Timing::GetFPSLimit ( ) const [inline]

Returns the FPS limit.

Returns:
FPS limit, 0 if there's no FPS limitation
Note:
  • FPS limitation could be used to avoid that the application uses to much system resources. (normally 30 FPS are enough)
  • Use a FPS limitation only in special situations! (users love FPS over 100 even if its more or less senseless ;-)
void PLCore::Timing::SetFPSLimit ( float  fFPSLimit = 0.0f) [inline]

Sets the FPS limit.

Parameters:
[in]fFPSLimitFPS limit, 0 if there should be no limitation (>= 0)
See also:
bool PLCore::Timing::IsFreezed ( ) const [inline]

Returns if the timing is currently freezed or not.

Returns:
'true' if the timing is freezed at the moment, else 'false'
PLCORE_API void PLCore::Timing::Freeze ( bool  bFreeze = true)

Set freezed mode.

Parameters:
[in]bFreezeShould the timing be freezed or not?
Note:
  • Freeze your application if you are not in rendering mode (e.g. you load something)
bool PLCore::Timing::IsPaused ( ) const [inline]

Returns whether the timing is paused of not.

Returns:
'true' if the timing is paused, else 'false'
Note:
  • If the timing is paused scene nodes, particles etc. are not updated
  • The timing will still be updated
void PLCore::Timing::Pause ( bool  bPause = true) [inline]

Set pause mode.

Parameters:
[in]bPauseShould the timing be paused or not?
float PLCore::Timing::GetTimeScaleFactor ( ) const [inline]

Returns the time scale factor.

Returns:
Time scale factor
Note:
  • The global time scale factor should only be manipulated for debugging
  • For 'slow motion' effects use the slow motion functions instead!
  • A factor of <= 0 is NOT allowed because this may cause problems in certain situations, pause the timer instead by hand!
  • Do NOT make the factor 'too' (for example > 4) extreme, this may cause problems in certain situations!
bool PLCore::Timing::SetTimeScaleFactor ( float  fFactor = 1.0f) [inline]

Sets the time scale factor.

Parameters:
[in]fFactorTime scale, a factor of <= 0 is NOT allowed!
Returns:
'true' if all went fine, else 'false' (maybe the given factor is <= 0?)
See also:
bool PLCore::Timing::IsSlowMotion ( ) const [inline]

Returns if the slow motion is activated or not.

Returns:
'true' is the slow motion mode is activated, else 'false'
void PLCore::Timing::SetSlowMotion ( bool  bSlowMotion = false) [inline]

Activates/deactivates the slow motion mode.

Parameters:
[in]bSlowMotionShould the slow motion mode be activated?
float PLCore::Timing::GetSlowMotionFactor ( bool  bRealUsed = true) const [inline]

Returns the slow motion factor.

Sets the custom slow motion factor.

Parameters:
[in]bRealUsedThe real used slow motion factor will be returned. If the slow motion mode is deactivated this will be 1!
Returns:
The current slow motion factor
Note:
  • The slow motion mode must be activated that this factor changes the game speed
  • Use this function to change the speed in general
  • A factor of <= 0 is NOT allowed because this may cause problems in certain situations, pause the timer instead by hand!
  • Do NOT make the factor 'too' (for example > 4) extreme, this may cause problems in certain situations!
bool PLCore::Timing::SetSlowMotionFactor ( float  fSlowMotionFactor = 1.0f) [inline]

Sets the slow motion factor.

Parameters:
[in]fSlowMotionFactorThe slow motion factor, a factor of <= 0 is NOT allowed!
Returns:
'true' if all went fine, else 'false' (maybe the given factor is <= 0?)
See also:
float PLCore::Timing::GetCustomSlowMotionFactor ( bool  bRealUsed = true) const [inline]

Returns the custom slow motion factor.

Parameters:
[in]bRealUsedThe real used slow motion factor will be returned. If the slow motion mode is deactivated this will be 1!
Returns:
The current slow motion factor
Note:
  • The slow motion mode must be activated that this factor changes the game speed
  • Use this factor to temporal slow motion effects
bool PLCore::Timing::SetCustomSlowMotionFactor ( float  fSlowMotionFactor = 1.0f) [inline]

Sets the custom slow motion factor.

Parameters:
[in]fSlowMotionFactorThe slow motion factor, a factor of <= 0 is NOT allowed!
Returns:
'true' if all went fine, else 'false' (maybe the given factor is <= 0?)
See also:

The documentation for this class was generated from the following files:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:16
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported