00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CLOCKOBJECT_H
00020 #define CLOCKOBJECT_H
00021
00022 #include <pandabase.h>
00023
00024 #include "trueClock.h"
00025 #include "config_express.h"
00026
00027 class EXPCL_PANDAEXPRESS TimeVal {
00028 PUBLISHED:
00029 INLINE TimeVal(void);
00030 INLINE ulong get_sec(void) const;
00031 INLINE ulong get_usec(void) const;
00032 ulong tv[2];
00033 };
00034
00035 BEGIN_PUBLISH
00036
00037 EXPCL_PANDAEXPRESS void get_time_of_day(TimeVal &tv);
00038
00039 END_PUBLISH
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 class EXPCL_PANDAEXPRESS ClockObject {
00067 PUBLISHED:
00068 enum Mode {
00069 M_normal,
00070 M_non_real_time,
00071 };
00072
00073 ClockObject();
00074 INLINE ~ClockObject();
00075
00076 INLINE void set_mode(Mode mode);
00077 INLINE Mode get_mode() const;
00078
00079 INLINE double get_frame_time() const;
00080 INLINE double get_real_time() const;
00081 INLINE double get_long_time() const;
00082
00083 INLINE void reset();
00084 void set_real_time(double time);
00085 void set_frame_time(double time);
00086 void set_frame_count(int frame_count);
00087
00088 INLINE int get_frame_count() const;
00089 INLINE double get_frame_rate() const;
00090
00091 INLINE double get_dt() const;
00092 INLINE void set_dt(double dt);
00093
00094 INLINE double get_max_dt() const;
00095 INLINE void set_max_dt(double max_dt);
00096
00097 void tick();
00098 void sync_frame_time();
00099
00100 INLINE static ClockObject *get_global_clock();
00101
00102 private:
00103 TrueClock *_true_clock;
00104 Mode _mode;
00105 double _start_short_time;
00106 double _start_long_time;
00107 int _frame_count;
00108 double _actual_frame_time;
00109 double _reported_frame_time;
00110 double _dt;
00111 double _max_dt;
00112
00113 static ClockObject *_global_clock;
00114 };
00115
00116 #include "clockObject.I"
00117
00118 #endif
00119