diff --git a/panda/src/grutil/frameRateMeter.I b/panda/src/grutil/frameRateMeter.I index 65984fd568..87385fc059 100644 --- a/panda/src/grutil/frameRateMeter.I +++ b/panda/src/grutil/frameRateMeter.I @@ -20,9 +20,8 @@ //////////////////////////////////////////////////////////////////// // Function: FrameRateMeter::get_window // 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. //////////////////////////////////////////////////////////////////// INLINE GraphicsOutput *FrameRateMeter:: @@ -30,6 +29,18 @@ get_window() const { 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 // Access: Published diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index c7452ca625..036ab9b421 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -44,7 +44,7 @@ FrameRateMeter(const string &name) : TextNode(name) { set_align(A_right); 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_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. _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. PT(Camera) camera = new Camera("frame_rate_camera"); @@ -114,8 +115,11 @@ setup_window(GraphicsOutput *window) { //////////////////////////////////////////////////////////////////// void FrameRateMeter:: 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(); } diff --git a/panda/src/grutil/frameRateMeter.h b/panda/src/grutil/frameRateMeter.h index bb976f487a..acae637e46 100644 --- a/panda/src/grutil/frameRateMeter.h +++ b/panda/src/grutil/frameRateMeter.h @@ -51,6 +51,7 @@ PUBLISHED: void clear_window(); INLINE GraphicsOutput *get_window() const; + INLINE DisplayRegion *get_display_region() const; INLINE void set_update_interval(double update_interval); INLINE double get_update_interval() const;