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