Browse Source

more fixes after removing GraphicsLayer

David Rose 21 years ago
parent
commit
3f94604fc3

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

@@ -20,9 +20,8 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: FrameRateMeter::get_window
 //     Function: FrameRateMeter::get_window
 //       Access: Published
 //       Access: Published
-//  Description: Returns the GraphicsOutput that the meter has created
-//               to render itself into the window or channel supplied
-//               to setup_window(), or NULL if setup_window() has not
+//  Description: Returns the GraphicsOutput that was passed to
+//               setup_window(), or NULL if setup_window() has not
 //               been called.
 //               been called.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE GraphicsOutput *FrameRateMeter::
 INLINE GraphicsOutput *FrameRateMeter::
@@ -30,6 +29,18 @@ get_window() const {
   return _window;
   return _window;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: FrameRateMeter::get_display_region
+//       Access: Published
+//  Description: Returns the DisplayRegion that the meter has created
+//               to render itself into the window to setup_window(),
+//               or NULL if setup_window() has not been called.
+////////////////////////////////////////////////////////////////////
+INLINE DisplayRegion *FrameRateMeter::
+get_display_region() const {
+  return _display_region;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: FrameRateMeter::set_update_interval
 //     Function: FrameRateMeter::set_update_interval
 //       Access: Published
 //       Access: Published

+ 7 - 3
panda/src/grutil/frameRateMeter.cxx

@@ -44,7 +44,7 @@ FrameRateMeter(const string &name) : TextNode(name) {
 
 
   set_align(A_right);
   set_align(A_right);
   set_transform(LMatrix4f::scale_mat(frame_rate_meter_scale) * 
   set_transform(LMatrix4f::scale_mat(frame_rate_meter_scale) * 
-                LMatrix4f::translate_mat(1.0f - frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, 1.0f - frame_rate_meter_scale));
+                LMatrix4f::translate_mat(LVector3f::rfu(1.0f - frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, 1.0f - frame_rate_meter_scale)));
   set_card_color(0.0f, 0.0f, 0.0f, 0.4f);
   set_card_color(0.0f, 0.0f, 0.0f, 0.4f);
   set_card_as_margin(frame_rate_meter_side_margins, frame_rate_meter_side_margins, 0.1f, 0.0f);
   set_card_as_margin(frame_rate_meter_side_margins, frame_rate_meter_side_margins, 0.1f, 0.0f);
 
 
@@ -86,6 +86,7 @@ setup_window(GraphicsOutput *window) {
     
     
   // Create a display region that covers the entire window.
   // Create a display region that covers the entire window.
   _display_region = _window->make_display_region();
   _display_region = _window->make_display_region();
+  _display_region->set_sort(frame_rate_meter_layer_sort);
     
     
   // Finally, we need a camera to associate with the display region.
   // Finally, we need a camera to associate with the display region.
   PT(Camera) camera = new Camera("frame_rate_camera");
   PT(Camera) camera = new Camera("frame_rate_camera");
@@ -114,8 +115,11 @@ setup_window(GraphicsOutput *window) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void FrameRateMeter::
 void FrameRateMeter::
 clear_window() {
 clear_window() {
-  _window = (GraphicsOutput *)NULL;
-  _display_region = (DisplayRegion *)NULL;
+  if (_window != (GraphicsOutput *)NULL) {
+    _window->remove_display_region(_display_region);
+    _window = (GraphicsOutput *)NULL;
+    _display_region = (DisplayRegion *)NULL;
+  }
   _root = NodePath();
   _root = NodePath();
 }
 }
 
 

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

@@ -51,6 +51,7 @@ PUBLISHED:
   void clear_window();
   void clear_window();
 
 
   INLINE GraphicsOutput *get_window() const;
   INLINE GraphicsOutput *get_window() const;
+  INLINE DisplayRegion *get_display_region() const;
 
 
   INLINE void set_update_interval(double update_interval);
   INLINE void set_update_interval(double update_interval);
   INLINE double get_update_interval() const;
   INLINE double get_update_interval() const;