Răsfoiți Sursa

fix initialization bug; add minor interfaces

David Rose 20 ani în urmă
părinte
comite
4b58cb8500

+ 14 - 0
panda/src/grutil/frameRateMeter.I

@@ -101,6 +101,7 @@ get_text_pattern() const {
 INLINE void FrameRateMeter::
 set_clock_object(ClockObject *clock_object) {
   _clock_object = clock_object;
+  _last_update = 0.0f;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -113,3 +114,16 @@ INLINE ClockObject *FrameRateMeter::
 get_clock_object() const {
   return _clock_object;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: FrameRateMeter::update
+//       Access: Published
+//  Description: You can call this to explicitly force the
+//               FrameRateMeter to update itself with the latest frame
+//               rate information.  Normally, it is not necessary to
+//               call this explicitly.
+////////////////////////////////////////////////////////////////////
+INLINE void FrameRateMeter::
+update() {
+  do_update();
+}

+ 1 - 0
panda/src/grutil/frameRateMeter.cxx

@@ -39,6 +39,7 @@ TypeHandle FrameRateMeter::_type_handle;
 FrameRateMeter::
 FrameRateMeter(const string &name) : TextNode(name) {
   _update_interval = frame_rate_meter_update_interval;
+  _last_update = 0.0f;
   _text_pattern = frame_rate_meter_text_pattern;
   _clock_object = ClockObject::get_global_clock();
 

+ 2 - 0
panda/src/grutil/frameRateMeter.h

@@ -62,6 +62,8 @@ PUBLISHED:
   INLINE void set_clock_object(ClockObject *clock_object);
   INLINE ClockObject *get_clock_object() const;
 
+  INLINE void update();
+
 protected:
   virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);