Panda3D
 All Classes Functions Variables Enumerations
frameRateMeter.I
00001 // Filename: frameRateMeter.I
00002 // Created by:  drose (23Dec03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: FrameRateMeter::get_window
00018 //       Access: Published
00019 //  Description: Returns the GraphicsOutput that was passed to
00020 //               setup_window(), or NULL if setup_window() has not
00021 //               been called.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE GraphicsOutput *FrameRateMeter::
00024 get_window() const {
00025   return _window;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: FrameRateMeter::get_display_region
00030 //       Access: Published
00031 //  Description: Returns the DisplayRegion that the meter has created
00032 //               to render itself into the window to setup_window(),
00033 //               or NULL if setup_window() has not been called.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE DisplayRegion *FrameRateMeter::
00036 get_display_region() const {
00037   return _display_region;
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: FrameRateMeter::set_update_interval
00042 //       Access: Published
00043 //  Description: Specifies the number of seconds that should elapse
00044 //               between updates to the frame rate indication.  This
00045 //               should be reasonably slow (e.g. 0.2 to 1.0) so that
00046 //               the calculation of the frame rate text does not
00047 //               itself dominate the frame rate.
00048 ////////////////////////////////////////////////////////////////////
00049 INLINE void FrameRateMeter::
00050 set_update_interval(double update_interval) {
00051   _update_interval = update_interval;
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: FrameRateMeter::get_update_interval
00056 //       Access: Published
00057 //  Description: Returns the number of seconds that will elapse
00058 //               between updates to the frame rate indication.
00059 ////////////////////////////////////////////////////////////////////
00060 INLINE double FrameRateMeter::
00061 get_update_interval() const {
00062   return _update_interval;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: FrameRateMeter::set_text_pattern
00067 //       Access: Published
00068 //  Description: Sets the sprintf() pattern that is used to format the
00069 //               text.  The string "%f" or some variant will be
00070 //               replaced with the current frame rate in frames per
00071 //               second.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE void FrameRateMeter::
00074 set_text_pattern(const string &text_pattern) {
00075   _text_pattern = text_pattern;
00076   Thread *current_thread = Thread::get_current_thread();
00077   do_update(current_thread);
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: FrameRateMeter::get_text_pattern
00082 //       Access: Published
00083 //  Description: Returns the sprintf() pattern that is used to format the
00084 //               text.
00085 ////////////////////////////////////////////////////////////////////
00086 INLINE const string &FrameRateMeter::
00087 get_text_pattern() const {
00088   return _text_pattern;
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: FrameRateMeter::set_clock_object
00093 //       Access: Published
00094 //  Description: Sets the clock that is used to determine the frame
00095 //               rate.  The default is the application's global clock
00096 //               (ClockObject::get_global_clock()).
00097 ////////////////////////////////////////////////////////////////////
00098 INLINE void FrameRateMeter::
00099 set_clock_object(ClockObject *clock_object) {
00100   _clock_object = clock_object;
00101   _last_update = 0.0f;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: FrameRateMeter::get_clock_object
00106 //       Access: Published
00107 //  Description: Returns the clock that is used to determine the frame
00108 //               rate.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE ClockObject *FrameRateMeter::
00111 get_clock_object() const {
00112   return _clock_object;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: FrameRateMeter::update
00117 //       Access: Published
00118 //  Description: You can call this to explicitly force the
00119 //               FrameRateMeter to update itself with the latest frame
00120 //               rate information.  Normally, it is not necessary to
00121 //               call this explicitly.
00122 ////////////////////////////////////////////////////////////////////
00123 INLINE void FrameRateMeter::
00124 update() {
00125   Thread *current_thread = Thread::get_current_thread();
00126   do_update(current_thread);
00127 }
 All Classes Functions Variables Enumerations