/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/core/time/gameclock.hpp

*/

#ifndef SGX_CORE_TIME_GAMECLOCK_HPP
#define SGX_CORE_TIME_GAMECLOCK_HPP	1

#include "sgx/core/types/types.hpp"

class CGameClock {
public:
    CGameClock();

    tREAL32		applyRealTimeToClock(tREAL32 current_time);
    void		setModeRealtime();
    void		setModeConstant(const tREAL32 period);
    void		setModeConstantFPS(const tREAL32 fps);
    void		setModeClamped(const tREAL32 min_fps, const tREAL32 max_fps=60);
	void		setModeClampedTelaps(const tREAL32 min_telaps, const tREAL32 max_telaps);
    tREAL32		getTime();
	tREAL32		getLastTelaps();
	tREAL32		getClampedMin();
	tREAL32		getClampedMax();
    tREAL32		update(const tREAL32 telaps);

    typedef enum {
        Realtime,
        AsGiven,
        Constant,
        Clamped
    } CClockMode;

    static	CGameClock * get();

protected:
    static CGameClock      *sm_pSingleton;

private:
    tREAL32                 m_fLastTime;
    tREAL32                 m_fFractionalSpeed;
    tREAL32                 m_fGivenTime;
    tREAL32                 m_fConstantPeriod;
    tREAL32                 m_fClampedMin;
    tREAL32                 m_fClampedMax;
	tREAL32					m_fLastTelaps;
    CClockMode              m_ClockMode;
};

#endif /* SGX_CORE_TIME_GAMECLOCK_HPP */
