Panda3D
Loading...
Searching...
No Matches
frameRateMeter.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file frameRateMeter.h
10 * @author drose
11 * @date 2003-12-23
12 */
13
14#ifndef FRAMERATEMETER_H
15#define FRAMERATEMETER_H
16
17#include "pandabase.h"
18#include "textNode.h"
19#include "nodePath.h"
20#include "graphicsOutput.h"
21#include "displayRegion.h"
22#include "pointerTo.h"
23#include "pStatCollector.h"
24
25class GraphicsChannel;
26class ClockObject;
27
28/**
29 * This is a special TextNode that automatically updates itself with the
30 * current frame rate. It can be placed anywhere in the world where you'd
31 * like to see the frame rate.
32 *
33 * It also has a special mode in which it may be attached directly to a
34 * channel or window. If this is done, it creates a DisplayRegion for itself
35 * and renders itself in the upper-right-hand corner.
36 */
37class EXPCL_PANDA_GRUTIL FrameRateMeter : public TextNode {
38PUBLISHED:
39 explicit FrameRateMeter(const std::string &name);
40 virtual ~FrameRateMeter();
41
42 void setup_window(GraphicsOutput *window);
43 void clear_window();
44
45 INLINE GraphicsOutput *get_window() const;
46 INLINE DisplayRegion *get_display_region() const;
47
48 INLINE void set_update_interval(double update_interval);
49 INLINE double get_update_interval() const;
50
51 INLINE void set_text_pattern(const std::string &text_pattern);
52 INLINE const std::string &get_text_pattern() const;
53
54 INLINE void set_clock_object(ClockObject *clock_object);
55 INLINE ClockObject *get_clock_object() const;
56
57 INLINE void update();
58
59protected:
60 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
61
62private:
63 void do_update(Thread *current_thread);
64
65private:
66 PT(GraphicsOutput) _window;
67 PT(DisplayRegion) _display_region;
68 NodePath _root;
69
70 bool _show_milliseconds;
71 double _update_interval;
72 double _last_update;
73 std::string _text_pattern;
74 ClockObject *_clock_object;
75
76 PN_stdfloat _last_aspect_ratio;
77 CPT(TransformState) _aspect_ratio_transform;
78
79 static PStatCollector _show_fps_pcollector;
80
81public:
82 static TypeHandle get_class_type() {
83 return _type_handle;
84 }
85 static void init_type() {
86 TextNode::init_type();
87 register_type(_type_handle, "FrameRateMeter",
88 TextNode::get_class_type());
89 }
90 virtual TypeHandle get_type() const {
91 return get_class_type();
92 }
93 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94
95private:
96 static TypeHandle _type_handle;
97};
98
99#include "frameRateMeter.I"
100
101#endif
A ClockObject keeps track of elapsed real time and discrete time.
Definition clockObject.h:58
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A rectangular subregion within a window for rendering into.
This is a special TextNode that automatically updates itself with the current frame rate.
This is a base class for the various different classes that represent the result of a frame of render...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A lightweight class that represents a single element that may be timed and/or counted via stats.
The primary interface to this module.
Definition textNode.h:48
void update()
Can be called after the TextNode has been fully configured, to force the node to recompute its text i...
Definition textNode.I:1162
A thread; that is, a lightweight process.
Definition thread.h:46
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.