Panda3D
Loading...
Searching...
No Matches
frameRateMeter.I
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.I
10 * @author drose
11 * @date 2003-12-23
12 */
13
14/**
15 * Returns the GraphicsOutput that was passed to setup_window(), or NULL if
16 * setup_window() has not been called.
17 */
19get_window() const {
20 return _window;
21}
22
23/**
24 * Returns the DisplayRegion that the meter has created to render itself into
25 * the window to setup_window(), or NULL if setup_window() has not been
26 * called.
27 */
29get_display_region() const {
30 return _display_region;
31}
32
33/**
34 * Specifies the number of seconds that should elapse between updates to the
35 * frame rate indication. This should be reasonably slow (e.g. 0.2 to 1.0)
36 * so that the calculation of the frame rate text does not itself dominate the
37 * frame rate.
38 */
40set_update_interval(double update_interval) {
41 _update_interval = update_interval;
42}
43
44/**
45 * Returns the number of seconds that will elapse between updates to the frame
46 * rate indication.
47 */
48INLINE double FrameRateMeter::
49get_update_interval() const {
50 return _update_interval;
51}
52
53/**
54 * Sets the sprintf() pattern that is used to format the text. The string
55 * "%f" or some variant will be replaced with the current frame rate in frames
56 * per second.
57 */
59set_text_pattern(const std::string &text_pattern) {
60 _text_pattern = text_pattern;
61 Thread *current_thread = Thread::get_current_thread();
62 do_update(current_thread);
63}
64
65/**
66 * Returns the sprintf() pattern that is used to format the text.
67 */
68INLINE const std::string &FrameRateMeter::
69get_text_pattern() const {
70 return _text_pattern;
71}
72
73/**
74 * Sets the clock that is used to determine the frame rate. The default is
75 * the application's global clock (ClockObject::get_global_clock()).
76 */
78set_clock_object(ClockObject *clock_object) {
79 _clock_object = clock_object;
80 _last_update = 0.0f;
81}
82
83/**
84 * Returns the clock that is used to determine the frame rate.
85 */
87get_clock_object() const {
88 return _clock_object;
89}
90
91/**
92 * You can call this to explicitly force the FrameRateMeter to update itself
93 * with the latest frame rate information. Normally, it is not necessary to
94 * call this explicitly.
95 */
97update() {
98 Thread *current_thread = Thread::get_current_thread();
99 do_update(current_thread);
100}
A ClockObject keeps track of elapsed real time and discrete time.
Definition clockObject.h:58
A rectangular subregion within a window for rendering into.
void set_clock_object(ClockObject *clock_object)
Sets 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...
const std::string & get_text_pattern() const
Returns the sprintf() pattern that is used to format the text.
double get_update_interval() const
Returns the number of seconds that will elapse between updates to the frame rate indication.
void set_text_pattern(const std::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.
ClockObject * get_clock_object() const
Returns the clock that is used to determine the frame rate.
void update()
You can call this to explicitly force the FrameRateMeter to update itself with the latest frame rate ...
GraphicsOutput * get_window() const
Returns the GraphicsOutput that was passed to setup_window(), or NULL if setup_window() has not been ...
This is a base class for the various different classes that represent the result of a frame of render...
A thread; that is, a lightweight process.
Definition thread.h:46
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition thread.h:109