/*
Copyright (C) 1997, 1998, 1999, 2000 by Alex Pfaffe
(Digital Dawn Graphics Inc)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ddgClock_Class_
#define _ddgClock_Class_
#include "util/ddgstr.h"
#define ddgFPSBUFSIZE 16
class WEXP ddgClock
{
float _time;
float _elapsed;
float _sysfactor;
float _simfactor;
float _simstart;
unsigned long _prev;
unsigned int _frame;
unsigned int _totalFrame;
unsigned int _totalTime;
unsigned int _minTime;
unsigned int _maxTime;
float _fpsbuf[ddgFPSBUFSIZE];
int _fpsidx;
float _fpstotal;
public:
ddgClock( float init = 0.0);
float update(void);
void set(int t) { _time = t / _sysfactor; }
float getSysTime(void) { return _time * _sysfactor; }
float getElapsed(void) { return _elapsed * _sysfactor; }
float getFrameRate(void);
float getAvgFrameRate(void);
// Return the simulated time where one system second is _simfactor seconds.
// The return values is the fractional number of days elapsed.
// If h is given, h returns the number of hours and returned days are rounded.
// If m is given, m returns the number of minutes and h is rounded.
// If s is given, s returns the number of seconds and m is rounded.
float getSimTime(float *h = 0, float *m = 0, float *s = 0, float *r = 0);
void start( float t) { _simstart = t; }
void simfactor( float f ) { _simfactor = f; }
float getDayLight(void);
void perf( unsigned int tf ) { _totalFrame = tf-1; }
bool perfDump( ddgStr *filename = NULL, char *s = NULL );
static void timeStamp( ddgStr *timestamp );
};
#endif