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;
95  GLPolygon* statsGraphLine;
96  GLPolygon* statsPreDrawGraphLine;
97  GLPolygon* statsCalculateGraphLine;
98  GLPolygon* statsHzLine;
99  GLPolygon* statsBox;
100  GLPolygon* statsTargetLine;
101 
102  GLS_EXPORT Statistics( DisplayFrame* display, unsigned int numFrames, unsigned long frameInterval );
103  virtual GLS_EXPORT ~Statistics();
104 
105  virtual GLS_EXPORT void RecordDrawStart();
106  virtual GLS_EXPORT void RecordDrawEnd();
107  virtual GLS_EXPORT void RecordPreDrawStart();
108  virtual GLS_EXPORT void RecordPreDrawEnd();
109  virtual GLS_EXPORT void RecordCalculateStart();
110  virtual GLS_EXPORT void RecordCalculateEnd();
111 
112  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
113 
114  virtual GLS_EXPORT void Draw();
115  virtual GLS_EXPORT void DrawStats();
116 
117  virtual GLS_EXPORT void ToggleDisplay();
118 
119  virtual GLS_EXPORT void Samples( int frames );
120  virtual GLS_EXPORT int Samples();
121 
122  virtual GLS_EXPORT void FrameInterval( unsigned long microseconds );
123 };
124 
125 } // namespace disti
126 
127 #endif
Definition: cull.h:49
Definition: display_frame.h:85
virtual void Draw()
Definition: vertex.h:409
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:473
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
The disti::GLPolygon class. Implements Polygons.
Definition: gls_quad_storage.h:158
The disti::Timer class. An OS portable timing class.
Definition: statistics.h:56
Definition: timer.h:66
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
The disti::DisplayFrame class.
float averageHz
Definition: statistics.h:92
Definition: group.h:52
Definition: gls_quad_storage.h:63
Definition: bmpimage.h:46