GL Studio C++ Runtime API
embedded_display_frame.h
Go to the documentation of this file.
1 /*! \file
2  \brief disti::eglDisplayFrame class. The class for creating standalone executables for EGL.
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 EMBEDDED_DISPLAY_H
41 #define EMBEDDED_DISPLAY_H
42 
43 #include "events.h"
44 #include "gls_include.h"
45 #include "runtime_display_frame.h"
46 #include "timer.h"
47 
48 namespace disti
49 {
50 enum FL_Flags
51 {
52  FL_RGB,
53  FL_DOUBLE,
54  FL_DEPTH
55 };
56 
57 /**
58  * Base class for all embedded (openGL ES) display frame classes
59  */
61 {
62 protected:
63  Timer frameTimer; /**< Timer used for scheduling */
64  float _smoothedFrameDelay; /**< Frame interval, smoothed based on actual draw performance */
65  bool _redraw; /**< Flag indicating if the window should be redrawn */
66 
67  float _width_offset; /**< Current "width" offset of window. Used for panning of display horizontally in ortho mode. */
68  float _height_offset; /**< Current "height" offset of window. Used for panning of display vertically in ortho mode. */
69  Vector _viewOffset;
70 
71  /** For better control over clipping and field of view, use a GlsEyePoint, but some limited functionality is available here */
72 
73  float _depthFactor; /**< Used for auto calculations */
74  double _fov; /**< Field Of View. If 0.0 (the default), fov will be auto calculated. */
75  double _nearZ; /**< Near clipping plane. Only meaningful if _autoCalcNearZ is false */
76  bool _autoCalcNearZ; /**< When true a _nearZ is automatically calculated. */
77  double _farZ; /**< Far clipping plane. Only meaningfull if _autoCalcVarZ is false */
78  bool _autoCalcFarZ; /**< When true a _farZ is automatically calculated. */
79 
80  int _current_view; /**< Current view of the canvas (e.g., ortho, perspective, eyepoint) */
81 
82  void WindowFlags( int ) {}
83 
84  /** Builds a DisplayEvent for passing to the handle method
85  * \param x X device coordinate
86  * \param y Y device coordinate
87  * \param pressure Touchscreen pressure
88  * \param eventType Touch event type (e.g. MOUSE_UP,MOUSE_DOWN,MOUSE_DRAG
89  */
90  virtual GLS_EXPORT void BuildAndSendEvent( int x, int y, int pressure, unsigned int eventType );
91 
92  /* \see DisplayFrame */
93  virtual GLS_EXPORT EventCompressor<DisplayFrame>* GetEventComporessor() { return &eventCompressor; }
94 
95 public:
96  enum iDeviceOrientation
97  {
98  ORIENTATION_UNKNOWN = 0,
99  ORIENTATION_PORTRAIT = 1,
100  ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2,
101  ORIENTATION_LANDSCAPE_LEFT = 3,
102  ORIENTATION_LANDSCAPE_RIGHT = 4,
103  ORIENTATION_FACE_UP = 5,
104  ORIENTATION_FACE_DOWN = 6
105  };
106 
107  GLS_EXPORT EmbeddedDisplayFrame( const char* name, int width, int height );
108 
109  virtual GLS_EXPORT ~EmbeddedDisplayFrame();
110 
111  /** Used for event compression. Not for general use by users. */
113 
114  /** Removes (hides) the spash screen
115  * Note on iOS the AppDelegate presents the splash screen for us, so this is just a stub
116  */
117  virtual GLS_EXPORT void RemoveSplash()
118  {
119  }
120 
121  /** Creates the spash screen
122  * Note on iOS the AppDelegate presents the splash screen for us, so this is just a stub
123  */
124  virtual GLS_EXPORT void CreateSplash()
125  {
126  }
127 
128  /** Sets up the default Orthographic projection (which supports things like pan and zoom) */
129  virtual GLS_EXPORT void SetProjection( GlsMatrixType& projMatrix, GlsMatrixType& model );
130 
131  /** Redraw the window at the Hz rate set for the DisplayFrame, or at least
132  * try to. We might be slower if the hardware can't keep up.
133  */
134  virtual GLS_EXPORT bool FrameAnimate( void );
135 
136  /** Redraw the window now.
137  * This actually calls the OpenGL Drawing routines.
138  */
139  virtual GLS_EXPORT void Redraw( void );
140 
141  /** Set a flag that UpdateAnimate can test to see if the window needs redrawing.
142  */
143  virtual GLS_EXPORT void SetRedraw( void );
144 
145  /** Only draw on events or if SetRedraw has been called.
146  * If this is called in a main loop, updates can occur very frequently if SetRedraw is
147  * continuously being called.
148  */
149  virtual GLS_EXPORT bool UpdateAnimate( void );
150 
151  /** Pans the display horizontally
152  * \param offset The new X position at the center of the window
153  */
154  virtual GLS_EXPORT void WidthOffset( float offset );
155 
156  /** Gets the horizontal position of the display at the center of the window
157  * \return The X position at the center of the window
158  */
159  virtual GLS_EXPORT float WidthOffset( void );
160 
161  /** Pans the display vertically
162  * \param offset The new Y position of the center of the window
163  */
164  virtual GLS_EXPORT void HeightOffset( float offset );
165 
166  /** Gets the vertical position of the display at the center of the window
167  * \return The Y position at the center of the window
168  */
169  virtual GLS_EXPORT float HeightOffset( void );
170 
171  /** Sets the Depth Factor for the window
172  * \param factor The depth factor. Used for autocalculating clipping planes */
173  virtual GLS_EXPORT void DepthFactor( float factor );
174 
175  /** Gets the Depth Factor for the window
176  * \return The current depth factor
177  */
178  virtual GLS_EXPORT float DepthFactor();
179 
180  /** Sets the FOV (Field of View) for the window. If fov is set to 0.0, a reasonable FOV
181  * will be calculated based on width and height.
182  * \param fov New field of view in degrees
183  */
184  virtual GLS_EXPORT void FOV( double fov );
185 
186  /** Gets the FOV (Field of View) for the window.
187  * \return The current field of view in degrees
188  */
189  virtual GLS_EXPORT double FOV();
190 
191  /** Sets the current view mode for the window
192  * \param view The new view mode for the window.
193  * Acceptable view types are:
194  * [VIEW_EYEPOINT - The application will be viewed through an eyepoint]
195  * [VIEW_XY - The application will be viewed through a 2D orthographic view of the XY plane]
196  * [VIEW_PERSPECTIVE - The application will be viewed through a perspective projection]
197  */
198  virtual GLS_EXPORT void CurrentView( const int view ) { _current_view = view; }
199 
200  /** Gets the current view mode for the window.
201  * \return The current viewmode for the window (VIEW_EYEPOINT, VIEW_XY, VIEW_PERSPECTIVE)
202  */
203  virtual GLS_EXPORT int CurrentView( void ) const { return _current_view; }
204 };
205 
206 } // namespace disti
207 
208 #endif
EventCompressor< DisplayFrame > eventCompressor
Definition: embedded_display_frame.h:112
virtual void Redraw(void)
Definition: display_frame.h:75
float _depthFactor
Definition: embedded_display_frame.h:73
virtual int CurrentView(void) const
Definition: embedded_display_frame.h:203
virtual void RemoveSplash()
Definition: embedded_display_frame.h:117
virtual void SetProjection(GlsMatrixType &projMatrix, GlsMatrixType &model)
double _farZ
Definition: embedded_display_frame.h:77
virtual void CurrentView(const int view)
Definition: embedded_display_frame.h:198
The disti::Timer class. An OS portable timing class.
Definition: runtime_display_frame.h:52
A file for all GL Studio files to include.
virtual float WidthOffset(void)
virtual bool UpdateAnimate(void)
double _nearZ
Definition: embedded_display_frame.h:75
virtual void CreateSplash()
Definition: embedded_display_frame.h:124
The standard Mouse and keyboard events and event structures.
Definition: timer.h:66
bool _redraw
Definition: embedded_display_frame.h:65
Timer frameTimer
Definition: embedded_display_frame.h:63
float _height_offset
Definition: embedded_display_frame.h:68
bool _autoCalcFarZ
Definition: embedded_display_frame.h:78
virtual float HeightOffset(void)
double _fov
Definition: embedded_display_frame.h:74
Definition: embedded_display_frame.h:60
virtual void BuildAndSendEvent(int x, int y, int pressure, unsigned int eventType)
bool _autoCalcNearZ
Definition: embedded_display_frame.h:76
float _width_offset
Definition: embedded_display_frame.h:67
Definition: vertex.h:83
virtual void SetRedraw(void)
float _smoothedFrameDelay
Definition: embedded_display_frame.h:64
The disti::RuntimeDisplayFrame class, parent class of all DisplayFrames used in runtime code...
virtual float DepthFactor()
virtual bool FrameAnimate(void)
Definition: bmpimage.h:46
int _current_view
Definition: embedded_display_frame.h:80