Class TAdPerformanceCounter

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TAdPerformanceCounter = class(TObject)

Description

Class for calculating the FPS and the TimeGap.

Hierarchy

Overview

Methods

Public constructor Create(ACreatePaused:boolean=false);
Public procedure Resume;
Public procedure Pause;
Public procedure Calculate;

Properties

Public property State: TAdPerformanceCounterState read FState;
Public property FPS: integer read FFPS;
Public property TimeGap: double read FTimeGap;
Public property Interpolate: Boolean read FInterpolate write FInterpolate;
Public property InterpolationFactor: integer read FInterpolationFactor write FInterpolationFactor;
Public property MaximumTimeGap: double read FMaximumTimeGap write FMaximumTimeGap;
Public property MaximumFrameRate: integer read FMaximumFrameRate write FMaximumFrameRate;

Description

Methods

Public constructor Create(ACreatePaused:boolean=false);

Creates a new instance of TAdPerformanceCounter.

Parameters
ACreatePaused
can be true, in order to create the performance counter in a suspended mode
Public procedure Resume;

If the performance counter was paused (suspended), resume makes the counter to calculate the time-between frames again.

Public procedure Pause;

Pauses the counter. TimeGap will always be zero.

Public procedure Calculate;

Makes the counter to calculate the FPS and the time between this and the last call of "Calculate".

Properties

Public property State: TAdPerformanceCounterState read FState;

Contains the current state of the performance counter.

See also
TAdPerformanceCounterState
Represents the state of the performance counter.
Public property FPS: integer read FFPS;

Contains the current FPS. FPS is calculated every second by counting the ticks passed.

Public property TimeGap: double read FTimeGap;

TimeGap is the time that passed between the last two calls of the "Calculate" function. Zero if the counter is paused. The result is in milliseconds.

Public property Interpolate: Boolean read FInterpolate write FInterpolate;

If true, the TimeGap values are interpolated in order to prevent the game from small hangs. May cause problems if the framerate falls below 100 FPS.

Public property InterpolationFactor: integer read FInterpolationFactor write FInterpolationFactor;

The factor the old TimeGap value is multiplied with. The weight of the previous TimeGap is InterpolationFactor:1

Public property MaximumTimeGap: double read FMaximumTimeGap write FMaximumTimeGap;

If TimeGap exceeds MaximumTimeGap, TimeGap will be set to this value. This is for preventing the game logic from e.g. collision bugs beause TimeGap got to big.

Public property MaximumFrameRate: integer read FMaximumFrameRate write FMaximumFrameRate;

Use this property to set the maximum framerate that should be achieved. Setting this value will also help to save cpu workload, what means less power comsumption. Remember that Maximumframerate is not really percise, do not replace time based moving by this method. If maximum frame rate is activated, a "sleep" will be added to the "calculate" function. So if you want to use the time while the program sleeps, you have to use threads. If Maximum Frame Rate is smaller or equals zero, frame rate limitation will be disabled.

SourceForge.net Logo


Generated by PasDoc 0.11.0 on 2008-12-31 14:32:00