00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef FRAMERATEMETER_H
00016 #define FRAMERATEMETER_H
00017
00018 #include "pandabase.h"
00019 #include "textNode.h"
00020 #include "nodePath.h"
00021 #include "graphicsOutput.h"
00022 #include "displayRegion.h"
00023 #include "pointerTo.h"
00024 #include "pStatCollector.h"
00025
00026 class GraphicsChannel;
00027 class ClockObject;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class EXPCL_PANDA_GRUTIL FrameRateMeter : public TextNode {
00042 PUBLISHED:
00043 FrameRateMeter(const string &name);
00044 virtual ~FrameRateMeter();
00045
00046 void setup_window(GraphicsOutput *window);
00047 void clear_window();
00048
00049 INLINE GraphicsOutput *get_window() const;
00050 INLINE DisplayRegion *get_display_region() const;
00051
00052 INLINE void set_update_interval(double update_interval);
00053 INLINE double get_update_interval() const;
00054
00055 INLINE void set_text_pattern(const string &text_pattern);
00056 INLINE const string &get_text_pattern() const;
00057
00058 INLINE void set_clock_object(ClockObject *clock_object);
00059 INLINE ClockObject *get_clock_object() const;
00060
00061 INLINE void update();
00062
00063 protected:
00064 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00065
00066 private:
00067 void do_update(Thread *current_thread);
00068
00069 private:
00070 PT(GraphicsOutput) _window;
00071 PT(DisplayRegion) _display_region;
00072 NodePath _root;
00073
00074 double _update_interval;
00075 double _last_update;
00076 string _text_pattern;
00077 ClockObject *_clock_object;
00078
00079 static PStatCollector _show_fps_pcollector;
00080
00081 public:
00082 static TypeHandle get_class_type() {
00083 return _type_handle;
00084 }
00085 static void init_type() {
00086 TextNode::init_type();
00087 register_type(_type_handle, "FrameRateMeter",
00088 TextNode::get_class_type());
00089 }
00090 virtual TypeHandle get_type() const {
00091 return get_class_type();
00092 }
00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00094
00095 private:
00096 static TypeHandle _type_handle;
00097 };
00098
00099 #include "frameRateMeter.I"
00100
00101 #endif