GL Studio C++ Runtime API
gls_rso_interface_impl.h
Go to the documentation of this file.
1/*! \file
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 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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40#ifndef INCLUDED_GLS_RSO_INTERFACE_IMPL_H
41#define INCLUDED_GLS_RSO_INTERFACE_IMPL_H
42
43#include "events.h"
44#include "gls_include.h"
45#include "gls_resources.h"
46#ifdef GLES
47# include "rso_interface_es_2.h"
48typedef disti::RSOInterfaceES2 RsoImplBaseClass; ///< Typedef for the current RSO interface.
49typedef disti::RSOInterfaceES1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
50typedef disti::RSOInterfaceES1 RsoImplMultiTouchInterface; ///< Typedef for the RSO interface version that introduced multitouch support.
51typedef disti::RSOInterfaceES1::MatrixF RSOMatrixT; ///< Typedef for the RSO interface matrix type.
52typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
53#else
54# include "rso_interface_5.h"
55typedef disti::RSOInterface5 RsoImplBaseClass; ///< Typedef for the current RSO interface.
56typedef disti::RSOInterface1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
57typedef disti::RSOInterface3 RsoImplMultiTouchInterface; ///< Typedef for the RSO interface version that introduced multitouch support.
58typedef disti::RSOInterface1::MatrixD RSOMatrixT; ///< Typedef for the RSO interface matrix type.
59typedef disti::RSOInterface5::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
60#endif
61
62namespace disti
63{
64class ComponentBase;
65
66/** Wraps a GlsResourceFilter so it can be passed to the RSO Interface's GetResources call */
67class RSOResourceFilterImpl : public RsoImplBaseInterface::ResourceFilter
68{
69private:
70 GlsResourceFilter* _filter; ///< The underlying (runtime) filter wrapped by this interface.
71
72public:
73 /// Constructor
74 /// \param filter The filter to wrap.
75 GLS_EDITOR RSOResourceFilterImpl( GlsResourceFilter* filter ) { _filter = filter; }
76
78
79 /// \return The current qualification level.
80 int LevelsUp() const DISTI_METHOD_OVERRIDE { return _filter->LevelsUp(); }
81
82 /// How many levels of qualification to show in the name.
83 /// -1 means full qualification.
84 /// Default: -1
85 /// \param value The new qualification level to set.
86 void LevelsUp( int value ) DISTI_METHOD_OVERRIDE { _filter->LevelsUp( value ); }
87
88 /// \return The current levels of children to show.
89 int GroupLevelsDown() const DISTI_METHOD_OVERRIDE { return _filter->GroupLevelsDown(); }
90
91 /// How many levels of children to show.
92 /// 0 means don't show any children properties
93 /// -1 means all the way down.
94 /// Default: -1
95 /// \param value The new levels of children to show.
96 void GroupLevelsDown( int value ) DISTI_METHOD_OVERRIDE { _filter->GroupLevelsDown( value ); }
97
98 /// \return Whether or not names, or names and values should be returned.
99 bool NamesOnly() const DISTI_METHOD_OVERRIDE { return _filter->NamesOnly(); }
100
101 /// If true, only a list of names will be returned.
102 /// Values will not be returned.
103 /// The format changes to not include the ":".
104 /// Default: false
105 /// \param value The new name display flag to set.
106 void NamesOnly( bool value ) DISTI_METHOD_OVERRIDE { _filter->NamesOnly( value ); }
107
108 /// Manage the list of excluded attributes. Takes precedence over includes.
109 /// \param str The new name to add to the exclude list.
110 void AddExclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddExclude( str ); }
111
112 /// Default: 0
113 /// \return The number of entries in the exclude list.
114 int ExcludeCount() const DISTI_METHOD_OVERRIDE { return _filter->ExcludeCount(); }
115
116 /// \note Returns NULL if index >= ExcludeCount() or index < -1.
117 /// \return The exclude name associated with the incoming index.
118 /// \param index The index of the exclusion item to return.
119 const char* GetExclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetExclude( index ); }
120
121 /// Manage the list of included attributes.
122 /// \param str The new name to add to the include list.
123 void AddInclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddInclude( str ); }
124
125 /// Default: 0
126 /// \return The number of entries in the include list.
127 int IncludeCount() const DISTI_METHOD_OVERRIDE { return _filter->IncludeCount(); }
128
129 /// \note Returns NULL if index >= IncludeCount() or index < -1
130 /// \return The include name associated with the incoming index.
131 /// \param index The index of the inclusion item to return.
132 const char* GetInclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetInclude( index ); }
133
134 /// Check a name against the filters.
135 /// Exclude list takes precedence.
136 /// \param name The name of the item to test.
137 /// \return Whether or not the name passes the filter (to be included in the returned results).
138 bool PassFilter( const char* name ) const DISTI_METHOD_OVERRIDE { return _filter->PassFilter( name ); }
139
140 /// Manage the stack of parent object names.
141 /// \param parent The name of the item to add to the stack.
142 void PushParentName( const char* parent ) { _filter->PushParentName( parent ); }
143
144 /// Pop the parent object name stack.
145 void PopParentName() { _filter->PopParentName(); }
146
147 /// \return The number of entries in the parent name stack.
148 unsigned int ParentNameCount() const { return _filter->ParentNameCount(); }
149
150 /// \note Returns NULL if index >= ParentNameCount() or index < -1.
151 /// \return The parent name associated with the incoming index.
152 /// \param index The index of the parent name to return.
153 const char* GetParentName( unsigned int index ) const { return _filter->GetParentName( index ); }
154};
155
156/** Implementation of RSOInterface. */
158 , virtual public GlsPainter
159{
160protected:
161 /// Reference to the component being wrapped.
162 /// GlsRSOInterface1Impl will delete this object.
164
165 /// The container's event handler.
166 RsoImplBaseInterface::EmittedEventHandler* _emittedEventHandler;
167
168 /// String to return from Resources methods.
169 std::string _resourcesRetVal;
170
171 // RSOInterface2 implementation
172
173 typedef std::map<ResourceHandle, DistiAttributeBase*> ResourceHandleMap; ///< Typedef to associate external ids (ResourceHandle) with runtime attributes.
174
175 ResourceHandleMap _resourceHandleMap; ///< Mapping of external RSO interface resource ids with runtime attributes.
176 ResourceHandle _nextResourceHandle; ///< Used to track the highest id, to assign as the next resource handle.
177 bool _firstDraw; ///< If true, this RSO has not been drawn yet.
178
179 RSOPainterT* _painter; ///< Painter object that tracks the conditional rendering state.
180 bool _redraw; ///< If true, this RSO should redraw itself on the next frame.
181
182 /// \return The runtime attribute associated with the external handle.
183 /// \param handle The external id for the desired runtime attribute.
184 DistiAttributeBase& GetAttribute( ResourceHandle handle );
185
186 /// Protected constructor - Call CreateInstance instead
187 /// \param component The component object to wrap.
189
190 // Protected destructor - Call DeleteInstance instead
192
193public:
194 /// \return An RSO interface wrapper for the incoming component object.
195 /// \param component The component object to wrap.
197
198 /// Pass an event that was emitted from the component to the container.
199 /// \param ev The event to pass into the container.
200 /// \return Zero if the event was not handled, otherwise not zero.
202
203 /// \copydoc RSOInterface1::Calculate
205 /// \copydoc RSOInterface1::CloneObject
207 /// \copydoc RSOInterface1::DeleteInstance
209 /// \copydoc RSOInterface1::Draw
211 /// \copydoc RSOInterface1::SetEmittedEventHandler
213 /// \copydoc RSOInterface1::GetBoundingSphere
215 /// \copydoc RSOInterface1::GetBoundingBox
217 /// \copydoc RSOInterface1::HandleInput
219 /// \copydoc RSOInterface3::HandleMultiTouchInput
221
222 /// \copydoc RSOInterface1::Pick3D
224 const RsoImplBaseInterface::Vector& logicalCoords,
225 float scale,
226 const RsoImplBaseInterface::Vector& directionVector,
227 RsoImplBaseInterface::Vector& collisionWinLoc,
229
230 /// \copydoc RSOInterface1::PreDraw
232 /// \copydoc RSOInterface1::SetResource
233 GLS_EXPORT void SetResource( const char* resourceName, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
234 /// \copydoc RSOInterface1::GetResource
235 GLS_EXPORT const char* GetResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
236 /// \copydoc RSOInterface1::GetResources
237 GLS_EXPORT const char* GetResources( RsoImplBaseInterface::ResourceFilter* filter = NULL ) DISTI_METHOD_OVERRIDE;
238
239 /// \copydoc RSOInterface2::CreateResourceHandle
240 ResourceHandle CreateResourceHandle( const char* resourceName ) DISTI_METHOD_OVERRIDE;
241 /// \copydoc RSOInterface2::ReleaseResourceHandle
242 void ReleaseResourceHandle( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
243 /// \copydoc RSOInterface2::IsResourceHandleValid
244 bool IsResourceHandleValid( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
245 /// \copydoc RSOInterface2::SetResource
246 void SetResource( ResourceHandle resourceHandle, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
247 /// \copydoc RSOInterface2::GetResource
248 const char* GetResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
249 /// \copydoc RSOInterface2::SetIntResource(const char*, long)
250 void SetIntResource( const char* resourceName, long resourceVal ) DISTI_METHOD_OVERRIDE;
251 /// \copydoc RSOInterface2::GetIntResource(const char*)
252 long GetIntResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
253 /// \copydoc RSOInterface2::SetIntResource(ResourceHandle, long)
254 void SetIntResource( ResourceHandle handle, long resourceVal ) DISTI_METHOD_OVERRIDE;
255 /// \copydoc RSOInterface2::GetIntResource(ResourceHandle)
256 long GetIntResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
257 /// \copydoc RSOInterface2::SetFloatResource(const char*, double)
258 void SetFloatResource( const char* resourceName, double resourceVal ) DISTI_METHOD_OVERRIDE;
259 /// \copydoc RSOInterface2::GetFloatResource(const char*)
260 double GetFloatResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
261 /// \copydoc RSOInterface2::SetFloatResource(ResourceHandle, double)
262 void SetFloatResource( ResourceHandle handle, double resourceVal ) DISTI_METHOD_OVERRIDE;
263 /// \copydoc RSOInterface2::GetFloatResource(ResourceHandle)
264 double GetFloatResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
265 /// \copydoc RSOInterface4::RegisterResourceObserver
266 CallbackID RegisterResourceObserver( ResourceHandle resourceHandle, ResourceObserver* observer ) DISTI_METHOD_OVERRIDE;
267 /// \copydoc RSOInterface4::UnregisterResourceObserver
268 void UnregisterResourceObserver( ResourceHandle resourceHandle, CallbackID id ) DISTI_METHOD_OVERRIDE;
269
270#ifdef GLES
271 /// \return The maximum number of possible lights this platform supports.
272 unsigned int GetMaxNumLights();
273
274 /// Updates the state manager to set various light parameters.
275 /// \param numLights The number of lights within the lightData.
276 /// \param lightData An array of data where each element contains a collection of light properties.
277 void SetLightData( unsigned int numLights, LightData* lightData );
278
279 /// \return The maximum number of clip planes supported by the current driver.
280 unsigned int GetMaxClipPlanes();
281
282 /// Activates and updates the clip planes in the state manager.
283 /// \param[in] numClipPlanes Determines how many planes are defined in the equations array.
284 /// \param[in] equations An array of floats that define each plane where each equation is defined by four floats. equations[numClipPlanes][4].
285 void SetClipPlaneData( unsigned int numClipPlanes, float** equations );
286
287 /// Updates the state manager's top matrix based on the type.
288 /// \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.
289 /// \param[in] matrix The matrix to push to the top of the stack.
290 void SetMatrix( int type, const float* matrix );
291
292 /// Restores the state manager back to its default state.
294#endif
295
296 /// \copydoc RSOInterface5::RSOPainter::Invalidate
298
299 /// \copydoc GlsPainter::IsInvalidated
301
302 /// \copydoc RSOInterface5::SetPainter
304};
305
306} // end namespace disti
307
308#endif
Definition: component_base.h:68
Definition: cull.h:50
Definition: events.h:113
Definition: disti_metadata.h:220
Definition: gls_painter.h:51
Definition: gls_rso_interface_impl.h:159
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:175
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:166
RSOPainterT * _painter
Painter object that tracks the conditional rendering state.
Definition: gls_rso_interface_impl.h:179
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:180
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:173
bool _firstDraw
If true, this RSO has not been drawn yet.
Definition: gls_rso_interface_impl.h:177
GlsRSOInterfaceImpl(ComponentBase *component)
double GetFloatResource(const char *resourceName) override
bool HandleMultiTouchInput(RsoImplMultiTouchInterface::MouseMultiTouchEvent *ev) override
void SetMatrix(int type, const float *matrix)
bool SetEmittedEventHandler(RsoImplBaseInterface::EmittedEventHandler *handler) override
const char * GetResource(const char *resourceName) override
void SetDefaultOpenGLState()
Restores the state manager back to its default state.
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
unsigned int GetMaxClipPlanes()
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:176
CallbackID RegisterResourceObserver(ResourceHandle resourceHandle, ResourceObserver *observer) override
unsigned int GetMaxNumLights()
void SetClipPlaneData(unsigned int numClipPlanes, float **equations)
std::string _resourcesRetVal
String to return from Resources methods.
Definition: gls_rso_interface_impl.h:169
RsoImplBaseInterface * CloneObject() override
void SetLightData(unsigned int numLights, LightData *lightData)
ComponentBase * _component
Definition: gls_rso_interface_impl.h:163
int LiveComponentEventHandlerCb(ComponentBase *, disti::DisplayEvent *ev)
void PreDraw(const RsoImplBaseInterface::OpenGLMatrices &current, RsoImplBaseInterface::Culler &culler) override
Definition: gls_resources.h:51
void LevelsUp(int value)
Definition: gls_resources.h:84
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:112
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:103
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: rso_interface_1.h:210
Definition: rso_interface_1.h:61
Definition: rso_interface_3.h:61
Definition: rso_interface_5.h:66
Definition: rso_interface_5.h:62
Definition: gls_rso_interface_impl.h:68
const char * GetInclude(int index) const override
Definition: gls_rso_interface_impl.h:132
void PopParentName()
Pop the parent object name stack.
Definition: gls_rso_interface_impl.h:145
int ExcludeCount() const override
Definition: gls_rso_interface_impl.h:114
const char * GetExclude(int index) const override
Definition: gls_rso_interface_impl.h:119
bool NamesOnly() const override
Definition: gls_rso_interface_impl.h:99
void PushParentName(const char *parent)
Definition: gls_rso_interface_impl.h:142
void GroupLevelsDown(int value) override
Definition: gls_rso_interface_impl.h:96
RSOResourceFilterImpl(GlsResourceFilter *filter)
Definition: gls_rso_interface_impl.h:75
void LevelsUp(int value) override
Definition: gls_rso_interface_impl.h:86
void AddExclude(const char *str) override
Definition: gls_rso_interface_impl.h:110
bool PassFilter(const char *name) const override
Definition: gls_rso_interface_impl.h:138
int LevelsUp() const override
Definition: gls_rso_interface_impl.h:80
void AddInclude(const char *str) override
Definition: gls_rso_interface_impl.h:123
unsigned int ParentNameCount() const
Definition: gls_rso_interface_impl.h:148
int GroupLevelsDown() const override
Definition: gls_rso_interface_impl.h:89
int IncludeCount() const override
Definition: gls_rso_interface_impl.h:127
const char * GetParentName(unsigned int index) const
Definition: gls_rso_interface_impl.h:153
void NamesOnly(bool value) override
Definition: gls_rso_interface_impl.h:106
Definition: vertex.h:85
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:222
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:52
#define GLS_EDITOR
Macro denoting which functions should be visible from the editor.
Definition: gls_include.h:63
disti::GlsResourceFilter classes and methods.
disti::RSOInterfaceES1 RsoImplMultiTouchInterface
Typedef for the RSO interface version that introduced multitouch support.
Definition: gls_rso_interface_impl.h:50
disti::RSOInterfaceES1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: gls_rso_interface_impl.h:49
disti::RSOInterfaceES1::MatrixF RSOMatrixT
Typedef for the RSO interface matrix type.
Definition: gls_rso_interface_impl.h:51
disti::RSOInterfaceES2::RSOPainter RSOPainterT
Typedef for the RSO interface painter type.
Definition: gls_rso_interface_impl.h:52
disti::RSOInterfaceES2 RsoImplBaseClass
Typedef for the current RSO interface.
Definition: gls_rso_interface_impl.h:48
Definition: bmpimage.h:47
RSOInterfaceES1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: live_component_lib_ref.h:53
Defines the RSO interface v5, which extends v4 to add conditional rendering support.