GL Studio C++ Runtime API
statistics.h
Go to the documentation of this file.
1/// \file statistics.h
2/// \brief The disti::Statistics class. Tracks and displays runtime performance.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef STATISTICS_H
40#define STATISTICS_H
41
42#include "display_frame.h"
43#include "glpolygon.h"
44#include "group.h"
45#include "timer.h"
46#ifdef GLES
47# include "gls_quad_storage.h"
48#endif
49
50namespace disti
51{
52/** Provides basic runtime performance statistics.
53 * Functionality is built into glsDisplayFrame
54 */
55class Statistics : public Group
56{
57private:
58 typedef struct
59 {
60 unsigned long startTime; /** Absolute (from start of program) uS */
61 unsigned long drawTime; /** Relative (from start of draw) uS */
62 unsigned long preDrawTime; /** Relative (from start of predraw) uS */
63 unsigned long calculateTime; /** Relative (from start of calculate) uS */
64 } frameDataType;
65 frameDataType* historyArray;
66 Vertex* drawLineVerts;
67 Vertex* preDrawLineVerts;
68 Vertex* calculateLineVerts;
69 Vertex* hzLineVerts;
70 unsigned int numFrames;
71 unsigned long _frameInterval;
72 int historyState;
73 int drawState;
74 Timer longTimer;
75 Timer shortTimer;
76 DisplayFrame* parentDisplay;
77 unsigned int currentIndex;
78 unsigned int NextIndex( int index );
79 unsigned int PrevIndex( int index );
80 float _initialWidth;
81 float _initialHeight;
82 bool _textVisible;
83
84#ifdef GLES
85 GlsQuadListVCT_2D _textQuadStorage;
86 GlsQuadListVC_3D _graphQuadStorage;
87#endif
88
89public:
90 /** The current average frame rate in updates per second */
91 float averageHz;
92
93 Group* statsGraphGroup; ///< The group containing the statistics graph.
94 GLPolygon* statsGraphLine; ///< The draw timeline object.
95 GLPolygon* statsPreDrawGraphLine; ///< The predraw timeline object.
96 GLPolygon* statsCalculateGraphLine; ///< The calculate timeline object.
97 GLPolygon* statsHzLine; ///< The framerate timeline object.
98 GLPolygon* statsBox; ///< Bounding box for the statistics objects.
99 GLPolygon* statsTargetLine; ///< The target framerate line object.
100
101 /// Constructor
102 /// \param display The display frame to associate with.
103 /// \param numFrames The number of frames to store in history.
104 /// \param frameInterval The frame interval for the application.
105 GLS_EXPORT Statistics( DisplayFrame* display, unsigned int numFrames, unsigned long frameInterval );
106
107 virtual GLS_EXPORT ~Statistics();
108
109 /// Marks the time at draw start.
110 /// Call right before Draw().
112
113 /// Marks the time at draw end.
114 /// Call right after Draw().
115 virtual GLS_EXPORT void RecordDrawEnd();
116
117 /// Marks the time at predraw start.
118 /// Call right before PreDraw().
120
121 /// Marks the time at predraw end.
122 /// Call right after PreDraw().
124
125 /// Marks the time at calculate start.
126 /// Call right before Calculate().
128
129 /// Marks the time at calculate end.
130 /// Call right after Calculate().
132
134
136
137 /// Helper method to draw the statistics themselves.
138 virtual GLS_EXPORT void DrawStats();
139
140 /// Toggle the statistics displays between its various states.
141 /// 0: Off
142 /// 1: Text and graph
143 /// 2: Graph only
144 /// 3: Text only
145 virtual GLS_EXPORT void ToggleDisplay();
146
147 /// Set the number of frames to store in statistics history.
148 /// \param frames The new number of frames to store.
149 virtual GLS_EXPORT void Samples( int frames );
150
151 /// \return The number of frames to store in statistics history.
152 virtual GLS_EXPORT int Samples();
153
154 /// Set the application frame interval.
155 /// \param microseconds The frame interval to set in microseconds.
156 virtual GLS_EXPORT void FrameInterval( unsigned long microseconds );
157};
158
159} // namespace disti
160
161#endif
Definition: cull.h:49
Definition: display_frame.h:86
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
Definition: gls_quad_storage.h:156
Definition: gls_quad_storage.h:60
Definition: group.h:52
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: statistics.h:56
GLPolygon * statsPreDrawGraphLine
The predraw timeline object.
Definition: statistics.h:95
virtual void RecordDrawEnd()
Group * statsGraphGroup
The group containing the statistics graph.
Definition: statistics.h:93
GLPolygon * statsBox
Bounding box for the statistics objects.
Definition: statistics.h:98
void PreDraw(const OpenGLMatrices &current, Culler &culler) override
virtual void RecordDrawStart()
virtual void RecordPreDrawEnd()
virtual int Samples()
virtual void RecordCalculateEnd()
virtual void RecordCalculateStart()
Statistics(DisplayFrame *display, unsigned int numFrames, unsigned long frameInterval)
virtual void FrameInterval(unsigned long microseconds)
GLPolygon * statsGraphLine
The draw timeline object.
Definition: statistics.h:94
float averageHz
Definition: statistics.h:91
virtual void RecordPreDrawStart()
virtual void ToggleDisplay()
GLPolygon * statsCalculateGraphLine
The calculate timeline object.
Definition: statistics.h:96
virtual void DrawStats()
Helper method to draw the statistics themselves.
GLPolygon * statsTargetLine
The target framerate line object.
Definition: statistics.h:99
GLPolygon * statsHzLine
The framerate timeline object.
Definition: statistics.h:97
void Draw() override
The Timer class.
Definition: timer.h:66
Definition: vertex.h:419
The disti::DisplayFrame class.
The disti::GLPolygon class. Implements Polygons.
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46
The disti::Timer class. An OS portable timing class.