checkErrors bool ClockObject::check_errors(void); Description: Returns true if a clock error was detected since the last time check_errors() was called. A clock error means that something happened, an OS or BIOS bug, for instance, that makes the current value of the clock somewhat suspect, and an application may wish to resynchronize with any external clocks. |
getAverageFrameRate double ClockObject::get_average_frame_rate(void) const; Description: Returns the average frame rate in number of frames per second over the last get_average_frame_rate_interval() seconds. This measures the virtual frame rate if the clock is in M_non_real_time mode. |
getAverageFrameRateInterval double ClockObject::get_average_frame_rate_interval(void) const; Description: Returns the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate. |
getDegradeFactor double ClockObject::get_degrade_factor(void) const; Description: In degrade mode, returns the ratio by which the performance is degraded. A value of 2.0 causes the clock to be slowed down by a factor of two (reducing performance to 1/2 what would be otherwise). This has no effect if mode is not M_degrade. |
getDt double ClockObject::get_dt(void) const; Description: Returns the elapsed time for the previous frame: the number of seconds elapsed between the last two calls to tick(). |
getFrameCount int ClockObject::get_frame_count(void) const; Description: Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset. This is generally the number of frames that have been rendered. |
getFrameTime double ClockObject::get_frame_time(void) const; Description: Returns the time in seconds as of the last time tick() was called (typically, this will be as of the start of the current frame). This is generally the kind of time you want to ask for in most rendering and animation contexts, since it's important that all of the animation for a given frame remains in sync with each other. |
getGlobalClock static ClockObject *ClockObject::get_global_clock(void); Description: Returns a pointer to the global ClockObject. This is the ClockObject that most code should use for handling scene graph rendering and animation. |
getLongTime double ClockObject::get_long_time(void) const; Description: Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset. This is similar to get_real_time(), except that it uses the most accurate counter we have over a long period of time, and so it is less likely to drift. However, it may not be very precise for measuring short intervals. On Windows, for instace, this is only accurate to within about 55 milliseconds. |
getMaxDt double ClockObject::get_max_dt(void) const; Description: Returns the current maximum allowable time elapsed between any two frames. See set_max_dt(). |
getMode ClockObject::Mode ClockObject::get_mode(void) const; Description: Returns the current mode of the clock. See set_mode(). |
getNetFrameRate double ClockObject::get_net_frame_rate(void) const; Description: Returns the average frame rate since the last reset. This is simply the total number of frames divided by the total elapsed time. This reports the virtual frame rate if the clock is in (or has been in) M_non_real_time mode. |
getRealTime double ClockObject::get_real_time(void) const; Description: Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last reset. This is useful for doing real timing measurements, e.g. for performance statistics. This returns the most precise timer we have for short time intervals, but it may tend to drift over the long haul. If more accurate timekeeping is needed over a long period of time, use get_long_time() instead. |
reset void ClockObject::reset(void); Description: Simultaneously resets both the time and the frame count to zero. |
setAverageFrameRateInterval void ClockObject::set_average_frame_rate_interval(double time); Description: Specifies the interval of time (in seconds) over which get_average_frame_rate() averages the number of frames per second to compute the frame rate. Changing this does not necessarily immediately change the result of get_average_frame_rate(), until this interval of time has elapsed again. Setting this to zero disables the computation of get_average_frame_rate(). |
setDegradeFactor void ClockObject::set_degrade_factor(double degrade_factor); Description: In degrade mode, sets the ratio by which the performance is degraded. A value of 2.0 causes the clock to be slowed down by a factor of two (reducing performance to 1/2 what would be otherwise). This has no effect if mode is not M_degrade. |
setDt void ClockObject::set_dt(double dt); Description: In non-real-time mode, sets the number of seconds that should appear to elapse between frames. In forced mode, sets our target dt. In normal mode, this has no effect. |
setFrameCount void ClockObject::set_frame_count(int frame_count); Description: Resets the number of frames counted to the indicated number. Also see reset(), set_real_time(), and set_frame_time(). |
setFrameTime void ClockObject::set_frame_time(double time); Description: Changes the time as reported for the current frame to the indicated time. Normally, the way to adjust the frame time is via tick(); this function is provided only for occasional special adjustments. |
setMaxDt void ClockObject::set_max_dt(double max_dt); Description: Sets a limit on the value returned by get_dt(). If this value is less than zero, no limit is imposed; otherwise, this is the maximum value that will ever be returned by get_dt(), regardless of how much time has actually elapsed between frames. This limit is only imposed in real-time mode; in non-real-time mode, the dt is fixed anyway and max_dt is ignored. This is generally used to guarantee reasonable behavior even in the presence of a very slow or chuggy frame rame. |
setMode void ClockObject::set_mode(ClockObject::Mode mode); Description: Changes the mode of the clock, e.g. from normal (real-time) to non-real-time. In non-real-time mode, tick() will add the value of dt to the value returned by get_frame_time(), regardless of how much time has actually passed. In normal, real-time mode, tick() will set the value returned by get_frame_time() to the current real time. |
setRealTime void ClockObject::set_real_time(double time); Description: Resets the clock to the indicated time. This changes only the real time of the clock as reported by get_real_time(), but does not immediately change the time reported by get_frame_time()--that will change after the next call to tick(). Also see reset(), set_frame_time(), and set_frame_count(). |
syncFrameTime void ClockObject::sync_frame_time(void); Description: Resets the frame time to the current real time. This is similar to tick(), except that it does not advance the frame counter and does not affect dt. This is intended to be used in the middle of a particularly long frame to compensate for the time that has already elapsed. In non-real-time mode, this function has no effect (because in this mode all frames take the same length of time). |
tick void ClockObject::tick(void); Description: Instructs the clock that a new frame has just begun. In normal, real-time mode, get_frame_time() will henceforth report the time as of this instant as the current start-of-frame time. In non-real-time mode, get_frame_time() will be incremented by the value of dt. |