| 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
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*/
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
51 namespace disti
52{
53/** Provides basic runtime performance statistics.
54 * Functionality is built into glsDisplayFrame
55 */
56 class Statistics : public Group
57{
58 private:
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
90 public:
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().
112 virtual GLS_EXPORT void RecordDrawStart();
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().
120 virtual GLS_EXPORT void RecordPreDrawStart();
121
122 /// Marks the time at predraw end.
123 /// Call right after PreDraw().
124 virtual GLS_EXPORT void RecordPreDrawEnd();
125
126 /// Marks the time at calculate start.
127 /// Call right before Calculate().
128 virtual GLS_EXPORT void RecordCalculateStart();
129
130 /// Marks the time at calculate end.
131 /// Call right after Calculate().
132 virtual GLS_EXPORT void RecordCalculateEnd();
133
134 virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
135
136 virtual GLS_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
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
disti::Culler
Definition: cull.h:50
disti::DisplayFrame
Definition: display_frame.h:87
disti::GLPolygon
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
disti::GlsQuadListVCT_2D
Definition: gls_quad_storage.h:160
disti::GlsQuadListVC_3D
Definition: gls_quad_storage.h:64
disti::Group
Definition: group.h:53
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::Statistics
Definition: statistics.h:57
disti::Statistics::statsPreDrawGraphLine
GLPolygon * statsPreDrawGraphLine
The predraw timeline object.
Definition: statistics.h:96
disti::Statistics::RecordDrawEnd
virtual void RecordDrawEnd()
disti::Statistics::statsGraphGroup
Group * statsGraphGroup
The group containing the statistics graph.
Definition: statistics.h:94
disti::Statistics::statsBox
GLPolygon * statsBox
Bounding box for the statistics objects.
Definition: statistics.h:99
disti::Statistics::RecordDrawStart
virtual void RecordDrawStart()
disti::Statistics::RecordPreDrawEnd
virtual void RecordPreDrawEnd()
disti::Statistics::Samples
virtual int Samples()
disti::Statistics::RecordCalculateEnd
virtual void RecordCalculateEnd()
disti::Statistics::RecordCalculateStart
virtual void RecordCalculateStart()
disti::Statistics::Statistics
Statistics(DisplayFrame *display, unsigned int numFrames, unsigned long frameInterval)
disti::Statistics::FrameInterval
virtual void FrameInterval(unsigned long microseconds)
disti::Statistics::statsGraphLine
GLPolygon * statsGraphLine
The draw timeline object.
Definition: statistics.h:95
disti::Statistics::averageHz
float averageHz
Definition: statistics.h:92
disti::Statistics::RecordPreDrawStart
virtual void RecordPreDrawStart()
disti::Statistics::ToggleDisplay
virtual void ToggleDisplay()
disti::Statistics::Draw
virtual void Draw() override
disti::Statistics::PreDraw
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
disti::Statistics::statsCalculateGraphLine
GLPolygon * statsCalculateGraphLine
The calculate timeline object.
Definition: statistics.h:97
disti::Statistics::DrawStats
virtual void DrawStats()
Helper method to draw the statistics themselves.
disti::Statistics::statsTargetLine
GLPolygon * statsTargetLine
The target framerate line object.
Definition: statistics.h:100
disti::Statistics::statsHzLine
GLPolygon * statsHzLine
The framerate timeline object.
Definition: statistics.h:98
disti::Timer
The Timer class.
Definition: timer.h:67
disti::Vertex
Definition: vertex.h:420
display_frame.h
The disti::DisplayFrame class.
glpolygon.h
The disti::GLPolygon class. Implements Polygons.
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
gls_quad_storage.h
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47
timer.h
The disti::Timer class. An OS portable timing class.