GL Studio C++ Runtime API
gls_rso_wrapper.h
Go to the documentation of this file.
1/// \file gls_rso_wrapper.h
2/// \brief The disti::GlsRSOWrapper class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef DISTI_INCLUDED_GLS_RSO_WRAPPER_H
40#define DISTI_INCLUDED_GLS_RSO_WRAPPER_H
41
42#include "component_base.h"
43
44#ifdef GLES
45# include "rso_interface_es_2.h"
46typedef disti::RSOInterfaceES1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
47typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
48#else
49# include "rso_interface_5.h"
50typedef disti::RSOInterface1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
51typedef disti::RSOInterface5::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
52#endif
53
54namespace disti
55{
56class AttributeWrapperMap;
57class EmittedEventHandlerImpl;
58class MouseEvent;
59
60/** The GlsRSOWrapper class wraps an RsoImplBaseInterface object
61 so that it can be inserted into the GL Studio heirarchy.
62 */
64 , virtual public RSOPainterT
65{
66public:
67 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
68 typedef ComponentBase _BaseClass; ///< Deprecated typedef for the base class.
69 typedef ComponentBase BaseClass; ///< Typedef for the base class.
70
71 /// Constructor
72 /// \param rso The RSO to wrap.
73 /// \param RSOVersion The highest RSOInterface the RSO supports (e.g. 1,2,3).
74 GLS_EXPORT GlsRSOWrapper( RsoImplBaseInterface* rso, unsigned int RSOVersion );
75
76 /// Call CreateInstance() and Destroy() instead of new and delete
77 /// in a mixed-library environment to ensure that matching
78 /// new and delete operators are called.
79 /// \param rso The RSO to wrap.
80 /// \param RSOVersion The highest RSOInterface the RSO supports (e.g. 1,2,3).
81 /// \return A pointer to a new GlsRSOWrapper object.
82 static GLS_EXPORT GlsRSOWrapper* CreateInstance( RsoImplBaseInterface* rso, unsigned int RSOVersion );
83
84 /** Destructor
85 * Don't call "delete yourComponent;", instead call "yourComponent->Destroy();"
86 * to ensure that the object is deleted correctly.
87 */
89
90 /** Utility Method: Users should call Destroy() instead.
91 * Safely delete an object that was created using CreateInstance.
92 */
93 virtual GLS_EXPORT void DeleteInstance();
94
95 /** Replace the RSO that the GlsRSOWrapper is wrapping.
96 * \param rso The new RSO to use
97 * \param deleteCurrent Whether to delete the currently referenced rso. If false, then the caller is responsible for deleting it.
98 */
99 GLS_EXPORT void ChangeRSO( RsoImplBaseInterface* rso, bool deleteCurrent = true );
100
101 /// \return The current RSOInterface object.
103
104 /// \return The rso version.
105 unsigned int GetRSOVersion() const
106 {
107 return _rsoVersion;
108 }
109
110 /// Handle an event that was emitted from the RSO.
111 /// \param ev The event to handle.
112 /// \return Non-zero if the event was handled, otherwise zero.
114
115 /// \return The qualified instance name of the initiator of the last
116 /// event that was passed to HandleEmittedEvent or "" if no events
117 /// have been passed to HandleEmittedEvent.
119
120 /// \copydoc DisplayObject::AlphaMode(int)
122 /// \copydoc DisplayObject::AlphaMode()
124 /// \copydoc DisplayObject::AntiAlias(bool)
126 /// \copydoc DisplayObject::AntiAlias()
128 /// \copydoc DisplayObject::SetBlendColor(const GlsColor&)
130 /// \copydoc DisplayObject::GetBlendColor()
132 /// \copydoc DisplayObject::GetColor()
134 /// \copydoc DisplayObject::SetColor(const GlsColor&)
136 /// \copydoc DisplayObject::CullBackFace(const bool)
138 /// \copydoc DisplayObject::CullBackFace()
140 /// \copydoc DisplayObject::DepthTest()
142 /// \copydoc DisplayObject::DepthTest(unsigned char)
143 GLS_EXPORT void DepthTest( unsigned char zbuf ) DISTI_METHOD_OVERRIDE;
144 /// \copydoc DisplayObject::LightingEnabled()
146 /// \copydoc DisplayObject::LightingEnabled(bool)
148 /// \copydoc DisplayObject::LineStippleMultiplier()
150 /// \copydoc DisplayObject::LineStippleMultiplier(int)
152 /// \copydoc DisplayObject::LineStipplePattern()
154 /// \copydoc DisplayObject::LineStipplePattern(int)
156 /// \copydoc DisplayObject::LineWidth()
158 /// \copydoc DisplayObject::LineWidth(float)
160 /// \copydoc DisplayObject::MaterialIndex()
162 /// \copydoc DisplayObject::MaterialIndex(int)
164 /// \copydoc DisplayObject::PolygonMode()
166 /// \copydoc DisplayObject::PolygonMode(int)
168 /// \copydoc DisplayObject::PolygonEnd()
170 /// \copydoc DisplayObject::PolygonEnd(const int)
172 /// \copydoc DisplayObject::Shading()
174 /// \copydoc DisplayObject::Shading(const int)
175 GLS_EXPORT void Shading( const int shading ) DISTI_METHOD_OVERRIDE;
176 /// \copydoc DisplayObject::TextureIndex()
178 /// \copydoc DisplayObject::TextureIndex(int)
180 /// \copydoc DisplayObject::TextureRepeat()
182 /// \copydoc DisplayObject::TextureRepeat(const int)
184 /// \copydoc DisplayObject::TextureMappingTechnique()
186 /// \copydoc DisplayObject::TextureMappingTechnique(const int)
188 /// \copydoc DisplayObject::TextureMagnificationFilter()
190 /// \copydoc DisplayObject::TextureMagnificationFilter(const int)
192 /// \copydoc DisplayObject::TextureMinificationFilter()
194 /// \copydoc DisplayObject::TextureMinificationFilter(const int)
196
197 /// \copydoc ComponentBase::AbsolutePlacement(bool)
199
200 /// \copydoc DisplayObject::Calculate
202 /// \copydoc Group::CalculateBoundingBox
204 /// \copydoc DisplayObject::CloneObject
206 /// \copydoc DisplayObject::CopyGeometry
208 /// \copydoc DisplayObject::CopyProperties
210
211#ifndef GLES
212 /// \copydoc DisplayObject::GetCppInterfaceDescription
214 /// \copydoc DisplayObject::GetCppInterfaceDescriptionFree
216#endif
217 /// \copydoc ComponentBase::CreateObjects
219
220 /// \copydoc DisplayObject::Draw
222
223 /// \copydoc DisplayObject::GetExtents
224 GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
225
226 /// \copydoc DisplayObject::GetTransformedExtents
227 GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true ) DISTI_METHOD_OVERRIDE;
228
229 /// \copydoc DisplayObject::handle
231
232 /// \copydoc ComponentBase::HandleInput
234
235 /// \copydoc ComponentBase::Init
237
238 /// \copydoc ComponentBase::Initialize
240
241 /// \copydoc DisplayObject::Pick3D
243 const Vector& logicalCoords,
244 float scale,
245 const Vector& directionVector,
246 Vector& collisionWinLoc /*Returned*/,
247 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
248
249 /// \copydoc DisplayObject::PreDraw
251
252 /// \copydoc DisplayObject::GetResources
253 GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL ) DISTI_METHOD_OVERRIDE;
254
255 /// \copydoc DisplayObject::Resource
257
258 /* Unhides base class implementation. */
259 using ComponentBase::Rotate;
260 using ComponentBase::Scale;
261
262 /// \copydoc DisplayObject::UpdateBoundingVolume
264
265 /// \copydoc DisplayObject::SetValue
266 GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
267
268 /// Invalidates the painter set on this object if that painter exists.
270 /// \copydoc DisplayObject::SetPainter
272
273protected:
274 /** enum that guides the state machine for multitouch handling for RSO's that don't support multitouch.
275 * An RSO starts in the READY_FOR_INPUT state. When it handles a mouse drag event, it moves to PROCESSING_MOUSE_DRAG
276 * state. It will ignore any other mouse events if they are not for the original cursor_id. Then, once the RSO either receives the
277 * 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
278 * 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
279 */
281 {
282 READY_FOR_INPUT,
283 PROCESSING_MOUSE_DRAG,
284 WAITING_FOR_MOUSE_DOWN
285 };
286
287 RsoImplBaseInterface* _rsoInterface; ///< The RSO being wrapped by this interface.
288 AttributeWrapperMap* _attributeWrapperMap; ///< A map of attributes that wrap to the attributes within the RSO.
289 EmittedEventHandlerImpl* _rsoEmittedEventHandler; ///< The event handler for the RSO.
290 char* _lastEmittedEventInitiatorName; ///< The name of the last object who emitted an event that made it to the event handler.
291 MultitouchState _multitouchState; ///< The current multitouch input state, \see MultitouchState
292 unsigned int _currentCursor; ///< The cursor id of the current mouse / touch interacting with the RSO.
293 unsigned int _rsoVersion; ///< The interface version of the wrapped RSO.
294
295 /// Set the name of the object who most recently emitted an event that was handled by the event handler.
296 /// \note Not normally called by users.
297 /// \param name The new object name to set.
299
300 /// This function should be called to handle mouse events if the RSO handles multitouch (RSO version 3 or greater).
301 /// \note Not normally called by users.
302 /// \param mev The event to handle.
303 /// \return A pointer to the object that received the event, or NULL.
305};
306
307} // namespace disti
308
309#endif
Definition: component_base.h:67
bool AbsolutePlacement() const
Definition: component_base.h:123
Definition: cull.h:49
Definition: events.h:111
Definition: display.h:95
Definition: disti_metadata.h:220
Definition: dynamic_array.h:79
Definition: gls_color.h:53
Definition: gls_painter.h:50
Definition: gls_rso_wrapper.h:65
int DepthTest() override
bool CullBackFace() override
const char * LastEmittedEventInitiatorName() const
void SetPainter(GlsPainter *painter) override
int PolygonEnd() override
void PreDraw(const OpenGLMatrices &current, Culler &culler) override
unsigned int _currentCursor
The cursor id of the current mouse / touch interacting with the RSO.
Definition: gls_rso_wrapper.h:292
void Initialize() override
DisplayObject * HandleInput(DisplayEvent *ev) override
float LineWidth() override
void CopyProperties(DisplayObject *src) override
bool TextureRepeat() override
int Shading() override
void Invalidate() override
Invalidates the painter set on this object if that painter exists.
virtual void DeleteInstance()
int LineStippleMultiplier() override
void LastEmittedEventInitiatorName(const char *name)
int PolygonMode() override
void AlphaMode(int mode) override
void Init() override
void CopyGeometry(DisplayObject *src) override
int TextureIndex() override
DistiAttributeBase & Resource(const char *name) override
void SetValue(int spec, va_list &args) override
bool LightingEnabled() override
AttributeWrapperMap * _attributeWrapperMap
A map of attributes that wrap to the attributes within the RSO.
Definition: gls_rso_wrapper.h:288
unsigned int _rsoVersion
The interface version of the wrapped RSO.
Definition: gls_rso_wrapper.h:293
void CreateObjects() override
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) override
MultitouchState
Definition: gls_rso_wrapper.h:281
unsigned int GetRSOVersion() const
Definition: gls_rso_wrapper.h:105
RsoImplBaseInterface * _rsoInterface
The RSO being wrapped by this interface.
Definition: gls_rso_wrapper.h:287
int TextureMinificationFilter() override
int LineStipplePattern() override
void Calculate(double time) override
void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true) override
DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) override
void UpdateBoundingVolume() override
DisplayObject * CloneObject(bool generateNames=false) override
EmittedEventHandlerImpl * _rsoEmittedEventHandler
The event handler for the RSO.
Definition: gls_rso_wrapper.h:289
DisplayObject * handle(DisplayEvent *ev) override
virtual float Scale()
Definition: display_frame.h:133
void GetResources(std::ostream &outstr, GlsResourceFilter *filter=NULL) override
int TextureMappingTechnique() override
RsoImplBaseInterface * RSOInterface()
MultitouchState _multitouchState
The current multitouch input state,.
Definition: gls_rso_wrapper.h:291
void GetCppInterfaceDescriptionFree(InterfaceListType *array) override
void Rotate(const Vector &orig, float angle, const Vector &axis) override
char * _lastEmittedEventInitiatorName
The name of the last object who emitted an event that made it to the event handler.
Definition: gls_rso_wrapper.h:290
void SetBlendColor(const GlsColor &color) override
int HandleEmittedEvent(RsoImplBaseInterface::Event *ev)
int TextureMagnificationFilter() override
void CalculateBoundingBox() override
int AlphaMode() override
int MaterialIndex() override
void ChangeRSO(RsoImplBaseInterface *rso, bool deleteCurrent=true)
GlsColor GetBlendColor() override
virtual DisplayObject * HandleMultiTouchInput(MouseEvent *mev)
bool AntiAlias() override
void SetColor(const GlsColor &color) override
void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) override
GlsColor GetColor() override
void Draw() override
Definition: gls_resources.h:49
Definition: group.h:52
static DisplayObject * CreateInstance()
Definition: events.h:223
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: rso_interface_1.h:321
Definition: rso_interface_1.h:60
Definition: rso_interface_5.h:65
Definition: vertex.h:84
The disti::ComponentBase class.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
disti::RSOInterface5::RSOPainter RSOPainterT
Typedef for the RSO interface painter type.
Definition: gls_rso_wrapper.h:51
disti::RSOInterface1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: gls_rso_wrapper.h:50
Definition: bmpimage.h:46
DistiAttribDict::const_iterator end(const DistiAttribDict &dict)
Definition: disti_metadata.h:975
Defines the RSO interface v5, which extends v4 to add conditional rendering support.