CRM64Pro GDK  v0.94
A free cross-platform game development kit built on top of SDL 2.0
Classes | Functions
Timer

Classes

class  CRM64Pro::Timer
 

Functions

Sint32 CRM64Pro::Timer::info (Sint32 iMode=0)
 
Sint32 CRM64Pro::Timer::init (eTimerState tsOpt=TS_INIT)
 
Sint32 CRM64Pro::Timer::setRate (Uint16 iR, Uint16 iL)
 
Sint32 CRM64Pro::Timer::getLFR ()
 
Sint32 CRM64Pro::Timer::getRFR ()
 
float CRM64Pro::Timer::getAverageRFR ()
 
float CRM64Pro::Timer::getAverageLFR ()
 
Uint32 CRM64Pro::Timer::getCurrentRFR ()
 
Uint32 CRM64Pro::Timer::getCurrentLFR ()
 
Uint32 CRM64Pro::Timer::getRenderFrames ()
 
Uint32 CRM64Pro::Timer::getLogicFrames ()
 
float CRM64Pro::Timer::getTime ()
 
Uint32 CRM64Pro::Timer::getTicks ()
 
Uint32 CRM64Pro::Timer::getTicksNow ()
 

Detailed Description

The Timer must be initiated with Timer::init().
Apart from methods for getting time, fixed virtual logic frame rate with interpolation feature is implemented on this interface and in Main::update() method:

By default, no preferred Render and Logic Frame Rate are set (they are equal to 0) so if you want to use specific values, you must use setRate().
The rates can be adjusted (throttle down) but the upper limit is imposed by the underlying hardware where the application is executed, there is also a synergy between upper limits and ConfigMgr::iMTFriendly value.
It is important to say that the Render Frame Rate (if enabled) will be used for all enabled and visible screens.

Only a single instance of the Timer interface exists which is created once Main is instantiated.
You can get a reference to this interface using Main::ITimer() method.

Note
The Timer interface is automatically released when Main::Terminate() is called.
At this time, if any resource is still loaded, it will be released avoding a resource leak.

Enumeration Type Documentation

Timer init state.

Enumerator
TS_INIT 

'tsOpt' parameter in Timer::init(), initializes or resets all timer settings.

TS_RESET 

'tsOpt' parameter in Timer::init(), only resets the timer if it was previously initialized keeping RFR and LFR rates.

Function Documentation

Sint32 CRM64Pro::Timer::info ( Sint32  iMode = 0)

Request Timer Interface information.

For displaying the information, it uses the default log.

Parameters
iModeunused for the time being.
Returns
0 on success or a negative error code on failure.
Sint32 CRM64Pro::Timer::init ( eTimerState  tsOpt = TS_INIT)

Initialize the timer system.

The first call to this method, SDL timer subsystem will be initialized.

Parameters
tsOptCheck eTimerState enum for further information.
By default TS_INIT is set.
Returns
0 on success or a negative error code on failure.
Note
init(TS_RESET) is called internally by Main::cleanUp().
Sint32 CRM64Pro::Timer::setRate ( Uint16  iR,
Uint16  iL 
)

Set preferred Render and Logic Frame Rate.

Parameters
iRan integer value with preferred Render Frame Rate.
By default it is set to 0 which does not limit this rate.
Maximum value is 500.
iLan integer value with preferred Logic Frame Rate.
By default it is set to 0 which does not limit this rate.
Maximum value is 500.
Returns
0 on success or a negative error code on failure.
Sint32 CRM64Pro::Timer::getLFR ( )

Get the preferred Logic Frame Rate.

Returns
0 or positive value on success or -1 on failure.
Sint32 CRM64Pro::Timer::getRFR ( )

Get the preferred Render Frame Rate.

Returns
0 or positive value on success or -1 on failure.
float CRM64Pro::Timer::getAverageRFR ( )

Get the average Render Frame Rate since the last timer init or reset.

Returns
0 or positive value on success or -1 on failure.
float CRM64Pro::Timer::getAverageLFR ( )

Get the average Logic Frame Rate since the last timer init or reset.

Returns
0 or positive value on success or -1 on failure.
Uint32 CRM64Pro::Timer::getCurrentRFR ( )

Get current Render Frame Rate during last recent second.

Returns
Render Frame Rate.
Uint32 CRM64Pro::Timer::getCurrentLFR ( )

Get current Logic Frame Rate during last recent second.

Returns
Logic Frame Rate.
Uint32 CRM64Pro::Timer::getRenderFrames ( )

Get total render frames since the last timer init or reset.

Returns
Total number of Render frames.
Uint32 CRM64Pro::Timer::getLogicFrames ( )

Get total logic frames since the last timer init or reset.

Returns
Total number of Logic frames.
float CRM64Pro::Timer::getTime ( )

Get the execution time (in seconds) since the last timer init or reset.

This time will be constant inside the same Logic Frame iteration and will be updated on Main::update() if a new Logic Frame must be produced.

Returns
0 or positive value on success or -1 on failure.
Uint32 CRM64Pro::Timer::getTicks ( )

Get the execution time (in milliseconds) since the last timer init or reset.

This time will be constant inside the same Logic Frame iteration and will be updated on Main::update() if a new Logic Frame must be produced.

Returns
unsigned int 32bits with the ticks.
Uint32 CRM64Pro::Timer::getTicksNow ( )

Get the execution time (in milliseconds) since the last timer init or reset.

This time will be exactly the "now" time, on other words, it is not linked anyway to the Logic Frame iteration.

Returns
unsigned int 32bits with the ticks.