first commit
This commit is contained in:
70
include/engine/core/clock.h
Normal file
70
include/engine/core/clock.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifndef __NCLOCK__
|
||||
#define __NCLOCK__
|
||||
|
||||
|
||||
#include "memory/nshared_ptr.h"
|
||||
#include "container/smart_median_average.h"
|
||||
|
||||
|
||||
namespace GS {
|
||||
namespace Core {
|
||||
|
||||
/*!
|
||||
@short Clock
|
||||
@author Emmanuel Julien (ejulien@nworks.fr)
|
||||
*/
|
||||
class Clock : public SharedObject
|
||||
{
|
||||
bool pause;
|
||||
int fixed_delta; ///< Fixed dt (ms).
|
||||
|
||||
int _gtick, gtick; ///< System's global tick counter.
|
||||
int clock_scale; ///< System clock scale factor (x1000).
|
||||
|
||||
int dt_clock; ///< Delta frame.
|
||||
int dt_error;
|
||||
|
||||
SmartMedianAverage <int> dt_clock_filter;
|
||||
|
||||
public:
|
||||
|
||||
void Reset();
|
||||
void Update();
|
||||
|
||||
void Pause(bool = true);
|
||||
|
||||
/// Sync to current hardware clock (skipping unaccounted dt_clock).
|
||||
void EatDeltaClock();
|
||||
|
||||
float Getf() const;
|
||||
float GetDeltaf() const;
|
||||
|
||||
void SetScalef(float = 1.f);
|
||||
float GetScalef() const;
|
||||
|
||||
/// Set fixed delta clock in seconds.
|
||||
void SetFixedDeltaFramef(float = -1.0);
|
||||
|
||||
int GetDelta() const { return dt_clock; }
|
||||
|
||||
void SetScale(int k = 1000) { clock_scale = k; }
|
||||
int GetScale() const { return clock_scale; }
|
||||
|
||||
int Get() const { return gtick; }
|
||||
|
||||
Clock();
|
||||
};
|
||||
|
||||
typedef SharedPtr <Clock> sClock;
|
||||
|
||||
} // Core
|
||||
} // GS
|
||||
|
||||
|
||||
#endif // __NCLOCK__
|
||||
Reference in New Issue
Block a user