GL Studio C++ Runtime API
gls_rso_wrapper.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsRSOWrapper class.
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 _GLS_RSO_WRAPPER_H
41 #define _GLS_RSO_WRAPPER_H
42 
43 #include "component_base.h"
44 
45 #ifdef GLES
46 # include "rso_interface_es_2.h"
47 typedef disti::RSOInterfaceES1 RsoImplBaseInterface;
48 typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT;
49 #else
50 # include "rso_interface_5.h"
53 #endif
54 
55 namespace disti
56 {
57 //class RsoImplBaseInterface;
58 //class RsoImplBaseInterface::DisplayEvent;
59 class AttributeWrapperMap;
60 class EmittedEventHandlerImpl;
61 class MouseEvent;
62 
63 /** The GlsRSOWrapper class wraps an RsoImplBaseInterface object
64  so that it can be inserted into the GL Studio heirarchy.
65  */
67  , virtual public RSOPainterT
68 {
69 public:
70  typedef ComponentBase _BaseClass;
71 
72  /** Constructor
73  * \param rso The RSO to wrap
74  * \param RSOVersion the highest RSOInterface the RSO supports (e.g. 1,2,3)
75  */
76  GLS_EXPORT GlsRSOWrapper( RsoImplBaseInterface* rso, unsigned int RSOVersion );
77 
78  /** Call CreateInstance() and Destroy() instead of new and delete
79  * in a mixed-library environment to ensure that matching
80  * new and delete operators are called.
81  * \param rso The RSO to wrap
82  * \param RSOVersion the highest RSOInterface the RSO supports (e.g. 1,2,3)
83  */
84  static GLS_EXPORT GlsRSOWrapper* CreateInstance( RsoImplBaseInterface* rso, unsigned int RSOVersion );
85 
86  /** Destructor
87  * Don't call "delete yourComponent;", instead call "yourComponent->Destroy();"
88  * to ensure that the object is deleted correctly.
89  */
90  virtual GLS_EXPORT ~GlsRSOWrapper();
91 
92  /** Utility Method: Users should call Destroy() instead.
93  * Safely delete an object that was created using CreateInstance.
94  */
95  virtual GLS_EXPORT void DeleteInstance();
96 
97  /** Replace the RSO that the GlsRSOWrapper is wrapping.
98  * \param rso The new RSO to use
99  * \param deleteCurrent Whether to delete the currently referenced rso. If false, then the caller is responsible for deleting it.
100  */
101  GLS_EXPORT void ChangeRSO( RsoImplBaseInterface* rso, bool deleteCurrent = true );
102 
103  /** Returns the current RSOInterface object
104  */
105  GLS_EXPORT RsoImplBaseInterface* RSOInterface();
106 
107  /** Returns the rso version
108  */
109  unsigned int GetRSOVersion() const
110  {
111  return _rsoVersion;
112  }
113 
114  /** Handle an event that was emitted from the RSO.
115  */
116  GLS_EXPORT int HandleEmittedEvent( RsoImplBaseInterface::Event* ev );
117 
118  /** Returns the qualified instance name of the initiator of the last
119  * event that was passed to HandleEmittedEvent or "" if no events
120  * have been passed to HandleEmittedEvent. */
121  GLS_EXPORT const char* LastEmittedEventInitiatorName() const;
122 
123  // DisplayObject overrides
124 
125  virtual GLS_EXPORT void AlphaMode( int mode );
126  virtual GLS_EXPORT int AlphaMode( void );
127  virtual GLS_EXPORT void AntiAlias( bool alias );
128  virtual GLS_EXPORT bool AntiAlias( void );
129  virtual GLS_EXPORT void SetBlendColor( const GlsColor& color );
130  virtual GLS_EXPORT GlsColor GetBlendColor();
131  virtual GLS_EXPORT GlsColor GetColor();
132  virtual GLS_EXPORT void SetColor( const GlsColor& color );
133  virtual GLS_EXPORT void CullBackFace( const bool val );
134  virtual GLS_EXPORT bool CullBackFace( void );
135  virtual GLS_EXPORT int DepthTest( void );
136  virtual GLS_EXPORT void DepthTest( int zbuf );
137  virtual GLS_EXPORT bool LightingEnabled();
138  virtual GLS_EXPORT void LightingEnabled( bool lighting );
139  virtual GLS_EXPORT int LineStippleMultiplier( void );
140  virtual GLS_EXPORT void LineStippleMultiplier( int mult );
141  virtual GLS_EXPORT int LineStipplePattern( void );
142  virtual GLS_EXPORT void LineStipplePattern( int pattern );
143  virtual GLS_EXPORT float LineWidth( void );
144  virtual GLS_EXPORT void LineWidth( float width );
145  virtual GLS_EXPORT int MaterialIndex();
146  virtual GLS_EXPORT void MaterialIndex( unsigned int index );
147  virtual GLS_EXPORT int PolygonMode( void );
148  virtual GLS_EXPORT void PolygonMode( int mode );
149  virtual GLS_EXPORT int PolygonEnd( void );
150  virtual GLS_EXPORT void PolygonEnd( const int end );
151  virtual GLS_EXPORT int PolygonOffset( void ) const;
152  virtual GLS_EXPORT void PolygonOffset( const int offset );
153  virtual GLS_EXPORT int Shading( void );
154  virtual GLS_EXPORT void Shading( const int shading );
155  virtual GLS_EXPORT int TextureIndex( void );
156  virtual GLS_EXPORT void TextureIndex( int textureIndex );
157  virtual GLS_EXPORT bool TextureRepeat( void );
158  virtual GLS_EXPORT void TextureRepeat( const int rep );
159  virtual GLS_EXPORT int TextureMappingTechnique( void );
160  virtual GLS_EXPORT void TextureMappingTechnique( const int map );
161  virtual GLS_EXPORT int TextureMagnificationFilter( void );
162  virtual GLS_EXPORT void TextureMagnificationFilter( const int filter );
163  virtual GLS_EXPORT int TextureMinificationFilter( void );
164  virtual GLS_EXPORT void TextureMinificationFilter( const int filter );
165 
166  virtual GLS_EXPORT void AbsolutePlacement( bool filter );
167 
168  virtual GLS_EXPORT void Calculate( double time );
169 
170  virtual GLS_EXPORT void CalculateBoundingBox( void );
171 
172  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
173 
174  virtual GLS_EXPORT void CopyGeometry( DisplayObject* src );
175 
176  virtual GLS_EXPORT void CopyProperties( DisplayObject* src );
177 
178 #ifndef GLES
179  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
180 
181  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
182 #endif
183  virtual GLS_EXPORT void CreateObjects();
184 
185  virtual GLS_EXPORT void Draw();
186 
187  virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 );
188 
189  virtual GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true );
190 
191  virtual GLS_EXPORT DisplayObject* handle( DisplayEvent* ev );
192 
193  virtual GLS_EXPORT DisplayObject* HandleInput( DisplayEvent* ev );
194 
195  virtual GLS_EXPORT void Init();
196 
197  virtual GLS_EXPORT void Initialize();
198 
199  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
200  const Vector& logicalCoords,
201  float scale,
202  const Vector& directionVector,
203  Vector& collisionWinLoc /*Returned*/,
204  const OpenGLMatrices& drawnMatrices );
205 
206  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
207 
208  virtual GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL );
209 
210  virtual GLS_EXPORT DistiAttributeBase& Resource( const char* name );
211 
212  /* Unhides base class implementation. */
213  using ComponentBase::Rotate;
214  using ComponentBase::Scale;
215 
216  virtual void GLS_EXPORT UpdateBoundingVolume( void );
217 
218  /** Called on initial creation to set variables */
219  GLS_EXPORT void SetValue( int spec, va_list& args );
220 
221  /** Calls Invalidate on the parent's painter, causing the scene to redraw in conditional rendering. */
222  virtual void GLS_EXPORT Invalidate() DISTI_METHOD_OVERRIDE;
223 
224  /** Assigns a parent painter to this RSO which will be updated when any RSO child object causes invalidation. */
225  virtual void GLS_EXPORT SetPainter( GlsPainter* painter ) DISTI_METHOD_OVERRIDE;
226 
227 protected:
228  /** enum that guides the state machine for multitouch handling for RSO's that don't support multitouch.
229  * An RSO starts in the READY_FOR_INPUT state. When it handles a mouse drag event, it moves to PROCESSING_MOUSE_DRAG
230  * state. It will ignore any other mouse events if they are not for the original cursor_id. Then, once the RSO either receives the
231  * MOUSE_UP event or stops handling the MOUSE_DRAG events, the RSO then transitions to WAITING_FOR_MOUSE_DOWN (i.e. it keeps ignoring other cursors
232  * that might have been dragging on it while it was processing its original cursor event). Once it receives a new mouse down, it transitions back to READY_FOR_INPUT
233  */
235  {
236  READY_FOR_INPUT,
237  PROCESSING_MOUSE_DRAG,
238  WAITING_FOR_MOUSE_DOWN
239  };
240 
241  RsoImplBaseInterface* _rsoInterface;
242  AttributeWrapperMap* _attributeWrapperMap;
243  EmittedEventHandlerImpl* _rsoEmittedEventHandler;
244  char* _lastEmittedEventInitiatorName;
245  MultitouchState _multitouchState;
246  unsigned int _currentCursor;
247  unsigned int _rsoVersion;
248 
249  GLS_EXPORT void LastEmittedEventInitiatorName( const char* name );
250 
251  /** this function should be called to handle mouse events if the RSO handles multitouch (RSO version 3 or greater)
252  */
253  virtual GLS_EXPORT DisplayObject* HandleMultiTouchInput( MouseEvent* mev );
254 };
255 
256 } // namespace disti
257 
258 #endif
Definition: cull.h:49
virtual int AlphaMode(void)
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
virtual void Init()
virtual void CreateObjects()
virtual int MaterialIndex()
The disti::ComponentBase class.
virtual int TextureMagnificationFilter(void)
Definition: rso_interface_5.h:64
virtual void UpdateBoundingVolume(void)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true)
virtual void SetPainter(GlsPainter *painter)
int HandleEmittedEvent(RsoImplBaseInterface::Event *ev)
Definition: dynamic_array.h:62
virtual void Rotate(const Vector &orig, float angle, const Vector &axis)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:301
virtual void Invalidate()
virtual int DepthTest(void)
virtual int TextureMinificationFilter(void)
Definition: display.h:98
virtual float LineWidth(void)
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual int TextureMappingTechnique(void)
virtual int TextureIndex(void)
void ChangeRSO(RsoImplBaseInterface *rso, bool deleteCurrent=true)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
virtual GlsColor GetBlendColor()
virtual ~GlsRSOWrapper()
MultitouchState
Definition: gls_rso_wrapper.h:234
virtual void SetBlendColor(const GlsColor &color)
virtual int Shading(void)
Definition: component_base.h:67
Definition: gls_painter.h:51
Definition: rso_interface_1.h:302
GlsRSOWrapper(RsoImplBaseInterface *rso, unsigned int RSOVersion)
virtual void CopyProperties(DisplayObject *src)
virtual DisplayObject * HandleMultiTouchInput(MouseEvent *mev)
virtual void Calculate(double time)
virtual DisplayObject * handle(DisplayEvent *ev)
virtual void Draw()
void SetValue(int spec, va_list &args)
virtual int LineStippleMultiplier(void)
virtual void SetColor(const GlsColor &color)
T * end(DynamicArray< T, TypeIsSimple > &array)
Overload end() so that range-for loops and other constructs work with DynamicArray.
Definition: dynamic_array.h:450
Definition: rso_interface_1.h:60
RsoImplBaseInterface * RSOInterface()
Definition: disti_metadata.h:182
Definition: events.h:111
Definition: gls_color.h:53
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual DistiAttributeBase & Resource(const char *name)
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter=NULL)
virtual int PolygonEnd(void)
virtual int PolygonMode(void)
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1)
virtual void CopyGeometry(DisplayObject *src)
Definition: group.h:52
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
virtual float Scale(void)
Definition: display_frame.h:135
virtual DisplayObject * HandleInput(DisplayEvent *ev)
virtual void DeleteInstance()
const char * LastEmittedEventInitiatorName() const
Definition: vertex.h:84
virtual int LineStipplePattern(void)
virtual bool AntiAlias(void)
unsigned int GetRSOVersion() const
Definition: gls_rso_wrapper.h:109
Definition: gls_rso_wrapper.h:66
Definition: gls_resources.h:50
bool AbsolutePlacement() const
Definition: component_base.h:112
static GlsRSOWrapper * CreateInstance(RsoImplBaseInterface *rso, unsigned int RSOVersion)
virtual GlsColor GetColor()
virtual bool LightingEnabled()
Definition: bmpimage.h:46
Definition: events.h:219
Defines the RSO interface v5, which extends v4 to add conditional rendering support.
virtual void Initialize()
virtual bool CullBackFace(void)
virtual bool TextureRepeat(void)