GL Studio C++ Runtime API
gls_rso_interface_impl.h
Go to the documentation of this file.
1/// \file gls_rso_interface_impl.h
2/// \brief Standard GL Studio implementation of the safe interface to version 2 RSOs (component side).
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 INCLUDED_GLS_RSO_INTERFACE_IMPL_H
40#define INCLUDED_GLS_RSO_INTERFACE_IMPL_H
41
42#include "events.h"
43#include "gls_include.h"
44#include "gls_resources.h"
45#ifdef GLES
46# include "rso_interface_es_2.h"
47typedef disti::RSOInterfaceES2 RsoImplBaseClass; ///< Typedef for the current RSO interface.
48typedef disti::RSOInterfaceES1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
49typedef disti::RSOInterfaceES1 RsoImplMultiTouchInterface; ///< Typedef for the RSO interface version that introduced multitouch support.
50typedef disti::RSOInterfaceES1::MatrixF RSOMatrixT; ///< Typedef for the RSO interface matrix type.
51typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
52#else
53# include "rso_interface_5.h"
54typedef disti::RSOInterface5 RsoImplBaseClass; ///< Typedef for the current RSO interface.
55typedef disti::RSOInterface1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
56typedef disti::RSOInterface3 RsoImplMultiTouchInterface; ///< Typedef for the RSO interface version that introduced multitouch support.
57typedef disti::RSOInterface1::MatrixD RSOMatrixT; ///< Typedef for the RSO interface matrix type.
58typedef disti::RSOInterface5::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
59#endif
60
61namespace disti
62{
63class ComponentBase;
64
65/** Wraps a GlsResourceFilter so it can be passed to the RSO Interface's GetResources call */
67{
68private:
69 GlsResourceFilter* _filter; ///< The underlying (runtime) filter wrapped by this interface.
70
71public:
72 /// Constructor
73 /// \param filter The filter to wrap.
74 GLS_EDITOR RSOResourceFilterImpl( GlsResourceFilter* filter ) { _filter = filter; }
75
77
78 /// \return The current qualification level.
79 int LevelsUp() const DISTI_METHOD_OVERRIDE { return _filter->LevelsUp(); }
80
81 /// How many levels of qualification to show in the name.
82 /// -1 means full qualification.
83 /// Default: -1
84 /// \param value The new qualification level to set.
85 void LevelsUp( int value ) DISTI_METHOD_OVERRIDE { _filter->LevelsUp( value ); }
86
87 /// \return The current levels of children to show.
88 int GroupLevelsDown() const DISTI_METHOD_OVERRIDE { return _filter->GroupLevelsDown(); }
89
90 /// How many levels of children to show.
91 /// 0 means don't show any children properties
92 /// -1 means all the way down.
93 /// Default: -1
94 /// \param value The new levels of children to show.
95 void GroupLevelsDown( int value ) DISTI_METHOD_OVERRIDE { _filter->GroupLevelsDown( value ); }
96
97 /// \return Whether or not names, or names and values should be returned.
98 bool NamesOnly() const DISTI_METHOD_OVERRIDE { return _filter->NamesOnly(); }
99
100 /// If true, only a list of names will be returned.
101 /// Values will not be returned.
102 /// The format changes to not include the ":".
103 /// Default: false
104 /// \param value The new name display flag to set.
105 void NamesOnly( bool value ) DISTI_METHOD_OVERRIDE { _filter->NamesOnly( value ); }
106
107 /// Manage the list of excluded attributes. Takes precedence over includes.
108 /// \param str The new name to add to the exclude list.
109 void AddExclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddExclude( str ); }
110
111 /// Default: 0
112 /// \return The number of entries in the exclude list.
113 int ExcludeCount() const DISTI_METHOD_OVERRIDE { return _filter->ExcludeCount(); }
114
115 /// \note Returns NULL if index >= ExcludeCount() or index < -1.
116 /// \return The exclude name associated with the incoming index.
117 /// \param index The index of the exclusion item to return.
118 const char* GetExclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetExclude( index ); }
119
120 /// Manage the list of included attributes.
121 /// \param str The new name to add to the include list.
122 void AddInclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddInclude( str ); }
123
124 /// Default: 0
125 /// \return The number of entries in the include list.
126 int IncludeCount() const DISTI_METHOD_OVERRIDE { return _filter->IncludeCount(); }
127
128 /// \note Returns NULL if index >= IncludeCount() or index < -1
129 /// \return The include name associated with the incoming index.
130 /// \param index The index of the inclusion item to return.
131 const char* GetInclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetInclude( index ); }
132
133 /// Check a name against the filters.
134 /// Exclude list takes precedence.
135 /// \param name The name of the item to test.
136 /// \return Whether or not the name passes the filter (to be included in the returned results).
137 bool PassFilter( const char* name ) const DISTI_METHOD_OVERRIDE { return _filter->PassFilter( name ); }
138
139 /// Manage the stack of parent object names.
140 /// \param parent The name of the item to add to the stack.
141 void PushParentName( const char* parent ) { _filter->PushParentName( parent ); }
142
143 /// Pop the parent object name stack.
144 void PopParentName() { _filter->PopParentName(); }
145
146 /// \return The number of entries in the parent name stack.
147 unsigned int ParentNameCount() const { return _filter->ParentNameCount(); }
148
149 /// \note Returns NULL if index >= ParentNameCount() or index < -1.
150 /// \return The parent name associated with the incoming index.
151 /// \param index The index of the parent name to return.
152 const char* GetParentName( unsigned int index ) const { return _filter->GetParentName( index ); }
153};
154
155/** Implementation of RSOInterface. */
157 , virtual public GlsPainter
158{
159protected:
160 /// Reference to the component being wrapped.
161 /// GlsRSOInterface1Impl will delete this object.
163
164 /// The container's event handler.
166
167 /// String to return from Resources methods.
168 std::string _resourcesRetVal;
169
170 // RSOInterface2 implementation
171
172 typedef std::map<ResourceHandle, DistiAttributeBase*> ResourceHandleMap; ///< Typedef to associate external ids (ResourceHandle) with runtime attributes.
173
174 ResourceHandleMap _resourceHandleMap; ///< Mapping of external RSO interface resource ids with runtime attributes.
175 ResourceHandle _nextResourceHandle; ///< Used to track the highest id, to assign as the next resource handle.
176 bool _firstDraw; ///< If true, this RSO has not been drawn yet.
177
178 RSOPainterT* _painter; ///< Painter object that tracks the conditional rendering state.
179 bool _redraw; ///< If true, this RSO should redraw itself on the next frame.
180
181 /// \return The runtime attribute associated with the external handle.
182 /// \param handle The external id for the desired runtime attribute.
184
185 /// Protected constructor - Call CreateInstance instead
186 /// \param component The component object to wrap.
188
189 // Protected destructor - Call DeleteInstance instead
191
192public:
193 /// \return An RSO interface wrapper for the incoming component object.
194 /// \param component The component object to wrap.
196
197 /// Pass an event that was emitted from the component to the container.
198 /// \param ev The event to pass into the container.
199 /// \return Zero if the event was not handled, otherwise not zero.
201
202 /// \copydoc RSOInterface1::Calculate
204 /// \copydoc RSOInterface1::CloneObject
206 /// \copydoc RSOInterface1::DeleteInstance
208 /// \copydoc RSOInterface1::Draw
210 /// \copydoc RSOInterface1::SetEmittedEventHandler
212 /// \copydoc RSOInterface1::GetBoundingSphere
214 /// \copydoc RSOInterface1::GetBoundingBox
216 /// \copydoc RSOInterface1::HandleInput
218 /// \copydoc RSOInterface3::HandleMultiTouchInput
220
221 /// \copydoc RSOInterface1::Pick3D
223 const RsoImplBaseInterface::Vector& logicalCoords,
224 float scale,
225 const RsoImplBaseInterface::Vector& directionVector,
226 RsoImplBaseInterface::Vector& collisionWinLoc,
228
229 /// \copydoc RSOInterface1::PreDraw
231 /// \copydoc RSOInterface1::SetResource
232 GLS_EXPORT void SetResource( const char* resourceName, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
233 /// \copydoc RSOInterface1::GetResource
234 GLS_EXPORT const char* GetResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
235 /// \copydoc RSOInterface1::GetResources
237
238 /// \copydoc RSOInterface2::CreateResourceHandle
240 /// \copydoc RSOInterface2::ReleaseResourceHandle
242 /// \copydoc RSOInterface2::IsResourceHandleValid
244 /// \copydoc RSOInterface2::SetResource
245 void SetResource( ResourceHandle resourceHandle, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
246 /// \copydoc RSOInterface2::GetResource
247 const char* GetResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
248 /// \copydoc RSOInterface2::SetIntResource(const char*, long)
249 void SetIntResource( const char* resourceName, long resourceVal ) DISTI_METHOD_OVERRIDE;
250 /// \copydoc RSOInterface2::GetIntResource(const char*)
251 long GetIntResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
252 /// \copydoc RSOInterface2::SetIntResource(ResourceHandle, long)
253 void SetIntResource( ResourceHandle handle, long resourceVal ) DISTI_METHOD_OVERRIDE;
254 /// \copydoc RSOInterface2::GetIntResource(ResourceHandle)
256 /// \copydoc RSOInterface2::SetFloatResource(const char*, double)
257 void SetFloatResource( const char* resourceName, double resourceVal ) DISTI_METHOD_OVERRIDE;
258 /// \copydoc RSOInterface2::GetFloatResource(const char*)
259 double GetFloatResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
260 /// \copydoc RSOInterface2::SetFloatResource(ResourceHandle, double)
261 void SetFloatResource( ResourceHandle handle, double resourceVal ) DISTI_METHOD_OVERRIDE;
262 /// \copydoc RSOInterface2::GetFloatResource(ResourceHandle)
264 /// \copydoc RSOInterface4::RegisterResourceObserver
266 /// \copydoc RSOInterface4::UnregisterResourceObserver
268
269#ifdef GLES
270 /// \return The maximum number of possible lights this platform supports.
271 unsigned int GetMaxNumLights() DISTI_METHOD_OVERRIDE;
272
273 /// Updates the state manager to set various light parameters.
274 /// \param numLights The number of lights within the lightData.
275 /// \param lightData An array of data where each element contains a collection of light properties.
276 void SetLightData( unsigned int numLights, LightData* lightData ) DISTI_METHOD_OVERRIDE;
277
278 /// \return The maximum number of clip planes supported by the current driver.
279 unsigned int GetMaxClipPlanes() DISTI_METHOD_OVERRIDE;
280
281 /// Activates and updates the clip planes in the state manager.
282 /// \param[in] numClipPlanes Determines how many planes are defined in the equations array.
283 /// \param[in] equations An array of floats that define each plane where each equation is defined by four floats. equations[numClipPlanes][4].
284 void SetClipPlaneData( unsigned int numClipPlanes, float** equations ) DISTI_METHOD_OVERRIDE;
285
286 /// Updates the state manager's top matrix based on the type.
287 /// \param[in] type If it's equal to RSO_MODELVIEW_MATRIX, it'll load the model view matrix. If it's RSO_PROJECTION_MATRIX, then it'll retrieve the ProjectionMatrix instead.
288 /// \param[in] matrix The matrix to push to the top of the stack.
289 void SetMatrix( int type, const float* matrix ) DISTI_METHOD_OVERRIDE;
290
291 /// Restores the state manager back to its default state.
292 void SetDefaultOpenGLState() DISTI_METHOD_OVERRIDE;
293#endif
294
295 /// \copydoc RSOInterface5::RSOPainter::Invalidate
297
298 /// \copydoc GlsPainter::IsInvalidated
300
301 /// \copydoc RSOInterface5::SetPainter
303};
304
305} // end namespace disti
306
307#endif
Definition: component_base.h:67
Definition: events.h:111
Definition: disti_metadata.h:220
Definition: gls_painter.h:50
Definition: gls_rso_interface_impl.h:158
static GlsRSOInterfaceImpl * CreateInstance(ComponentBase *component)
DistiAttributeBase & GetAttribute(ResourceHandle handle)
void UnregisterResourceObserver(ResourceHandle resourceHandle, CallbackID id) override
bool GetBoundingSphere(RsoImplBaseInterface::Vector *center, float *radius) override
ResourceHandleMap _resourceHandleMap
Mapping of external RSO interface resource ids with runtime attributes.
Definition: gls_rso_interface_impl.h:174
void SetPainter(RSOPainterT *painter) override
bool GetBoundingBox(RsoImplBaseInterface::Vector *min, RsoImplBaseInterface::Vector *max, const RSOMatrixT *transform=NULL) override
bool HandleInput(RsoImplBaseInterface::Event *ev) override
RsoImplBaseInterface::EmittedEventHandler * _emittedEventHandler
The container's event handler.
Definition: gls_rso_interface_impl.h:165
RSOPainterT * _painter
Painter object that tracks the conditional rendering state.
Definition: gls_rso_interface_impl.h:178
void Invalidate() override
bool IsInvalidated() const override
void SetIntResource(const char *resourceName, long resourceVal) override
bool _redraw
If true, this RSO should redraw itself on the next frame.
Definition: gls_rso_interface_impl.h:179
bool Pick3D(const RsoImplBaseInterface::Vector &winLoc, const RsoImplBaseInterface::Vector &logicalCoords, float scale, const RsoImplBaseInterface::Vector &directionVector, RsoImplBaseInterface::Vector &collisionWinLoc, const RsoImplBaseInterface::OpenGLMatrices &drawnMatrices) override
ResourceHandle CreateResourceHandle(const char *resourceName) override
std::map< ResourceHandle, DistiAttributeBase * > ResourceHandleMap
Typedef to associate external ids (ResourceHandle) with runtime attributes.
Definition: gls_rso_interface_impl.h:172
bool _firstDraw
If true, this RSO has not been drawn yet.
Definition: gls_rso_interface_impl.h:176
GlsRSOInterfaceImpl(ComponentBase *component)
double GetFloatResource(const char *resourceName) override
bool HandleMultiTouchInput(RsoImplMultiTouchInterface::MouseMultiTouchEvent *ev) override
bool SetEmittedEventHandler(RsoImplBaseInterface::EmittedEventHandler *handler) override
const char * GetResource(const char *resourceName) override
void SetResource(const char *resourceName, const char *resourceVal) override
void DeleteInstance() override
Safely delete the object.
void Calculate(double time) override
The RSO Interface methods.
bool IsResourceHandleValid(ResourceHandle resourceHandle) override
void ReleaseResourceHandle(ResourceHandle resourceHandle) override
const char * GetResources(RsoImplBaseInterface::ResourceFilter *filter=NULL) override
void SetFloatResource(const char *resourceName, double resourceVal) override
long GetIntResource(const char *resourceName) override
ResourceHandle _nextResourceHandle
Used to track the highest id, to assign as the next resource handle.
Definition: gls_rso_interface_impl.h:175
CallbackID RegisterResourceObserver(ResourceHandle resourceHandle, ResourceObserver *observer) override
std::string _resourcesRetVal
String to return from Resources methods.
Definition: gls_rso_interface_impl.h:168
RsoImplBaseInterface * CloneObject() override
ComponentBase * _component
Definition: gls_rso_interface_impl.h:162
int LiveComponentEventHandlerCb(ComponentBase *, disti::DisplayEvent *ev)
void PreDraw(const RsoImplBaseInterface::OpenGLMatrices &current, RsoImplBaseInterface::Culler &culler) override
Definition: gls_resources.h:49
void LevelsUp(int value)
Definition: gls_resources.h:82
unsigned int IncludeCount() const
void PopParentName()
Removes the top entry on the parent name stack.
const char * GetInclude(unsigned int index) const
void PushParentName(const char *parent)
unsigned int ExcludeCount() const
const char * GetExclude(unsigned int index) const
void NamesOnly(bool value)
Definition: gls_resources.h:110
void AddInclude(const char *name)
unsigned int ParentNameCount() const
virtual bool PassFilter(const char *name)
const char * GetParentName(unsigned int index) const
void AddExclude(const char *name)
void GroupLevelsDown(int value)
Definition: gls_resources.h:101
Definition: rso_interface_1.h:309
Definition: rso_interface_1.h:635
Definition: rso_interface_1.h:321
Definition: rso_interface_1.h:209
Definition: rso_interface_1.h:242
Definition: rso_interface_1.h:649
Definition: rso_interface_1.h:174
Definition: rso_interface_1.h:60
unsigned int ResourceHandle
Typedef for a unique resource identifier.
Definition: rso_interface_2.h:64
Definition: rso_interface_3.h:64
Definition: rso_interface_3.h:60
Definition: rso_interface_4.h:63
unsigned int CallbackID
Type for unique identifiers.
Definition: rso_interface_4.h:78
Definition: rso_interface_5.h:65
Definition: rso_interface_5.h:61
Definition: gls_rso_interface_impl.h:67
const char * GetInclude(int index) const override
Definition: gls_rso_interface_impl.h:131
void PopParentName()
Pop the parent object name stack.
Definition: gls_rso_interface_impl.h:144
int ExcludeCount() const override
Definition: gls_rso_interface_impl.h:113
const char * GetExclude(int index) const override
Definition: gls_rso_interface_impl.h:118
bool NamesOnly() const override
Definition: gls_rso_interface_impl.h:98
void PushParentName(const char *parent)
Definition: gls_rso_interface_impl.h:141
void GroupLevelsDown(int value) override
Definition: gls_rso_interface_impl.h:95
RSOResourceFilterImpl(GlsResourceFilter *filter)
Definition: gls_rso_interface_impl.h:74
void LevelsUp(int value) override
Definition: gls_rso_interface_impl.h:85
void AddExclude(const char *str) override
Definition: gls_rso_interface_impl.h:109
bool PassFilter(const char *name) const override
Definition: gls_rso_interface_impl.h:137
int LevelsUp() const override
Definition: gls_rso_interface_impl.h:79
void AddInclude(const char *str) override
Definition: gls_rso_interface_impl.h:122
unsigned int ParentNameCount() const
Definition: gls_rso_interface_impl.h:147
int GroupLevelsDown() const override
Definition: gls_rso_interface_impl.h:88
int IncludeCount() const override
Definition: gls_rso_interface_impl.h:126
const char * GetParentName(unsigned int index) const
Definition: gls_rso_interface_impl.h:152
void NamesOnly(bool value) override
Definition: gls_rso_interface_impl.h:105
The standard Mouse and keyboard events and event structures.
#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
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
#define GLS_EDITOR
Macro denoting which functions should be visible from the editor.
Definition: gls_include.h:61
disti::GlsResourceFilter classes and methods.
disti::RSOInterface3 RsoImplMultiTouchInterface
Typedef for the RSO interface version that introduced multitouch support.
Definition: gls_rso_interface_impl.h:56
disti::RSOInterface5::RSOPainter RSOPainterT
Typedef for the RSO interface painter type.
Definition: gls_rso_interface_impl.h:58
disti::RSOInterface1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: gls_rso_interface_impl.h:55
disti::RSOInterface1::MatrixD RSOMatrixT
Typedef for the RSO interface matrix type.
Definition: gls_rso_interface_impl.h:57
disti::RSOInterface5 RsoImplBaseClass
Typedef for the current RSO interface.
Definition: gls_rso_interface_impl.h:54
Definition: bmpimage.h:46
Defines the RSO interface v5, which extends v4 to add conditional rendering support.