| GL Studio C++ Runtime API

gls_geometry_resource.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsGeometryResource 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_GEOMETRY_RESOURCE_H_INCLUDED
41#define GLS_GEOMETRY_RESOURCE_H_INCLUDED
42
43#include "assert.h"
44
45#ifdef _WIN32
46# include <windows.h>
47#endif
48
49#ifdef LINUX
50# include <limits.h>
51#endif
52
53#ifdef GLES
54# include "gls_gl.h"
55# include "limits.h"
56#else
57# ifdef __APPLE__
58# include <OpenGL/gl.h>
59# else
60# include <GL/gl.h>
61# endif
62#endif
63
64#include "disti_assert.h"
65#include "gls_matrix_affine.h"
66#include "gls_render_effect.h"
67#include "gls_resource_file_mgr.h"
68#include "vertex.h"
69
70//////////////////// Provides support for creating DLLs ////////////////////////
71#if( defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLSGEN_IMPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
72 && defined( _MSC_VER )
73# if defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED )
74# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllexport )
75# else
76# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllimport )
77# endif
78#else
79# define GLSGEN_GlsGeometryResource_EXPORT
80#endif
81///////////////////////////////////////////////////////////////////////////////
82
83 namespace disti
84{
85/** The geometry resource abstract base class */
86 class GlsGeometryResource
87{
88 public:
89 static const unsigned int MAX_TEXTURE_COORDS = 2; ///< GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates.
90 static const unsigned int MAX_VERTEX_ATTRIBS = 16; ///< GL_MAX_VERTEX_ATTRIBS.
91
92 static const unsigned int VERTEX_ATTRIBUTE_SIZE = 3 * sizeof( float ); ///< Size of vertex storage, in bytes.
93 static const unsigned int NORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float ); ///< Size of normal storage, in bytes.
94 static const unsigned int COLOR_ATTRIBUTE_SIZE = 4 * sizeof( unsigned char ); ///< Size of color storage, in bytes.
95
96 static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE = 3 * sizeof( unsigned char ); ///< Size of secondary color storage, in bytes.
97 static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE = 2 * sizeof( float ); ///< Size of texture coordinate storage, in bytes.
98 static const unsigned int TANGENT_ATTRIBUTE_SIZE = 3 * sizeof( float ); ///< Size of tangent storage, in bytes.
99 static const unsigned int BINORMAL_ATTRIBUTE_SIZE = 3 * sizeof( float ); ///< Size of binormal storage, in bytes.
100
101 /// \details The TypeDesc class. Describes the underlying format of a GL vertex.
102 class TypeDesc
103 {
104 bool hasNormal; ///< True if vertices have normals (float[3]).
105 bool hasColor; ///< True if vertices have color (UINT32).
106 bool hasSecondaryColor; ///< True if vertices have secondary color (UINT32).
107#ifdef GLES
108 unsigned int normalType; ///< GL_FLOAT or GL_UNSIGNED_BYTE.
109 unsigned int texCoordType; ///< GL_FLOAT or GL_SHORT.
110#endif
111
112 unsigned char numTextureCoords; ///< Number of texture coordinates per vertex [0-MAX_TEXTURE_COORDS].
113 unsigned char texCoordDimension[ GlsGeometryResource::MAX_TEXTURE_COORDS ]; ///< Number of components for each texture coordinate.
114 unsigned char numVertexAttribs; ///< Number of generic vertex attributes per vertex [0-MAX_VERTEX_ATTRIBS].
115 GLint vertexAttribNumComponents[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; ///< Number of components in the generic vertex attribute.
116 GLenum vertexAttribType[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; ///< Specifies the type of each vertex attribute.
117 GLboolean vertexAttribNormalize[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; ///< Specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed..
118 unsigned int vertexAttribSemantic[ GlsGeometryResource::MAX_VERTEX_ATTRIBS ]; ///< Semantic for each vertex attribute.
119 public:
120 // Default constructor
121 TypeDesc()
122 {
123 memset( this, 0, sizeof( TypeDesc ) );
124 unsigned int i;
125 for( i = 0; i < GlsGeometryResource::MAX_TEXTURE_COORDS; i++ )
126 {
127 texCoordDimension[ i ] = 2;
128 }
129 for( i = 0; i < GlsGeometryResource::MAX_VERTEX_ATTRIBS; i++ )
130 {
131 vertexAttribNumComponents[ i ] = 4;
132 }
133#ifdef GLES
134 normalType = GL_FLOAT;
135 texCoordType = GL_FLOAT;
136#endif
137 }
138
139 /// Set whether or not there should be storage for normals.
140 /// \param value The new normal storage flag.
141 void HasNormal( bool value ) { hasNormal = value; }
142
143 /// \return Whether or not this type stores normals.
144 bool HasNormal() const { return hasNormal; }
145
146#ifdef GLES
147 /// Sets the normal type to the new value.
148 /// \param value Sets the normalType to this value.
149 void NormalType( unsigned int value )
150 {
151 normalType = value;
152 }
153
154 /// \return a copy of normalType.
155 unsigned int NormalType() const { return normalType; }
156
157 /// Sets the texCoordType to the new value.
158 /// \param value Sets the texCoordType to this value.
159 void TexCoordType( unsigned int value ) { texCoordType = value; }
160
161 /// \return a copy of texCoordType.
162 unsigned int TexCoordType() const { return texCoordType; }
163#endif
164
165 /// Set whether or not there should be storage for colors.
166 /// \param value The new color storage flag.
167 void HasColor( bool value ) { hasColor = value; }
168
169 /// \return Whether or not this type stores colors.
170 bool HasColor() const { return hasColor; }
171
172 /// Set whether or not there should be storage for secondary colors.
173 /// \param value The new secondary color storage flag.
174 void HasSecondaryColor( bool value ) { hasSecondaryColor = value; }
175
176 /// \return Whether or not this type store secondary colors.
177 bool HasSecondaryColor() const { return hasSecondaryColor; }
178
179 /// Set the number of texture coordinates to be stored.
180 /// \param value The new number of texture coordinates to store.
181 void SetNumTextureCoords( unsigned char value )
182 {
183 if( value <= GlsGeometryResource::MAX_TEXTURE_COORDS )
184 {
185 numTextureCoords = value;
186 }
187 }
188
189 /// \return The number of texture coordinates stored.
190 unsigned char GetNumTextureCoords() const { return numTextureCoords; }
191
192 /// Set a component of a texture coordinate.
193 /// \param which 0 or 1
194 /// \param value 0 through 4
195 void SetTexCoordDimension( unsigned char which, unsigned char value )
196 {
197 if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
198 {
199 texCoordDimension[ which ] = value;
200 }
201 }
202
203 /// \return The component of a given texture coordinate (0 through 4).
204 /// \param which 0 or 1
205 unsigned char GetTexCoordDimension( unsigned char which ) const { return texCoordDimension[ which ]; }
206
207 /** Set the number of generic vertex attributes stored in the resource.
208 Generic vertex attributes are passed to OpenGL using glVertexAttribPointer.
209 These are special attributes to be used by the vertex shader.
210
211 \param value The new number of generic vertex attributes
212 \sa SetVertexAttribSizeBytes
213 */
214 void SetNumVertexAttribs( unsigned char value )
215 {
216 if( value <= GlsGeometryResource::MAX_VERTEX_ATTRIBS )
217 numVertexAttribs = value;
218 }
219
220 /// \return The number of vertex attributes.
221 unsigned char GetNumVertexAttribs() const { return numVertexAttribs; }
222
223 /// Set the size (number of components) in the generic vertex attribute.
224 /// See documentation on glVertexAttribPointer for details.
225 /// \param which The index of the attribute to set.
226 /// \param value The value to set at the attribute.
227 void SetVertexAttribComponents( unsigned char which, GLint value )
228 {
229 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
230 vertexAttribNumComponents[ which ] = value;
231 }
232
233 /// \return The number of components of the given vertex attribute.
234 /// \param which The attribute in question.
235 GLint GetVertexAttribComponents( unsigned char which ) const { return vertexAttribNumComponents[ which ]; }
236
237 /// Set the type of a given generic vertex attribute.
238 /// See documentation on glVertexAttribPointer for details.
239 /// \param which The index of the attribute to set.
240 /// \param value The value to set at the attribute.
241 void SetVertexAttribType( unsigned char which, GLenum value )
242 {
243 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
244 {
245 vertexAttribType[ which ] = value;
246 }
247 }
248
249 /// \return The given vertex attribute.
250 /// \param which The index of the attribute.
251 GLenum GetVertexAttribType( unsigned char which ) const { return vertexAttribType[ which ]; }
252
253 /// Set whether fixed-point data values should be normalized (Default is false).
254 /// See documentation on glVertexAttribPointer for details.
255 /// \param which The index of the attribute to set.
256 /// \param value The value to set at the attribute.
257 void SetVertexAttribNormalize( unsigned char which, GLboolean value )
258 {
259 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
260 {
261 vertexAttribNormalize[ which ] = value;
262 }
263 }
264
265 /// \return The normalize flag for the given attribute.
266 /// \param which The index of the attribute.
267 GLboolean GetVertexAttribNormalize( unsigned char which ) const { return vertexAttribNormalize[ which ]; }
268
269 /// Set semantic of a given generic vertex attribute
270 /// The semantic value can be used to determine the "meaning" of the vertex attribute
271 /// \param which Which vertex attrib to set
272 /// \param semanticEnum The new sematic value (see AttributeSemanticEnum)
273 void SetVertexAttribSemantic( unsigned char which, int semanticEnum )
274 {
275 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS )
276 vertexAttribSemantic[ which ] = semanticEnum;
277 }
278
279 /// \return The semantic value for the given attribute index.
280 /// \param which The index of the attribute.
281 int GetVertexAttribSemantic( unsigned char which ) const { return vertexAttribSemantic[ which ]; }
282 };
283
284 /// Something that we can initialize the Resource ID to
285 /// and then check for to see if we have initialized the resource.
286 typedef enum
287 {
288 BAD_ID = 0xffffffff
289 } BadId;
290
291 virtual ~GlsGeometryResource() {}
292
293 /// \details The observer class is used for notifications when attributes that affect how the object would draw are changed
294 class Observer
295 {
296 public:
297 /// Callback method to be called by this observer.
298 virtual void OnGeometryResourceChanged() = 0;
299
300 protected:
301 Observer() {}
302 virtual ~Observer() {}
303
304 private:
305 // Disable copying
306 Observer( const Observer& ) DISTI_SPECIAL_MEM_FUN_DELETE;
307 void operator=( const Observer& ) DISTI_SPECIAL_MEM_FUN_DELETE;
308 };
309
310 /// Adds a new observer to the list.
311 /// \param observer The new observer to add.
312 void AddObserver( Observer* observer )
313 {
314 _observers.PushBack( observer );
315 }
316
317 /// Removes the specified observer from the list.
318 /// \param observer The observer to remove.
319 void RemoveObserver( Observer* observer )
320 {
321 _observers.Erase( observer );
322 }
323
324 protected:
325 DynamicArray<Observer*> _observers; ///< The held list of observers w/ callbacks.
326
327 /// Called to call all observer callbacks when the attribute changes.
328 void OnGeometryResourceChanged()
329 {
330 for( unsigned int i = 0; i < _observers.Count(); ++i )
331 {
332 _observers[ i ]->OnGeometryResourceChanged();
333 }
334 }
335
336 /** Give this Resource a unique id so we can get it. */
337 unsigned int _resourceID;
338
339 /** The number of Parent Objects using this object. Once the number reaches zero, the object self deletes. */
340 unsigned int _referenceCount;
341
342 /** The TypeDesc that describes what is in this Resource */
343 TypeDesc _type;
344
345 /** The number of index buffers in this mesh */
346 unsigned int _numIndexBuffers;
347
348 Vector _boundingVolumeCenter; ///< Center location of the bounding volume.
349 float _boundingVolumeRadius; ///< Radius of the bounding volume.
350
351 // Shared between all instances
352 static bool _enableVBO; ///< If true, OpenGL supports vertex buffer objects (1.5 or greater).
353
354 /** Deletes this object from the heap that it was allocated on */
355 virtual void Destroy() = 0;
356
357 public:
358 /// When enabled, GlsGeometryResource::CreateInstance will instantiate GlsGeometry_HalfFloat objects when possible.
359 /// \param value Whether or not to use half floats.
360 static GLSGEN_GlsGeometryResource_EXPORT void SetCreateInstanceMakesHalfFloat( bool value );
361
362 /// Construct an empty GlsGeometryResource with the given type.
363 /// The initial reference count is 1.
364 /// Call DecrementReference to free the resource when you are done with it.
365 /// \param type A description of the initial Structure.
366 /// \return A pointer to a new GlsGeometryResource.
367 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance( const TypeDesc& type = GlsGeometryResource::TypeDesc() );
368
369 /// Construct a GlsGeometryResource from a binary resource.
370 /// The initial reference count is 1.
371 /// Call DecrementReference to free the GlsGeometryResource when you are done with it.
372 /// \param resource A pointer to a ResourceRef containing geometry data.
373 /// \return A pointer to a new GlsGeometryResource.
374 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometryResource* CreateInstance( GlsResourceFileMgr::ResourceRef* resource );
375
376 /** Setup the OpenGL state for rendering this geometry.
377 To draw, call DrawIndexBuffer for each index buffer in the resource.
378 After drawing, call DrawCleanup to restore the OpenGL state.
379 \param shaderProgram interface to the shader program, used to lookup correct VertexAttrib index values (may be NULL)
380 \post The OpenGL state is configured for rendering from the index buffers.
381 */
382 virtual void DrawSetup( VertexAttribIndexLookup* shaderProgram ) = 0;
383
384 /** Draw the geometry specified by the given index buffer
385 This method should only be called between calls to DrawSetup
386 and DrawCleanup.
387 \pre DrawSetup has been called.
388 \param bufferNumber Which index buffer to draw
389 */
390 virtual void DrawIndexBuffer( unsigned int bufferNumber ) = 0;
391
392 /** Restore the OpenGL state after rendering.
393 \param shaderProgram Must be the same value that was passed to DrawSetup
394 \pre DrawSetup was called
395 \post The OpenGL state will be restored
396 */
397 virtual void DrawCleanup( VertexAttribIndexLookup* shaderProgram ) = 0;
398
399 /** Force the GlsGeometryResource to free any buffers it has allocated in the current OpenGL context.
400 */
401 virtual void FreeOpenGLBuffers() = 0;
402
403 /** Since calculating metrics like the extents can be an expensive operation, the user can call this
404 * function to see if the geometry resource has changed. Caching the expensive-to-calculate values
405 * is the responsibility of the caller.
406 * \return The current extents ID. Never equal to s_invalidDataChangedCounter.
407 * \sa s_invalidDataChangedCounter
408 */
409 virtual unsigned int GetDataChangedCounter() const = 0;
410
411 /** A sentinel value for clients to initialize their counts with. GetDataChangedCounter() will never return this value. */
412 static const unsigned int s_invalidDataChangedCounter = 0;
413
414 /** Calculate and return the geometry extents
415 * \param min Returns the minimum x,y,z values
416 * \param max Returns the maximum x,y,z values
417 * \param matrix (Optional) matrix to transform the vertices into the desired coordinate system
418 * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
419 * \sa GetDataChangedCounter()
420 */
421 virtual void GetExtents( Vector& min, Vector& max, const GlsMatrixType* matrix = NULL ) = 0;
422
423 /** Updates the bounding volume of this object
424 * This method should be called if the vertices change for picking and
425 * culling to work correctly.
426 * \note This can be an expensive operation. GetDataChangedCounter() can be used to minimize this expense.
427 * \sa GetDataChangedCounter()
428 */
429 virtual void UpdateBoundingVolume() = 0;
430
431 /** Determines if the given ray hits the geometry bounding volume.
432 * Note: All parameters should be in this object's coordinates.
433 * @param point The starting point of the ray.
434 * @param direction The direction vector of the ray.
435 * @return True if this bounding volume is hit by the ray.
436 */
437 virtual bool BoundingVolumeHit( const Vector& point, const Vector& direction ) = 0;
438
439 /** Hit test the geometry against a picking line. All values are in geometry space.
440 * \param pickType The type of picking (see PickableType_e), must be PICK_FIRST or PICK_BEST
441 * \param pickLinePoint A point on the pick line.
442 * \param pickLineDirection The direction of the pick line.
443 * \param collisionPoint If the method returns true, this contains the point that was hit.
444 * \return true if the object was hit by the pick.
445 */
446 virtual bool HitTest( unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint ) = 0;
447
448 /// \return The vertex count for use in editor statistics.
449 /// \param bufferNumber The index of the buffer to count up.
450 virtual unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber ) = 0;
451
452 /// \return The polygon count for use in editor statistics.
453 /// \param bufferNumber The index of the buffer to count up.
454 virtual unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber ) = 0;
455
456 /// \return The TypeDesc for this resource.
457 GLSGEN_GlsGeometryResource_EXPORT const TypeDesc& Type() { return _type; }
458
459 /** Increment the Reference count to this instance. */
460 GLSGEN_GlsGeometryResource_EXPORT void IncrementReference() { _referenceCount++; }
461
462 /** Decrement the Reference count to this instance.
463 * \note The OpenGL context should be available to free resources.
464 */
465 GLSGEN_GlsGeometryResource_EXPORT void DecrementReference()
466 {
467 GLS_ASSERT( _referenceCount > 0 );
468
469 _referenceCount--;
470
471 if( _referenceCount == 0 )
472 {
473 Destroy();
474 }
475 }
476
477 /// \returns The number of index buffers in this geometry resource.
478 unsigned int NumIndexBuffers() const
479 {
480 return _numIndexBuffers;
481 }
482
483 /// \return The bounding sphere center.
484 const Vector& BoundingVolumeCenter() const { return _boundingVolumeCenter; }
485
486 /// \return The bounding sphere radius.
487 float BoundingVolumeRadius() const { return _boundingVolumeRadius; }
488
489 /** Sets a new resource ID
490 * \param id The new ID
491 * \pre id != BAD_ID
492 */
493 GLSGEN_GlsGeometryResource_EXPORT void SetResourceId( unsigned int id )
494 {
495 assert( BAD_ID != id );
496 _resourceID = id;
497 }
498
499 /// \return The current resource ID.
500 /// \pre _resourceID != BAD_ID
501 GLSGEN_GlsGeometryResource_EXPORT unsigned int GetResourceId()
502 {
503 assert( BAD_ID != _resourceID );
504 return _resourceID;
505 }
506};
507
508/** Forward declaration */
509 class GlsGeometry_Generic_IndexBufferData;
510/** Flexible implementation of GlsGeometryResource that can store any type of geometry
511 * This resource is used in the editor and may be used at runtime if there is not a more efficient implementation for the desired TypeDesc.
512 */
513 class GlsGeometry_Generic : public GlsGeometryResource
514{
515 public:
516 ////////////////////////////////
517 //
518 // GlsGeometryResource methods
519 //
520 ////////////////////////////////
521
522 virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferVertexCount( unsigned int bufferNumber ) DISTI_METHOD_OVERRIDE
523 {
524 return GetIndexBufferSize( bufferNumber ) / 3;
525 }
526
527 virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int StatsIndexBufferPolygonCount( unsigned int bufferNumber ) DISTI_METHOD_OVERRIDE
528 {
529 return GetIndexBufferSize( bufferNumber );
530 }
531
532 virtual GLSGEN_GlsGeometryResource_EXPORT unsigned int GetDataChangedCounter() const DISTI_METHOD_OVERRIDE;
533 virtual GLSGEN_GlsGeometryResource_EXPORT void GetExtents( Vector& min, Vector& max, const GlsMatrixType* matrix = NULL ) DISTI_METHOD_OVERRIDE;
534 virtual GLSGEN_GlsGeometryResource_EXPORT void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE;
535 virtual GLSGEN_GlsGeometryResource_EXPORT bool BoundingVolumeHit( const Vector& point, const Vector& direction ) DISTI_METHOD_OVERRIDE;
536 virtual GLSGEN_GlsGeometryResource_EXPORT bool HitTest( unsigned char pickType, const Vector& pickLinePoint, const Vector& pickLineDirection, Vector& collisionPoint ) DISTI_METHOD_OVERRIDE;
537 virtual GLSGEN_GlsGeometryResource_EXPORT void DrawSetup( VertexAttribIndexLookup* shaderProgram ) DISTI_METHOD_OVERRIDE;
538 virtual GLSGEN_GlsGeometryResource_EXPORT void DrawIndexBuffer( unsigned int bufferNumber ) DISTI_METHOD_OVERRIDE;
539 virtual GLSGEN_GlsGeometryResource_EXPORT void DrawCleanup( VertexAttribIndexLookup* shaderProgram ) DISTI_METHOD_OVERRIDE;
540 virtual GLSGEN_GlsGeometryResource_EXPORT void FreeOpenGLBuffers() DISTI_METHOD_OVERRIDE;
541
542 ////////////////////////////////
543 //
544 // GlsGeometry_Generic methods
545 //
546 ////////////////////////////////
547
548 /// Create GlsGeometry_Generic from TypeDesc.
549 /// \param type The storage format type to use.
550 /// \return The new geometry object.
551 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( const TypeDesc& type );
552
553 /// Construct a GlsGeometryResource from a binary resource
554 /// The initial reference count is 1.
555 /// Call DecrementReference to free the GlsGeometryResource when you are done with it.
556 /// \param resource pointer to a ResourceRef containing geometry data
557 /// \return The new geometry object.
558 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateInstance( GlsResourceFileMgr::ResourceRef* resource );
559
560 /// Create GlsGeometry_Generic from binary resource.
561 /// \param data The data to create object from.
562 /// \return The new geometry object.
563 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateFromBinaryResource( GlsResourceFileMgr::BinaryResource* data );
564
565 /// Create an empty GlsGeometry_Generic with default TypeDesc.
566 /// \return The new geometry object.
567 static GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic* CreateEmptyInstance();
568
569 /** Copy the geometry from another resource into this one.
570 Does not change the Type of this resource: only vertex attributes that both resources have in common will be copied.
571 \param rhs the resource to copy from
572 */
573 GLSGEN_GlsGeometryResource_EXPORT void CopyVertexAndIndexBuffers( GlsGeometry_Generic* rhs );
574
575 /** Changes the Type of this geometry resource.
576 This is a slow operation; it creates new storage according to the typeDesc and copys the existing vertex data.
577 If a vertex attribute does not map to the new type it will be lost. Any new attributes will be uninitialized.
578 Requires that the OpenGL context is current if this GlsGeometryResource has been previously drawn.
579
580 \param type The TypeDesc to use for the new structure
581 */
582 GLSGEN_GlsGeometryResource_EXPORT void ChangeType( const TypeDesc& type );
583
584 /** Attempt to Lock the Buffers, Non-Blocking
585 \return True if a lock is posible
586 */
587 GLSGEN_GlsGeometryResource_EXPORT bool LockBuffers();
588
589 /** Release the lock on the buffers.
590 Note: If the Vertex data was changed, you should typically call UpdateBoundingVolume() before unlocking.
591 \see UpdateBoundingVolume
592 \post If the buffer is not locked a debug message is sent to the terminal
593 */
594 GLSGEN_GlsGeometryResource_EXPORT void UnlockBuffers();
595
596 /** Get the size of the vertex buffer
597 \return The number of items in the vertex buffer
598 */
599 GLSGEN_GlsGeometryResource_EXPORT unsigned int VertexCount() const;
600
601 /** Set the size of the vertex buffer
602 \param count How many items the Vertex Buffer contains.
603 \pre size must be greater than zero
604 */
605 GLSGEN_GlsGeometryResource_EXPORT void VertexCount( unsigned int count );
606
607 /** Set a vertex
608 \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
609 \param *value Vertex can either be 3 or 4 floats depending on the type
610 \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
611 */
612 GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex, const float* value );
613
614 /// Vector version of SetVertex().
615 /// \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1.
616 /// \param value The Vector to set, uses its internal float array.
617 void SetVertex( GLuint vertIndex, const Vector* value ) { SetVertex( vertIndex, (float*)value ); }
618
619 /** Initialize the vertex data from an array of floats.
620
621 Steps through the array reading the data for each vertex. If Type() is POSITION_XYZ, the method will read 3 floats per vertex.
622 If Type() is POSITION_XYZW, the method will read 4 floats per vertex.
623
624 \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
625 \param numVertices Number of vertices to read from of the array
626 \param startVertIndex (optional) The vertex buffer index to start copying into
627 \param stride (optional) The distance between each vertex in the floatArray (in bytes)
628 */
629 GLSGEN_GlsGeometryResource_EXPORT void SetVertices( const float* floatArray,
630 unsigned int numVertices,
631 unsigned int startVertIndex = 0,
632 unsigned int stride = VERTEX_ATTRIBUTE_SIZE );
633
634 /** Set the vertex at a given index to a coordinate
635 \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
636 \param x The x-coord
637 \param y The y-coord
638 \param z The z-coord
639 \pre vertex must be a pointer to 3 or 4 floats, vertIndex must be less than VertexCount()
640 */
641 GLSGEN_GlsGeometryResource_EXPORT void SetVertex( GLuint vertIndex,
642 float x,
643 float y,
644 float z );
645
646 /** Return a pointer to an array of 3 or 4 floats which is the vertex
647 for the given index.
648
649 \param vertIndex The index of the vertex to get, 0 to VertexCount() - 1
650 \return a pointer to a 3 or 4 float vertex
651 \pre vertIndex must be less than VertexCount()
652 */
653 GLSGEN_GlsGeometryResource_EXPORT const float* GetVertex( GLuint vertIndex );
654
655 /** Set a Normal
656 \param vertIndex The index of the vertex to change, 0 to VertexCount() - 1
657 \param x X Normal value to assign
658 \param y Y Normal value to assign
659 \param z Z Normal value to assign
660 \pre normal must be a valid Vector, vertIndex must be less than VertexCount()
661 NORMAL must be part of the Type
662 */
663 GLSGEN_GlsGeometryResource_EXPORT void SetNormal( GLuint vertIndex, float x, float y, float z );
664
665 /** Initialize the vertex normals from an array of floats.
666
667 Steps through the array reading the normal data for each vertex. The method will read 3 floats for each normal.
668
669 \param floatArray Pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
670 \param numVertices Number of vertices to read from of the array
671 \param startVertIndex (optional) The vertex buffer index to start copying into
672 \param stride (optional) The distance between each normal in the floatArray (in bytes)
673 */
674 GLSGEN_GlsGeometryResource_EXPORT void SetNormals( const float* floatArray,
675 unsigned int numVertices,
676 unsigned int startVertIndex = 0,
677 unsigned int stride = NORMAL_ATTRIBUTE_SIZE );
678
679 /** Get a pointer to the Normal for a given Vertex index. Do
680 not change the Normal, change it through the Set function!
681 \param vertIndex The index of the Normal to get, 0 to VertexCount() - 1
682 \return a pointer to an array of 3 floats.
683 \pre vertIndex must be less than VertexCount()
684 NORMAL must be part of the Type
685 */
686 GLSGEN_GlsGeometryResource_EXPORT const float* GetNormal( GLuint vertIndex );
687
688 /** Set a color value
689 \param vertIndex The index of the color value to change, 0 to VertexCount() - 1
690 \param red Red
691 \param green Green
692 \param blue Blue
693 \param alpha Alpha
694 */
695 GLSGEN_GlsGeometryResource_EXPORT void SetColor( GLuint vertIndex,
696 unsigned char red,
697 unsigned char green,
698 unsigned char blue,
699 unsigned char alpha );
700
701 /** Initialize the vertex colors from an array of unsigned int containing rgba color data.
702
703 Steps through the array reading the color data for each vertex. The method will read 1 integer for each color.
704
705 \param rgbaArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
706 \param numVertices Number of vertices to read from of the array
707 \param startVertIndex (optional) The vertex buffer index to start copying into
708 \param stride (optional) The distance between each color in the rgbaArray (in bytes)
709 */
710 GLSGEN_GlsGeometryResource_EXPORT void SetColors( const unsigned int* rgbaArray,
711 unsigned int numVertices,
712 unsigned int startVertIndex = 0,
713 unsigned int stride = COLOR_ATTRIBUTE_SIZE );
714
715 /** Initialize Color from an array
716 \param array an array of color values in RGBA order of size VertexCount()
717 \pre The array must be of size VertexCount()
718 */
719 GLSGEN_GlsGeometryResource_EXPORT void SetColors( const unsigned int* array );
720
721 /** Gets the color value of the given vertex index
722 \param vertIndex The index of the color value to get, 0 to VertexCount() - 1
723 \return a pointer to a color array in rgba order
724 \pre vertIndex must be less than VertexCount(),
725 */
726 GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetColor( GLuint vertIndex );
727
728 /** Set a secondary color value (specular)
729 \param red Red
730 \param green Green
731 \param blue Blue
732 \param vertIndex The index of the secondary color value to change, 0 to VertexCount() - 1
733 \pre vertIndex must be less than VertexCount()
734 */
735 GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColor( GLuint vertIndex,
736 unsigned char red,
737 unsigned char green,
738 unsigned char blue );
739
740 /** Initialize the vertex secondary colors from an array of unsigned int containing rgb color data. (Secondary colors do not include alpha)
741
742 Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
743
744 \param rgbArray pointer to the array to read from. The array must be at least (numVertices * stride) bytes.
745 \param numVertices Number of vertices to read from of the array
746 \param startVertIndex (optional) The vertex buffer index to start copying into
747 \param stride (optional) The distance between each color in the array (in bytes)
748 */
749 GLSGEN_GlsGeometryResource_EXPORT void SetSecondaryColors( const unsigned int* rgbArray,
750 unsigned int numVertices,
751 unsigned int startVertIndex = 0,
752 unsigned int stride = SECONDARY_COLOR_ATTRIBUTE_SIZE );
753
754 /** Get the secondary color of the vertex at the given index.
755 \param vertIndex The index of the secondary color value to get, 0 to VertexCount() - 1
756 \return a pointer to a secondary color value in RGB order
757 \pre vertIndex must be less than VertexCount()
758 */
759 GLSGEN_GlsGeometryResource_EXPORT unsigned char* GetSecondaryColor( GLuint vertIndex );
760
761 /** Set a TextureCoord
762 \param textureCoord TextureCoord value to assign. Must point to a float array containing TextureCoordinateDepth() elements
763 \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
764 \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
765 \pre vertIndex must be less than VertexCount()
766 TEXCOORD must be part of the Type
767 whichTexture must be 0 to 7
768 */
769 GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture, const float* textureCoord );
770
771 /// Two float version of SetTextureCoord().
772 /// \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1.
773 /// \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
774 /// \param textureCoordU The new U coordinate to set.
775 /// \param textureCoordV The new V coordinate to set.
776 GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoord( GLuint vertIndex, unsigned int whichTexture, float textureCoordU, float textureCoordV );
777
778#ifdef GLES
779 /** Sets all texture coordinates from a pointer of texture coordinate data
780
781 \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
782 \param textureCoordArray Pointer to texture coordinate data to assign. Must point to a float array containing TextureCoordinateDepth() elements
783 \param numVertices The number of vertices worth of texture coordinate data in the array
784 \param startVertIndex (optional) The texture coord vertex element to start copying into
785 \param stride (optional) The distance between each texture coordinate in the array (in bytes)
786 */
787 GLSGEN_GlsGeometryResource_EXPORT void SetTextureCoords( unsigned int whichTexture,
788 const float* textureCoordArray,
789 unsigned int numVertices,
790 unsigned int startVertIndex = 0,
791 unsigned int stride = TEXTURE_COORDINATE_ATTRIBUTE_SIZE );
792#endif
793
794 /** Get a TextureCoord
795 \param vertIndex The index of the TextureCoord value to change, 0 to VertexCount() - 1
796 \param whichTexture Which set of texture coordinates to change, 0 to NumTextureCoordinateArrays() - 1.
797 \return Return a pointer to the Texture Coordinates ask for
798 \pre vertIndex must be less than VertexCount()
799 TEXCOORD must be part of the Type
800 textureCount must be 1 to 8
801 */
802 GLSGEN_GlsGeometryResource_EXPORT const float* GetTextureCoord( GLuint vertIndex, unsigned int whichTexture );
803
804 /** Store a generic vertex attribute value
805 \param vertIndex The index of the vertex
806 \param attribIndex The index of the generic vertex attribute to be modified
807 \param value void pointer to the value
808 \param sizeBytes size of the value in bytes
809 */
810 GLSGEN_GlsGeometryResource_EXPORT void StoreVertexAttrib( GLuint vertIndex, GLuint attribIndex, void* value, GLuint sizeBytes );
811
812 /// One float version of StoreVertexAttrib().
813 /// \param vertIndex The index of the vertex.
814 /// \param attribIndex The index of the generic vertex attribute to be modified.
815 /// \param v A pointer to an array of floats.
816 void SetVertexAttrib1fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 1 * sizeof( float ) ); }
817
818 /// Two float version of StoreVertexAttrib().
819 /// \param vertIndex The index of the vertex.
820 /// \param attribIndex The index of the generic vertex attribute to be modified.
821 /// \param v A pointer to an array of floats.
822 void SetVertexAttrib2fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 2 * sizeof( float ) ); }
823
824 /// Three float version of StoreVertexAttrib().
825 /// \param vertIndex The index of the vertex.
826 /// \param attribIndex The index of the generic vertex attribute to be modified.
827 /// \param v A pointer to an array of floats.
828 void SetVertexAttrib3fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 3 * sizeof( float ) ); }
829
830 /// Four float version of StoreVertexAttrib().
831 /// \param vertIndex The index of the vertex.
832 /// \param attribIndex The index of the generic vertex attribute to be modified.
833 /// \param v A pointer to an array of floats.
834 void SetVertexAttrib4fv( GLuint vertIndex, GLuint attribIndex, const GLfloat* v ) { StoreVertexAttrib( vertIndex, attribIndex, (void*)v, 4 * sizeof( float ) ); }
835
836#ifdef GLES
837 /// Updates the VertexStructureDefinition to contain new vertex data.
838 /// \param attribArray An array of floats that contains the raw vertex data.
839 /// \param attribIndex Index of the vertex attribute. This determines which attribute to access in each vertex.
840 /// \param numVertices Determines the number of vertices to access starting from startVertIndex.
841 /// \param startVertIndex Index to the first vertex to access.
842 /// \param stride Determines the amount to 'jump' for each vertex.
843 GLSGEN_GlsGeometryResource_EXPORT void SetVertexAttribs( const float* attribArray,
844 GLuint attribIndex,
845 unsigned int numVertices,
846 unsigned int startVertIndex = 0,
847 unsigned int stride = TANGENT_ATTRIBUTE_SIZE );
848#endif
849
850 /// Get pointer to the raw vertex attribute data, be careful with this!
851 /// \note This method may be removed in the future.
852 /// \param vertIndex The index of the vertex.
853 /// \param attribIndex The index of the generic vertex attribute.
854 /// \return A pointer to raw data.
855 GLSGEN_GlsGeometryResource_EXPORT void* GetVertexAttrib( GLuint vertIndex, GLuint attribIndex );
856
857 using GlsGeometryResource::NumIndexBuffers;
858
859 /** Get the number of available index buffers
860 * \param count Set the number of index buffers in this geometry resource.
861 */
862 GLSGEN_GlsGeometryResource_EXPORT void NumIndexBuffers( unsigned int count );
863
864 /** Gets the size of an index buffer
865 \param bufferNum Which index buffer to return the size of
866 \return The number of items that the given index buffer can hold
867 */
868 GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndexBufferSize( unsigned int bufferNum ) const;
869
870 /** Set the size of the specified index buffer
871 \param bufferNum Which index buffer to set the size of
872 \param newSize How many items the Index Buffer can hold.
873 \pre newSize must be greater than zero
874 */
875 GLSGEN_GlsGeometryResource_EXPORT void SetIndexBufferSize( unsigned int bufferNum, unsigned int newSize );
876
877 /** Change the Vertex index
878 \param bufferNum Which index buffer to modify
879 \param index The index of the Index to change, 0 to GetIndexBufferSize(bufferNum)) - 1
880 \param indexValue Index must be less than GetIndexBufferSize(bufferNum)
881 */
882 GLSGEN_GlsGeometryResource_EXPORT void SetIndex( unsigned int bufferNum, unsigned int index, unsigned int indexValue );
883
884#ifndef GLES
885
886 /** Initialize the Index buffer from an array of index values
887 *
888 * Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
889 *
890 * \param bufferNum Which index buffer to modify
891 * \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
892 * \param numIndices Number of indices to read from of the array
893 * \param startIndex (optional) The index buffer element to start copying into
894 * \param stride (optional) The distance between each index in the array (in bytes)
895 */
896 GLSGEN_GlsGeometryResource_EXPORT void SetIndices( unsigned int bufferNum,
897 const unsigned int* indexArray,
898 unsigned int numIndices,
899 unsigned int startIndex = 0,
900 unsigned int stride = sizeof( unsigned int ) );
901
902 /** Gets an index from an index buffer
903 \param bufferNum Which index buffer to read from
904 \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
905 \return an Index value
906 \pre index must be less than GetIndexBufferSize(bufferNum)
907 */
908 GLSGEN_GlsGeometryResource_EXPORT unsigned int GetIndex( unsigned int bufferNum, unsigned int index );
909
910 /// Merge two index buffers by adding the indexes from the source buffer to the dest buffer,
911 /// then deleting the source buffer.
912 /// \param dstBufferNum Which index buffer to add to.
913 /// \param srcBufferNum Which index buffer to delete.
914 GLSGEN_GlsGeometryResource_EXPORT void MergeIndexBuffers( unsigned int dstBufferNum, unsigned int srcBufferNum );
915
916#else // GLES
917
918 /** Initialize the Index buffer from an array of index values
919
920 Steps through the array reading the color data for each vertex. The method will read 3 bytes for each color.
921
922 \param bufferNum Which index buffer to modify
923 \param indexArray pointer to the array to read from. The array must be at least (numIndices * stride) bytes.
924 \param numIndices Number of indices to read from of the array
925 \param startIndex (optional) The index buffer element to start copying into
926 \param stride (optional) The distance between each index in the array (in bytes)
927 */
928 GLSGEN_GlsGeometryResource_EXPORT void SetIndices( unsigned int bufferNum,
929 const unsigned int* indexArray,
930 unsigned int numIndices,
931 unsigned int startIndex = 0,
932 unsigned int stride = sizeof( unsigned int ) );
933
934 /** Get an index from an index buffer
935 \param bufferNum Which index buffer to read from
936 \param index The index of the Index to get, 0 to GetIndexBufferSize(bufferNum) - 1
937 \return an Index value
938 \pre index must be less than GetIndexBufferSize(bufferNum)
939 */
940 GLSGEN_GlsGeometryResource_EXPORT unsigned short GetIndex( unsigned int bufferNum, unsigned short index );
941
942#endif // !GLES
943
944 /** See GlsGeometryResource::VertexSort() */
945 typedef struct
946 {
947 unsigned int _order; ///< The order the vertex should be in.
948 unsigned int _vertexTupleIndex; ///< The index of the primitive.
949 } VertexSortData;
950
951 /** Sort the vertices, based on the input data
952
953 \param *sortData An array of VertexSortData structures, one for each primitive (set of three vertices).
954 The data in this is array is used to reorder the primitives. e.g.:
955 Input:
956 order 0,1,0,5,2
957 index 0,1,2,3,4
958 Sorted:
959 order 0,0,1,2,5
960 index 0,2,1,4,3
961
962 \pre sortData must be an array of VertexSortData VertexCount()/3 in size
963
964 \post The sortData array will be sorted based on _order.
965 The vertex buffer will be sorted based on the new order from the sortData.
966 */
967 GLSGEN_GlsGeometryResource_EXPORT void VertexSort( VertexSortData* sortData );
968
969 /** Dump all the vertices to the terminal
970 */
971 GLSGEN_GlsGeometryResource_EXPORT void DumpVertices();
972
973 /** Dump all the Normals to the terminal
974 */
975 GLSGEN_GlsGeometryResource_EXPORT void DumpNormals();
976
977 /** Dump all the Indices to the terminal
978 */
979 GLSGEN_GlsGeometryResource_EXPORT void DumpIndices();
980
981 /** Copy vertex attributes from srcGeom to dstGeom
982 Does not change the Type of the resource: only vertex attributes that both resources have in common will be copied.
983 \param dstGeom the resource to copy to
984 \param dstOffset vertex offset to start copying at
985 \param srcGeom the resource to copy from
986 \param srcOffset vertex offset to start copying from
987 \param vertexCount number of vertices to copy
988 \returns the number of vertices that were copied
989 */
990 static GLSGEN_GlsGeometryResource_EXPORT unsigned int CopyVertexData(
991 GlsGeometry_Generic* dstGeom, unsigned int dstOffset,
992 GlsGeometry_Generic* srcGeom, unsigned int srcOffset,
993 unsigned int vertexCount );
994
995 /// Apply a transform to the vertex attributes of the given mesh
996 /// The transform affects vertex position, normals, ATTRIB_TANGENT, and ATTRIB_BINORMAL
997 /// \param dstGeom The resource to modify.
998 /// \param transform The matrix used to convert vertex attributes.
999 /// \param vertexOffset Start of the range of verts to transform.
1000 /// \param vertexCount Number of verts to transform.
1001 /// \return The number of verts that were transformed.
1002 static GLSGEN_GlsGeometryResource_EXPORT unsigned int TransformVertexData(
1003 GlsGeometry_Generic* dstGeom,
1004 GlsMatrixType* transform,
1005 unsigned int vertexOffset = 0,
1006 unsigned int vertexCount = UINT_MAX );
1007
1008 /// Generate tangents/binormals for all vertices in the given
1009 /// GlsGeometryResource and adds them as vertex attributes.
1010 /// \param geom The vertices to generate from.
1011 /// \return Whether or not the generation was successful.
1012 static GLSGEN_GlsGeometryResource_EXPORT bool GenerateTangentsAndBinormals( GlsGeometry_Generic* geom );
1013
1014 /// \details The VertexStructureDefinition struct. Contains stride and attribute information associated with a vertex buffer object.
1015 typedef struct
1016 {
1017 unsigned int _size; ///< Total size of each vertex in bytes (depends on which data is included).
1018
1019 unsigned int _normalStride; ///< Offset between each normal in bytes.
1020 unsigned int _texcoordStride; ///< Offset between each texture coordinate in bytes.
1021 unsigned int _texcoord2Stride; ///< Offset between each secondary texture coordinate in bytes.
1022 unsigned int _colorStride; ///< Offset between each color in bytes.
1023 unsigned int _secondaryColorStride; ///< Offset between each secondary color in bytes.
1024 unsigned int _numVertexAttribs; ///< The count of vertex attributes.
1025 unsigned int _vertexAttribStride[ MAX_VERTEX_ATTRIBS ]; ///< A list of offsets in bytes for each vertex attribute.
1026 unsigned int _vertexAttribSize[ MAX_VERTEX_ATTRIBS ]; ///< The size of each vertex attribute in bytes.
1027 } VertexStructureDefinition;
1028
1029 /// Return the appropriate VertexStructureDefinition type derived from the incoming TypeDesc.
1030 /// \param vertStruct The returned vertex structure.
1031 /// \param type The type to generate a vertex structure definiton for.
1032 static GLSGEN_GlsGeometryResource_EXPORT void SetVertexStructureFromTypeDesc( VertexStructureDefinition& vertStruct, const TypeDesc& type );
1033
1034 protected:
1035 bool _bufferLock; ///< Flag indicating that the vertex buffer is being written to.
1036
1037 char* _vertexBuffer; ///< Underlying storage for vertices.
1038 unsigned int _vertexBufferCount; ///< The number of vertices in the buffer.
1039 GLuint _vertexBufferID; ///< The OpenGL index for this vertex buffer object.
1040 bool _vertexBufferUpdated; ///< Is the video card vertex buffer up to date?
1041
1042 /** Index buffers array */
1043 GlsGeometry_Generic_IndexBufferData* _indexBuffers;
1044
1045 VertexStructureDefinition _structure; ///< Describes the internal storage pattern for vertices, i.e. does it have colors? textures? normals?
1046
1047 /// Copies vertex data from this buffer into the incoming geometry object.
1048 /// \param rhs The object to copy vertex data into.
1049 GLSGEN_GlsGeometryResource_EXPORT void CopyVertexBufferOnly( GlsGeometry_Generic* rhs );
1050
1051 /** Utility routine used by Hit. Performs a "BestHit" test, which performs a hit test on the object
1052 * and guarantees that the collision point returned by Hit is the closest collision point to the observer.
1053 * @param point The geometry coordinate of the click, relative to the object
1054 * @param directionVector The direction of the pick vector
1055 * @param collisionPoint Set to the point on the object hit by directionVector
1056 * @return booleanean indicating if the object was hit by the mouse
1057 */
1058 GLSGEN_GlsGeometryResource_EXPORT bool BestHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
1059
1060 /** Utility routine used by Hit. Performs a "FirstHit" test, which performs a hit test on the object
1061 * but does not guarantee that the collision point returned by Hit is the closest collision point
1062 * to the observer
1063 * @param point The logical coordinate of the click, relative to the object
1064 * @param directionVector The direction of the pick vector
1065 * @param collisionPoint Set to the point on the object hit by directionVector
1066 * @return boolean indicating if the object was hit
1067 */
1068 GLSGEN_GlsGeometryResource_EXPORT bool FirstHit( const Vector& point, const Vector& directionVector, Vector& collisionPoint );
1069
1070 /// Shared initialization code used by all constructors.
1071 void InitializeMembers();
1072
1073 /// Initialize this object from the incoming binary resource.
1074 /// \param resource The binary resource to initialize with.
1075 void InitFromBinaryResource( GlsResourceFileMgr::BinaryResource* resource );
1076
1077 /// \return The offset in bytes for the given texture index.
1078 /// \param whichTexture The texture index to locate.
1079 unsigned int GetTexcoordByteOffset( unsigned int whichTexture );
1080
1081 GLSGEN_GlsGeometryResource_EXPORT void Destroy() DISTI_METHOD_OVERRIDE;
1082
1083private:
1084 // Member data
1085 unsigned int _dataChangedCounter;
1086
1087 /** Should be called when any data changes. Used to optimize calls like GetExtents(). */
1088 void IncDataChangedCounter()
1089 {
1090 // If we hit the invalid ID, skip past it.
1091 if( ++_dataChangedCounter == s_invalidDataChangedCounter )
1092 {
1093 ++_dataChangedCounter;
1094 }
1095 }
1096
1097 /** Private Constructor: Use CreateInstance methods */
1098 GLSGEN_GlsGeometryResource_EXPORT GlsGeometry_Generic();
1099
1100 /** Private Destructor: Use DecrementReference to delete the object*/
1101 GLSGEN_GlsGeometryResource_EXPORT ~GlsGeometry_Generic();
1102
1103 // Disable implicit generated Members
1104 GlsGeometry_Generic( const GlsGeometry_Generic& src );
1105 GlsGeometry_Generic& operator=( const GlsGeometry_Generic& rhs );
1106};
1107
1108} // namespace disti
1109
1110#endif
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsGeometryResource::Observer
Definition: gls_geometry_resource.h:295
disti::GlsGeometryResource::Observer::OnGeometryResourceChanged
virtual void OnGeometryResourceChanged()=0
Callback method to be called by this observer.
disti::GlsGeometryResource::TypeDesc
Definition: gls_geometry_resource.h:103
disti::GlsGeometryResource::TypeDesc::SetVertexAttribComponents
void SetVertexAttribComponents(unsigned char which, GLint value)
Definition: gls_geometry_resource.h:227
disti::GlsGeometryResource::TypeDesc::HasColor
bool HasColor() const
Definition: gls_geometry_resource.h:170
disti::GlsGeometryResource::TypeDesc::GetVertexAttribSemantic
int GetVertexAttribSemantic(unsigned char which) const
Definition: gls_geometry_resource.h:281
disti::GlsGeometryResource::TypeDesc::HasNormal
bool HasNormal() const
Definition: gls_geometry_resource.h:144
disti::GlsGeometryResource::TypeDesc::SetVertexAttribType
void SetVertexAttribType(unsigned char which, GLenum value)
Definition: gls_geometry_resource.h:241
disti::GlsGeometryResource::TypeDesc::GetTexCoordDimension
unsigned char GetTexCoordDimension(unsigned char which) const
Definition: gls_geometry_resource.h:205
disti::GlsGeometryResource::TypeDesc::SetNumVertexAttribs
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:214
disti::GlsGeometryResource::TypeDesc::HasSecondaryColor
void HasSecondaryColor(bool value)
Definition: gls_geometry_resource.h:174
disti::GlsGeometryResource::TypeDesc::SetVertexAttribNormalize
void SetVertexAttribNormalize(unsigned char which, GLboolean value)
Definition: gls_geometry_resource.h:257
disti::GlsGeometryResource::TypeDesc::TexCoordType
unsigned int TexCoordType() const
Definition: gls_geometry_resource.h:162
disti::GlsGeometryResource::TypeDesc::GetVertexAttribType
GLenum GetVertexAttribType(unsigned char which) const
Definition: gls_geometry_resource.h:251
disti::GlsGeometryResource::TypeDesc::SetVertexAttribSemantic
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:273
disti::GlsGeometryResource::TypeDesc::GetVertexAttribNormalize
GLboolean GetVertexAttribNormalize(unsigned char which) const
Definition: gls_geometry_resource.h:267
disti::GlsGeometryResource::TypeDesc::NormalType
unsigned int NormalType() const
Definition: gls_geometry_resource.h:155
disti::GlsGeometryResource::TypeDesc::HasColor
void HasColor(bool value)
Definition: gls_geometry_resource.h:167
disti::GlsGeometryResource::TypeDesc::GetVertexAttribComponents
GLint GetVertexAttribComponents(unsigned char which) const
Definition: gls_geometry_resource.h:235
disti::GlsGeometryResource::TypeDesc::NormalType
void NormalType(unsigned int value)
Definition: gls_geometry_resource.h:149
disti::GlsGeometryResource::TypeDesc::HasNormal
void HasNormal(bool value)
Definition: gls_geometry_resource.h:141
disti::GlsGeometryResource::TypeDesc::GetNumTextureCoords
unsigned char GetNumTextureCoords() const
Definition: gls_geometry_resource.h:190
disti::GlsGeometryResource::TypeDesc::GetNumVertexAttribs
unsigned char GetNumVertexAttribs() const
Definition: gls_geometry_resource.h:221
disti::GlsGeometryResource::TypeDesc::TexCoordType
void TexCoordType(unsigned int value)
Definition: gls_geometry_resource.h:159
disti::GlsGeometryResource::TypeDesc::SetTexCoordDimension
void SetTexCoordDimension(unsigned char which, unsigned char value)
Definition: gls_geometry_resource.h:195
disti::GlsGeometryResource::TypeDesc::HasSecondaryColor
bool HasSecondaryColor() const
Definition: gls_geometry_resource.h:177
disti::GlsGeometryResource::TypeDesc::SetNumTextureCoords
void SetNumTextureCoords(unsigned char value)
Definition: gls_geometry_resource.h:181
disti::GlsGeometryResource
Definition: gls_geometry_resource.h:87
disti::GlsGeometryResource::VERTEX_ATTRIBUTE_SIZE
static const unsigned int VERTEX_ATTRIBUTE_SIZE
Size of vertex storage, in bytes.
Definition: gls_geometry_resource.h:92
disti::GlsGeometryResource::OnGeometryResourceChanged
void OnGeometryResourceChanged()
Called to call all observer callbacks when the attribute changes.
Definition: gls_geometry_resource.h:328
disti::GlsGeometryResource::_observers
DynamicArray< Observer * > _observers
The held list of observers w/ callbacks.
Definition: gls_geometry_resource.h:325
disti::GlsGeometryResource::GetResourceId
unsigned int GetResourceId()
Definition: gls_geometry_resource.h:501
disti::GlsGeometryResource::GetExtents
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
disti::GlsGeometryResource::_numIndexBuffers
unsigned int _numIndexBuffers
Definition: gls_geometry_resource.h:346
disti::GlsGeometryResource::StatsIndexBufferPolygonCount
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)=0
disti::GlsGeometryResource::TANGENT_ATTRIBUTE_SIZE
static const unsigned int TANGENT_ATTRIBUTE_SIZE
Size of tangent storage, in bytes.
Definition: gls_geometry_resource.h:98
disti::GlsGeometryResource::Type
const TypeDesc & Type()
Definition: gls_geometry_resource.h:457
disti::GlsGeometryResource::NORMAL_ATTRIBUTE_SIZE
static const unsigned int NORMAL_ATTRIBUTE_SIZE
Size of normal storage, in bytes.
Definition: gls_geometry_resource.h:93
disti::GlsGeometryResource::_boundingVolumeRadius
float _boundingVolumeRadius
Radius of the bounding volume.
Definition: gls_geometry_resource.h:349
disti::GlsGeometryResource::DecrementReference
void DecrementReference()
Definition: gls_geometry_resource.h:465
disti::GlsGeometryResource::StatsIndexBufferVertexCount
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)=0
disti::GlsGeometryResource::GetDataChangedCounter
virtual unsigned int GetDataChangedCounter() const =0
disti::GlsGeometryResource::RemoveObserver
void RemoveObserver(Observer *observer)
Definition: gls_geometry_resource.h:319
disti::GlsGeometryResource::TEXTURE_COORDINATE_ATTRIBUTE_SIZE
static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE
Size of texture coordinate storage, in bytes.
Definition: gls_geometry_resource.h:97
disti::GlsGeometryResource::SetResourceId
void SetResourceId(unsigned int id)
Definition: gls_geometry_resource.h:493
disti::GlsGeometryResource::BoundingVolumeHit
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)=0
disti::GlsGeometryResource::AddObserver
void AddObserver(Observer *observer)
Definition: gls_geometry_resource.h:312
disti::GlsGeometryResource::HitTest
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
disti::GlsGeometryResource::Destroy
virtual void Destroy()=0
disti::GlsGeometryResource::IncrementReference
void IncrementReference()
Definition: gls_geometry_resource.h:460
disti::GlsGeometryResource::_boundingVolumeCenter
Vector _boundingVolumeCenter
Center location of the bounding volume.
Definition: gls_geometry_resource.h:348
disti::GlsGeometryResource::s_invalidDataChangedCounter
static const unsigned int s_invalidDataChangedCounter
Definition: gls_geometry_resource.h:412
disti::GlsGeometryResource::MAX_TEXTURE_COORDS
static const unsigned int MAX_TEXTURE_COORDS
GL_MAX_TEXTURE_COORDS. GlsGeometryResource currently only supports two sets of texture coordinates.
Definition: gls_geometry_resource.h:89
disti::GlsGeometryResource::CreateInstance
static GlsGeometryResource * CreateInstance(const TypeDesc &type=GlsGeometryResource::TypeDesc())
disti::GlsGeometryResource::DrawSetup
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
disti::GlsGeometryResource::NumIndexBuffers
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:478
disti::GlsGeometryResource::DrawCleanup
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram)=0
disti::GlsGeometryResource::FreeOpenGLBuffers
virtual void FreeOpenGLBuffers()=0
disti::GlsGeometryResource::_enableVBO
static bool _enableVBO
If true, OpenGL supports vertex buffer objects (1.5 or greater).
Definition: gls_geometry_resource.h:352
disti::GlsGeometryResource::UpdateBoundingVolume
virtual void UpdateBoundingVolume()=0
disti::GlsGeometryResource::_type
TypeDesc _type
Definition: gls_geometry_resource.h:343
disti::GlsGeometryResource::BadId
BadId
Definition: gls_geometry_resource.h:287
disti::GlsGeometryResource::DrawIndexBuffer
virtual void DrawIndexBuffer(unsigned int bufferNumber)=0
disti::GlsGeometryResource::_resourceID
unsigned int _resourceID
Definition: gls_geometry_resource.h:337
disti::GlsGeometryResource::MAX_VERTEX_ATTRIBS
static const unsigned int MAX_VERTEX_ATTRIBS
GL_MAX_VERTEX_ATTRIBS.
Definition: gls_geometry_resource.h:90
disti::GlsGeometryResource::SECONDARY_COLOR_ATTRIBUTE_SIZE
static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE
Size of secondary color storage, in bytes.
Definition: gls_geometry_resource.h:96
disti::GlsGeometryResource::COLOR_ATTRIBUTE_SIZE
static const unsigned int COLOR_ATTRIBUTE_SIZE
Size of color storage, in bytes.
Definition: gls_geometry_resource.h:94
disti::GlsGeometryResource::BoundingVolumeCenter
const Vector & BoundingVolumeCenter() const
Definition: gls_geometry_resource.h:484
disti::GlsGeometryResource::_referenceCount
unsigned int _referenceCount
Definition: gls_geometry_resource.h:340
disti::GlsGeometryResource::SetCreateInstanceMakesHalfFloat
static void SetCreateInstanceMakesHalfFloat(bool value)
disti::GlsGeometryResource::BINORMAL_ATTRIBUTE_SIZE
static const unsigned int BINORMAL_ATTRIBUTE_SIZE
Size of binormal storage, in bytes.
Definition: gls_geometry_resource.h:99
disti::GlsGeometryResource::BoundingVolumeRadius
float BoundingVolumeRadius() const
Definition: gls_geometry_resource.h:487
disti::GlsGeometry_Generic
Definition: gls_geometry_resource.h:514
disti::GlsGeometry_Generic::SetColor
void SetColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
disti::GlsGeometry_Generic::GetIndexBufferSize
unsigned int GetIndexBufferSize(unsigned int bufferNum) const
disti::GlsGeometry_Generic::InitializeMembers
void InitializeMembers()
Shared initialization code used by all constructors.
disti::GlsGeometry_Generic::StatsIndexBufferPolygonCount
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:527
disti::GlsGeometry_Generic::DrawCleanup
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::SetIndices
void SetIndices(unsigned int bufferNum, const unsigned int *indexArray, unsigned int numIndices, unsigned int startIndex=0, unsigned int stride=sizeof(unsigned int))
disti::GlsGeometry_Generic::SetIndex
void SetIndex(unsigned int bufferNum, unsigned int index, unsigned int indexValue)
disti::GlsGeometry_Generic::_vertexBufferID
GLuint _vertexBufferID
The OpenGL index for this vertex buffer object.
Definition: gls_geometry_resource.h:1039
disti::GlsGeometry_Generic::_structure
VertexStructureDefinition _structure
Describes the internal storage pattern for vertices, i.e. does it have colors? textures?...
Definition: gls_geometry_resource.h:1045
disti::GlsGeometry_Generic::SetVertexAttrib4fv
void SetVertexAttrib4fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:834
disti::GlsGeometry_Generic::TransformVertexData
static unsigned int TransformVertexData(GlsGeometry_Generic *dstGeom, GlsMatrixType *transform, unsigned int vertexOffset=0, unsigned int vertexCount=UINT_MAX)
disti::GlsGeometry_Generic::DumpVertices
void DumpVertices()
disti::GlsGeometry_Generic::BestHit
bool BestHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
disti::GlsGeometry_Generic::DrawIndexBuffer
virtual void DrawIndexBuffer(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::GenerateTangentsAndBinormals
static bool GenerateTangentsAndBinormals(GlsGeometry_Generic *geom)
disti::GlsGeometry_Generic::SetNormal
void SetNormal(GLuint vertIndex, float x, float y, float z)
disti::GlsGeometry_Generic::GetColor
unsigned char * GetColor(GLuint vertIndex)
disti::GlsGeometry_Generic::ChangeType
void ChangeType(const TypeDesc &type)
disti::GlsGeometry_Generic::GetSecondaryColor
unsigned char * GetSecondaryColor(GLuint vertIndex)
disti::GlsGeometry_Generic::HitTest
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::SetVertexAttrib1fv
void SetVertexAttrib1fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:816
disti::GlsGeometry_Generic::CopyVertexBufferOnly
void CopyVertexBufferOnly(GlsGeometry_Generic *rhs)
disti::GlsGeometry_Generic::GetIndex
unsigned short GetIndex(unsigned int bufferNum, unsigned short index)
disti::GlsGeometry_Generic::LockBuffers
bool LockBuffers()
disti::GlsGeometry_Generic::SetVertexAttribs
void SetVertexAttribs(const float *attribArray, GLuint attribIndex, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TANGENT_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::GetDataChangedCounter
virtual unsigned int GetDataChangedCounter() const DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::GetNormal
const float * GetNormal(GLuint vertIndex)
disti::GlsGeometry_Generic::GetVertex
const float * GetVertex(GLuint vertIndex)
disti::GlsGeometry_Generic::SetVertices
void SetVertices(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=VERTEX_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::VertexSort
void VertexSort(VertexSortData *sortData)
disti::GlsGeometry_Generic::SetVertex
void SetVertex(GLuint vertIndex, const Vector *value)
Definition: gls_geometry_resource.h:617
disti::GlsGeometry_Generic::_vertexBuffer
char * _vertexBuffer
Underlying storage for vertices.
Definition: gls_geometry_resource.h:1037
disti::GlsGeometry_Generic::FirstHit
bool FirstHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
disti::GlsGeometry_Generic::SetVertex
void SetVertex(GLuint vertIndex, const float *value)
disti::GlsGeometry_Generic::GetVertexAttrib
void * GetVertexAttrib(GLuint vertIndex, GLuint attribIndex)
disti::GlsGeometry_Generic::SetColors
void SetColors(const unsigned int *rgbaArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=COLOR_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::SetSecondaryColors
void SetSecondaryColors(const unsigned int *rgbArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=SECONDARY_COLOR_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::GetExtents
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::CreateInstance
static GlsGeometry_Generic * CreateInstance(const TypeDesc &type)
disti::GlsGeometry_Generic::CopyVertexData
static unsigned int CopyVertexData(GlsGeometry_Generic *dstGeom, unsigned int dstOffset, GlsGeometry_Generic *srcGeom, unsigned int srcOffset, unsigned int vertexCount)
disti::GlsGeometry_Generic::_vertexBufferCount
unsigned int _vertexBufferCount
The number of vertices in the buffer.
Definition: gls_geometry_resource.h:1038
disti::GlsGeometry_Generic::GetTextureCoord
const float * GetTextureCoord(GLuint vertIndex, unsigned int whichTexture)
disti::GlsGeometry_Generic::SetVertexStructureFromTypeDesc
static void SetVertexStructureFromTypeDesc(VertexStructureDefinition &vertStruct, const TypeDesc &type)
disti::GlsGeometry_Generic::NumIndexBuffers
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:478
disti::GlsGeometry_Generic::BoundingVolumeHit
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::DumpIndices
void DumpIndices()
disti::GlsGeometry_Generic::SetTextureCoord
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
disti::GlsGeometry_Generic::InitFromBinaryResource
void InitFromBinaryResource(GlsResourceFileMgr::BinaryResource *resource)
disti::GlsGeometry_Generic::SetVertexAttrib3fv
void SetVertexAttrib3fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:828
disti::GlsGeometry_Generic::StatsIndexBufferVertexCount
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:522
disti::GlsGeometry_Generic::CreateEmptyInstance
static GlsGeometry_Generic * CreateEmptyInstance()
disti::GlsGeometry_Generic::SetIndexBufferSize
void SetIndexBufferSize(unsigned int bufferNum, unsigned int newSize)
disti::GlsGeometry_Generic::_vertexBufferUpdated
bool _vertexBufferUpdated
Is the video card vertex buffer up to date?
Definition: gls_geometry_resource.h:1040
disti::GlsGeometry_Generic::SetVertexAttrib2fv
void SetVertexAttrib2fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:822
disti::GlsGeometry_Generic::SetSecondaryColor
void SetSecondaryColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
disti::GlsGeometry_Generic::DumpNormals
void DumpNormals()
disti::GlsGeometry_Generic::_indexBuffers
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:1043
disti::GlsGeometry_Generic::SetNormals
void SetNormals(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=NORMAL_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::FreeOpenGLBuffers
virtual void FreeOpenGLBuffers() DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::Destroy
void Destroy() DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::UpdateBoundingVolume
virtual void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::DrawSetup
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
disti::GlsGeometry_Generic::CopyVertexAndIndexBuffers
void CopyVertexAndIndexBuffers(GlsGeometry_Generic *rhs)
disti::GlsGeometry_Generic::_bufferLock
bool _bufferLock
Flag indicating that the vertex buffer is being written to.
Definition: gls_geometry_resource.h:1035
disti::GlsGeometry_Generic::StoreVertexAttrib
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
disti::GlsGeometry_Generic::GetTexcoordByteOffset
unsigned int GetTexcoordByteOffset(unsigned int whichTexture)
disti::GlsGeometry_Generic::SetTextureCoords
void SetTextureCoords(unsigned int whichTexture, const float *textureCoordArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=TEXTURE_COORDINATE_ATTRIBUTE_SIZE)
disti::GlsGeometry_Generic::CreateFromBinaryResource
static GlsGeometry_Generic * CreateFromBinaryResource(GlsResourceFileMgr::BinaryResource *data)
disti::GlsGeometry_Generic::VertexCount
unsigned int VertexCount() const
disti::GlsGeometry_Generic::UnlockBuffers
void UnlockBuffers()
disti::GlsMatrixAffine< double >
disti::GlsResourceFileMgr::BinaryResource
Definition: gls_resource_file_mgr.h:35
disti::GlsResourceFileMgr::ResourceRef
Definition: gls_resource_file_mgr.h:57
disti::GlsResourceFileMgr
Definition: gls_resource_file_mgr.h:26
disti::VertexAttribIndexLookup
Definition: gls_render_effect.h:79
disti::VertexNoColor
Definition: vertex.h:85
disti_assert.h
Contains the DistiAssert macro.
GLS_ASSERT
#define GLS_ASSERT(exp)
Definition: disti_assert.h:150
DISTI_SPECIAL_MEM_FUN_DELETE
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:246
DISTI_METHOD_OVERRIDE
#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
gls_gl.h
The gls_gl.
gls_matrix_affine.h
The GlsMatrixAffine class.
gls_render_effect.h
The disti::GlsRenderEffect class.
disti
Definition: bmpimage.h:47
disti::GlsGeometry_Generic::VertexSortData
Definition: gls_geometry_resource.h:946
disti::GlsGeometry_Generic::VertexSortData::_order
unsigned int _order
The order the vertex should be in.
Definition: gls_geometry_resource.h:947
disti::GlsGeometry_Generic::VertexSortData::_vertexTupleIndex
unsigned int _vertexTupleIndex
The index of the primitive.
Definition: gls_geometry_resource.h:948
disti::GlsGeometry_Generic::VertexStructureDefinition
Definition: gls_geometry_resource.h:1016
disti::GlsGeometry_Generic::VertexStructureDefinition::_texcoordStride
unsigned int _texcoordStride
Offset between each texture coordinate in bytes.
Definition: gls_geometry_resource.h:1020
disti::GlsGeometry_Generic::VertexStructureDefinition::_texcoord2Stride
unsigned int _texcoord2Stride
Offset between each secondary texture coordinate in bytes.
Definition: gls_geometry_resource.h:1021
disti::GlsGeometry_Generic::VertexStructureDefinition::_numVertexAttribs
unsigned int _numVertexAttribs
The count of vertex attributes.
Definition: gls_geometry_resource.h:1024
disti::GlsGeometry_Generic::VertexStructureDefinition::_size
unsigned int _size
Total size of each vertex in bytes (depends on which data is included).
Definition: gls_geometry_resource.h:1017
disti::GlsGeometry_Generic::VertexStructureDefinition::_colorStride
unsigned int _colorStride
Offset between each color in bytes.
Definition: gls_geometry_resource.h:1022
disti::GlsGeometry_Generic::VertexStructureDefinition::_normalStride
unsigned int _normalStride
Offset between each normal in bytes.
Definition: gls_geometry_resource.h:1019
disti::GlsGeometry_Generic::VertexStructureDefinition::_secondaryColorStride
unsigned int _secondaryColorStride
Offset between each secondary color in bytes.
Definition: gls_geometry_resource.h:1023
vertex.h
The disti::Vertex class. A class for manipulating 3D vertices.