Panda3D
|
This is a special TextNode that automatically updates itself with the current frame rate. More...
#include "frameRateMeter.h"
Public Member Functions | |
FrameRateMeter (const string &name) | |
void | clear_window () |
Undoes the effect of a previous call to setup_window(). | |
virtual TypeHandle | force_init_type () |
ClockObject * | get_clock_object () const |
Returns the clock that is used to determine the frame rate. | |
DisplayRegion * | get_display_region () const |
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. | |
const string & | get_text_pattern () const |
Returns the sprintf() pattern that is used to format the text. | |
virtual TypeHandle | get_type () const |
double | get_update_interval () const |
Returns the number of seconds that will elapse between updates to the frame rate indication. | |
GraphicsOutput * | get_window () const |
Returns the GraphicsOutput that was passed to setup_window(), or NULL if setup_window() has not been called. | |
void | set_clock_object (ClockObject *clock_object) |
Sets the clock that is used to determine the frame rate. | |
void | set_text_pattern (const string &text_pattern) |
Sets the sprintf() pattern that is used to format the text. | |
void | set_update_interval (double update_interval) |
Specifies the number of seconds that should elapse between updates to the frame rate indication. | |
void | setup_window (GraphicsOutput *window) |
Sets up the frame rate meter to create a DisplayRegion to render itself into the indicated window. | |
void | update () |
You can call this to explicitly force the FrameRateMeter to update itself with the latest frame rate information. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. |
This is a special TextNode that automatically updates itself with the current frame rate.
It can be placed anywhere in the world where you'd like to see the frame rate.
It also has a special mode in which it may be attached directly to a channel or window. If this is done, it creates a DisplayRegion for itself and renders itself in the upper-right-hand corner.
Definition at line 41 of file frameRateMeter.h.
void FrameRateMeter::clear_window | ( | ) |
Undoes the effect of a previous call to setup_window().
Definition at line 127 of file frameRateMeter.cxx.
Referenced by setup_window().
bool FrameRateMeter::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [protected, virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from TextNode.
Definition at line 162 of file frameRateMeter.cxx.
References CullTraverser::get_current_thread(), and ClockObject::get_frame_time().
ClockObject * FrameRateMeter::get_clock_object | ( | ) | const [inline] |
Returns the clock that is used to determine the frame rate.
Definition at line 111 of file frameRateMeter.I.
DisplayRegion * FrameRateMeter::get_display_region | ( | ) | const [inline] |
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.
Definition at line 36 of file frameRateMeter.I.
const string & FrameRateMeter::get_text_pattern | ( | ) | const [inline] |
Returns the sprintf() pattern that is used to format the text.
Definition at line 87 of file frameRateMeter.I.
double FrameRateMeter::get_update_interval | ( | ) | const [inline] |
Returns the number of seconds that will elapse between updates to the frame rate indication.
Definition at line 61 of file frameRateMeter.I.
GraphicsOutput * FrameRateMeter::get_window | ( | ) | const [inline] |
Returns the GraphicsOutput that was passed to setup_window(), or NULL if setup_window() has not been called.
Definition at line 24 of file frameRateMeter.I.
void FrameRateMeter::set_clock_object | ( | ClockObject * | clock_object | ) | [inline] |
Sets the clock that is used to determine the frame rate.
The default is the application's global clock (ClockObject::get_global_clock()).
Definition at line 99 of file frameRateMeter.I.
void FrameRateMeter::set_text_pattern | ( | const string & | text_pattern | ) | [inline] |
Sets the sprintf() pattern that is used to format the text.
The string "%f" or some variant will be replaced with the current frame rate in frames per second.
Definition at line 74 of file frameRateMeter.I.
References Thread::get_current_thread().
void FrameRateMeter::set_update_interval | ( | double | update_interval | ) | [inline] |
Specifies the number of seconds that should elapse between updates to the frame rate indication.
This should be reasonably slow (e.g. 0.2 to 1.0) so that the calculation of the frame rate text does not itself dominate the frame rate.
Definition at line 50 of file frameRateMeter.I.
void FrameRateMeter::setup_window | ( | GraphicsOutput * | window | ) |
Sets up the frame rate meter to create a DisplayRegion to render itself into the indicated window.
Definition at line 82 of file frameRateMeter.cxx.
References NodePath::attach_new_node(), clear_window(), NodePath::node(), PandaNode::set_attrib(), Lens::set_film_size(), NodePath::set_material_off(), and NodePath::set_two_sided().
void FrameRateMeter::update | ( | ) | [inline] |
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.
Reimplemented from TextNode.
Definition at line 124 of file frameRateMeter.I.
References Thread::get_current_thread().