39#ifndef GLS_GEOMETRY_RESOURCE_H_INCLUDED
40#define GLS_GEOMETRY_RESOURCE_H_INCLUDED
57# include <OpenGL/gl.h>
70#if( defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLSGEN_IMPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
71 && defined( _MSC_VER )
72# if defined( GLSGEN_EXPORT_GLSGEOMETRYRESOURCE ) || defined( GLS_EXPORT_GENERATED )
73# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllexport )
75# define GLSGEN_GlsGeometryResource_EXPORT __declspec( dllimport )
78# define GLSGEN_GlsGeometryResource_EXPORT
105 bool hasSecondaryColor;
107 unsigned int normalType;
108 unsigned int texCoordType;
111 unsigned char numTextureCoords;
113 unsigned char numVertexAttribs;
122 memset(
this, 0,
sizeof(
TypeDesc ) );
126 texCoordDimension[ i ] = 2;
130 vertexAttribNumComponents[ i ] = 4;
133 normalType = GL_FLOAT;
134 texCoordType = GL_FLOAT;
148 void NormalType(
unsigned int value )
154 unsigned int NormalType()
const {
return normalType; }
158 void TexCoordType(
unsigned int value ) { texCoordType = value; }
161 unsigned int TexCoordType()
const {
return texCoordType; }
184 numTextureCoords = value;
196 if( which < GlsGeometryResource::MAX_TEXTURE_COORDS && value > 0 && value < 5 )
198 texCoordDimension[ which ] = value;
216 numVertexAttribs = value;
228 if( which < GlsGeometryResource::MAX_VERTEX_ATTRIBS && value > 0 && value < 5 )
229 vertexAttribNumComponents[ which ] = value;
244 vertexAttribType[ which ] = value;
260 vertexAttribNormalize[ which ] = value;
275 vertexAttribSemantic[ which ] = semanticEnum;
329 for(
unsigned int i = 0; i <
_observers.Count(); ++i )
445 virtual bool HitTest(
unsigned char pickType,
const Vector& pickLinePoint,
const Vector& pickLineDirection,
Vector& collisionPoint ) = 0;
494 assert( BAD_ID !=
id );
508class GlsGeometry_Generic_IndexBufferData;
629 unsigned int numVertices,
630 unsigned int startVertIndex = 0,
674 unsigned int numVertices,
675 unsigned int startVertIndex = 0,
698 unsigned char alpha );
710 unsigned int numVertices,
711 unsigned int startVertIndex = 0,
737 unsigned char blue );
749 unsigned int numVertices,
750 unsigned int startVertIndex = 0,
787 const float* textureCoordArray,
788 unsigned int numVertices,
789 unsigned int startVertIndex = 0,
844 unsigned int numVertices,
845 unsigned int startVertIndex = 0,
896 const unsigned int* indexArray,
897 unsigned int numIndices,
898 unsigned int startIndex = 0,
899 unsigned int stride =
sizeof(
unsigned int ) );
928 const unsigned int* indexArray,
929 unsigned int numIndices,
930 unsigned int startIndex = 0,
931 unsigned int stride =
sizeof(
unsigned int ) );
992 unsigned int vertexCount );
1004 unsigned int vertexOffset = 0,
1005 unsigned int vertexCount = UINT_MAX );
1084 unsigned int _dataChangedCounter;
1087 void IncDataChangedCounter()
1092 ++_dataChangedCounter;
Definition: dynamic_array.h:79
Definition: gls_geometry_resource.h:294
virtual void OnGeometryResourceChanged()=0
Callback method to be called by this observer.
Definition: gls_geometry_resource.h:102
void SetVertexAttribComponents(unsigned char which, GLint value)
Definition: gls_geometry_resource.h:226
bool HasColor() const
Definition: gls_geometry_resource.h:169
int GetVertexAttribSemantic(unsigned char which) const
Definition: gls_geometry_resource.h:280
bool HasNormal() const
Definition: gls_geometry_resource.h:143
void SetVertexAttribType(unsigned char which, GLenum value)
Definition: gls_geometry_resource.h:240
unsigned char GetTexCoordDimension(unsigned char which) const
Definition: gls_geometry_resource.h:204
void SetNumVertexAttribs(unsigned char value)
Definition: gls_geometry_resource.h:213
void HasSecondaryColor(bool value)
Definition: gls_geometry_resource.h:173
void SetVertexAttribNormalize(unsigned char which, GLboolean value)
Definition: gls_geometry_resource.h:256
GLenum GetVertexAttribType(unsigned char which) const
Definition: gls_geometry_resource.h:250
void SetVertexAttribSemantic(unsigned char which, int semanticEnum)
Definition: gls_geometry_resource.h:272
GLboolean GetVertexAttribNormalize(unsigned char which) const
Definition: gls_geometry_resource.h:266
void HasColor(bool value)
Definition: gls_geometry_resource.h:166
GLint GetVertexAttribComponents(unsigned char which) const
Definition: gls_geometry_resource.h:234
void HasNormal(bool value)
Definition: gls_geometry_resource.h:140
unsigned char GetNumTextureCoords() const
Definition: gls_geometry_resource.h:189
unsigned char GetNumVertexAttribs() const
Definition: gls_geometry_resource.h:220
void SetTexCoordDimension(unsigned char which, unsigned char value)
Definition: gls_geometry_resource.h:194
bool HasSecondaryColor() const
Definition: gls_geometry_resource.h:176
void SetNumTextureCoords(unsigned char value)
Definition: gls_geometry_resource.h:180
Definition: gls_geometry_resource.h:86
static const unsigned int VERTEX_ATTRIBUTE_SIZE
Size of vertex storage, in bytes.
Definition: gls_geometry_resource.h:91
void OnGeometryResourceChanged()
Called to call all observer callbacks when the attribute changes.
Definition: gls_geometry_resource.h:327
DynamicArray< Observer * > _observers
The held list of observers w/ callbacks.
Definition: gls_geometry_resource.h:324
unsigned int GetResourceId()
Definition: gls_geometry_resource.h:500
virtual void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL)=0
unsigned int _numIndexBuffers
Definition: gls_geometry_resource.h:345
virtual unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber)=0
static const unsigned int TANGENT_ATTRIBUTE_SIZE
Size of tangent storage, in bytes.
Definition: gls_geometry_resource.h:97
const TypeDesc & Type()
Definition: gls_geometry_resource.h:456
static const unsigned int NORMAL_ATTRIBUTE_SIZE
Size of normal storage, in bytes.
Definition: gls_geometry_resource.h:92
float _boundingVolumeRadius
Radius of the bounding volume.
Definition: gls_geometry_resource.h:348
void DecrementReference()
Definition: gls_geometry_resource.h:464
virtual unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber)=0
virtual unsigned int GetDataChangedCounter() const =0
void RemoveObserver(Observer *observer)
Definition: gls_geometry_resource.h:318
static const unsigned int TEXTURE_COORDINATE_ATTRIBUTE_SIZE
Size of texture coordinate storage, in bytes.
Definition: gls_geometry_resource.h:96
void SetResourceId(unsigned int id)
Definition: gls_geometry_resource.h:492
virtual bool BoundingVolumeHit(const Vector &point, const Vector &direction)=0
void AddObserver(Observer *observer)
Definition: gls_geometry_resource.h:311
virtual bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint)=0
void IncrementReference()
Definition: gls_geometry_resource.h:459
Vector _boundingVolumeCenter
Center location of the bounding volume.
Definition: gls_geometry_resource.h:347
static const unsigned int s_invalidDataChangedCounter
Definition: gls_geometry_resource.h:411
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:88
static GlsGeometryResource * CreateInstance(const TypeDesc &type=GlsGeometryResource::TypeDesc())
virtual void DrawSetup(VertexAttribIndexLookup *shaderProgram)=0
unsigned int NumIndexBuffers() const
Definition: gls_geometry_resource.h:477
virtual void DrawCleanup(VertexAttribIndexLookup *shaderProgram)=0
virtual void FreeOpenGLBuffers()=0
static bool _enableVBO
If true, OpenGL supports vertex buffer objects (1.5 or greater).
Definition: gls_geometry_resource.h:351
virtual void UpdateBoundingVolume()=0
TypeDesc _type
Definition: gls_geometry_resource.h:342
BadId
Definition: gls_geometry_resource.h:286
virtual void DrawIndexBuffer(unsigned int bufferNumber)=0
unsigned int _resourceID
Definition: gls_geometry_resource.h:336
static const unsigned int MAX_VERTEX_ATTRIBS
GL_MAX_VERTEX_ATTRIBS.
Definition: gls_geometry_resource.h:89
static const unsigned int SECONDARY_COLOR_ATTRIBUTE_SIZE
Size of secondary color storage, in bytes.
Definition: gls_geometry_resource.h:95
static const unsigned int COLOR_ATTRIBUTE_SIZE
Size of color storage, in bytes.
Definition: gls_geometry_resource.h:93
static GlsGeometryResource * CreateInstance(GlsResourceFileMgr::ResourceRef *resource)
const Vector & BoundingVolumeCenter() const
Definition: gls_geometry_resource.h:483
unsigned int _referenceCount
Definition: gls_geometry_resource.h:339
static void SetCreateInstanceMakesHalfFloat(bool value)
static const unsigned int BINORMAL_ATTRIBUTE_SIZE
Size of binormal storage, in bytes.
Definition: gls_geometry_resource.h:98
float BoundingVolumeRadius() const
Definition: gls_geometry_resource.h:486
Definition: gls_geometry_resource.h:513
void SetColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
void NumIndexBuffers(unsigned int count)
unsigned int GetIndexBufferSize(unsigned int bufferNum) const
void InitializeMembers()
Shared initialization code used by all constructors.
void SetIndices(unsigned int bufferNum, const unsigned int *indexArray, unsigned int numIndices, unsigned int startIndex=0, unsigned int stride=sizeof(unsigned int))
unsigned int StatsIndexBufferVertexCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:521
void SetIndex(unsigned int bufferNum, unsigned int index, unsigned int indexValue)
GLuint _vertexBufferID
The OpenGL index for this vertex buffer object.
Definition: gls_geometry_resource.h:1038
VertexStructureDefinition _structure
Describes the internal storage pattern for vertices, i.e. does it have colors? textures?...
Definition: gls_geometry_resource.h:1044
void SetVertexAttrib4fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:833
static unsigned int TransformVertexData(GlsGeometry_Generic *dstGeom, GlsMatrixType *transform, unsigned int vertexOffset=0, unsigned int vertexCount=UINT_MAX)
bool BestHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
void DrawSetup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
void MergeIndexBuffers(unsigned int dstBufferNum, unsigned int srcBufferNum)
void FreeOpenGLBuffers() DISTI_METHOD_OVERRIDE
bool BoundingVolumeHit(const Vector &point, const Vector &direction) DISTI_METHOD_OVERRIDE
static bool GenerateTangentsAndBinormals(GlsGeometry_Generic *geom)
void SetNormal(GLuint vertIndex, float x, float y, float z)
unsigned char * GetColor(GLuint vertIndex)
void ChangeType(const TypeDesc &type)
unsigned char * GetSecondaryColor(GLuint vertIndex)
void SetVertexAttrib1fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:815
void CopyVertexBufferOnly(GlsGeometry_Generic *rhs)
void DrawCleanup(VertexAttribIndexLookup *shaderProgram) DISTI_METHOD_OVERRIDE
const float * GetNormal(GLuint vertIndex)
const float * GetVertex(GLuint vertIndex)
void SetVertices(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=VERTEX_ATTRIBUTE_SIZE)
void VertexSort(VertexSortData *sortData)
void SetVertex(GLuint vertIndex, const Vector *value)
Definition: gls_geometry_resource.h:616
char * _vertexBuffer
Underlying storage for vertices.
Definition: gls_geometry_resource.h:1036
bool FirstHit(const Vector &point, const Vector &directionVector, Vector &collisionPoint)
void GetExtents(Vector &min, Vector &max, const GlsMatrixType *matrix=NULL) DISTI_METHOD_OVERRIDE
void SetVertex(GLuint vertIndex, const float *value)
void DrawIndexBuffer(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
void * GetVertexAttrib(GLuint vertIndex, GLuint attribIndex)
void SetColors(const unsigned int *rgbaArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=COLOR_ATTRIBUTE_SIZE)
void SetSecondaryColors(const unsigned int *rgbArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=SECONDARY_COLOR_ATTRIBUTE_SIZE)
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, float textureCoordU, float textureCoordV)
static GlsGeometry_Generic * CreateInstance(const TypeDesc &type)
static unsigned int CopyVertexData(GlsGeometry_Generic *dstGeom, unsigned int dstOffset, GlsGeometry_Generic *srcGeom, unsigned int srcOffset, unsigned int vertexCount)
unsigned int _vertexBufferCount
The number of vertices in the buffer.
Definition: gls_geometry_resource.h:1037
const float * GetTextureCoord(GLuint vertIndex, unsigned int whichTexture)
static void SetVertexStructureFromTypeDesc(VertexStructureDefinition &vertStruct, const TypeDesc &type)
void SetTextureCoord(GLuint vertIndex, unsigned int whichTexture, const float *textureCoord)
void InitFromBinaryResource(GlsResourceFileMgr::BinaryResource *resource)
void SetVertexAttrib3fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:827
static GlsGeometry_Generic * CreateEmptyInstance()
void SetIndexBufferSize(unsigned int bufferNum, unsigned int newSize)
bool _vertexBufferUpdated
Is the video card vertex buffer up to date?
Definition: gls_geometry_resource.h:1039
void SetVertexAttrib2fv(GLuint vertIndex, GLuint attribIndex, const GLfloat *v)
Definition: gls_geometry_resource.h:821
void SetSecondaryColor(GLuint vertIndex, unsigned char red, unsigned char green, unsigned char blue)
GlsGeometry_Generic_IndexBufferData * _indexBuffers
Definition: gls_geometry_resource.h:1042
void SetNormals(const float *floatArray, unsigned int numVertices, unsigned int startVertIndex=0, unsigned int stride=NORMAL_ATTRIBUTE_SIZE)
void SetVertex(GLuint vertIndex, float x, float y, float z)
void Destroy() DISTI_METHOD_OVERRIDE
unsigned int GetIndex(unsigned int bufferNum, unsigned int index)
void SetColors(const unsigned int *array)
void CopyVertexAndIndexBuffers(GlsGeometry_Generic *rhs)
bool _bufferLock
Flag indicating that the vertex buffer is being written to.
Definition: gls_geometry_resource.h:1034
void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE
void StoreVertexAttrib(GLuint vertIndex, GLuint attribIndex, void *value, GLuint sizeBytes)
unsigned int GetTexcoordByteOffset(unsigned int whichTexture)
static GlsGeometry_Generic * CreateFromBinaryResource(GlsResourceFileMgr::BinaryResource *data)
unsigned int VertexCount() const
unsigned int StatsIndexBufferPolygonCount(unsigned int bufferNumber) DISTI_METHOD_OVERRIDE
Definition: gls_geometry_resource.h:526
bool HitTest(unsigned char pickType, const Vector &pickLinePoint, const Vector &pickLineDirection, Vector &collisionPoint) DISTI_METHOD_OVERRIDE
unsigned int GetDataChangedCounter() const DISTI_METHOD_OVERRIDE
Definition: gls_resource_file_mgr.h:73
Definition: gls_resource_file_mgr.h:95
Definition: gls_resource_file_mgr.h:64
Definition: gls_render_effect.h:78
Contains the DistiAssert macro.
#define GLS_ASSERT(exp)
Definition: disti_assert.h:149
#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:245
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
The GlsMatrixAffine class.
The disti::GlsRenderEffect class.
Resource file manager interface.
#define GLSGEN_GlsGeometryResource_EXPORT
Provides support for creating DLLs.
Definition: gls_resource_file_mgr.h:51
Definition: bmpimage.h:46
Definition: gls_geometry_resource.h:945
unsigned int _order
The order the vertex should be in.
Definition: gls_geometry_resource.h:946
unsigned int _vertexTupleIndex
The index of the primitive.
Definition: gls_geometry_resource.h:947
Definition: gls_geometry_resource.h:1015
unsigned int _texcoordStride
Offset between each texture coordinate in bytes.
Definition: gls_geometry_resource.h:1019
unsigned int _texcoord2Stride
Offset between each secondary texture coordinate in bytes.
Definition: gls_geometry_resource.h:1020
unsigned int _numVertexAttribs
The count of vertex attributes.
Definition: gls_geometry_resource.h:1023
unsigned int _size
Total size of each vertex in bytes (depends on which data is included).
Definition: gls_geometry_resource.h:1016
unsigned int _colorStride
Offset between each color in bytes.
Definition: gls_geometry_resource.h:1021
unsigned int _normalStride
Offset between each normal in bytes.
Definition: gls_geometry_resource.h:1018
unsigned int _secondaryColorStride
Offset between each secondary color in bytes.
Definition: gls_geometry_resource.h:1022
The disti::Vertex class. A class for manipulating 3D vertices.