GL Studio C++ Runtime API
GlsVertexArray Class Reference
Inheritance diagram for GlsVertexArray:
NonCopyable

Public Member Functions

 GlsVertexArray ()
 
virtual ~GlsVertexArray ()
 
void Setup (const int nVerts, const bool hasT, const bool hasC, const bool hasN)
 
void SetVertices (const Vertex verts[])
 
void SetTexCoords (const Vector verts[])
 
void SetNormals (const Vector verts[])
 
void SetColors (const Vertex verts[])
 
void SetVertex (const unsigned int index, const Vector &v)
 
void SetTexCoord (const unsigned int index, const Vector &v)
 
void Bake (IGlsStateManager *stateManager)
 
void Draw (const unsigned int glPrimitive, IGlsStateManager *stateManager, const bool texture, const bool color, const bool normal)
 
void Draw (const unsigned int glPrimitive, const unsigned int offset, const unsigned int count, GlsIndexArray &indexBuffer, IGlsStateManager *stateManager, const bool texture, const bool color, const bool normal)
 
void MultiDraw (const unsigned int glPrimitive, const unsigned int offset, const unsigned int count, const unsigned int primitiveSize, GlsIndexArray &indexBuffer, IGlsStateManager *stateManager, const bool texture, const bool color, const bool normal)
 

Static Public Attributes

static const GLuint VERT_SIZE = sizeof( GL_FLOAT ) * 3
 

Protected Member Functions

void AllocateBuffer (const unsigned int size)
 
void DeallocateBuffer ()
 

Protected Attributes

unsigned char * _vertexData
 
unsigned int _vboHandle
 
unsigned int _bufferSize
 
bool _setup
 
bool _hasT
 
bool _hasN
 
bool _hasC
 
unsigned int _componentSize
 
unsigned int _texOffset
 
unsigned int _normalOffset
 
unsigned int _colorOffset
 
unsigned int _nVerts
 

Constructor & Destructor Documentation

Default constructor

virtual ~GlsVertexArray ( )
virtual

Destructor

Member Function Documentation

void AllocateBuffer ( const unsigned int  size)
protected

Allocates the buffer data, copying the existing data

Parameters
sizeThe new size in bytes to allocate
void Bake ( IGlsStateManager stateManager)

Bake the vertex buffer to a VBO

Precondition
_setup == true
Parameters
stateManagerState manager for the OpenGL context to bake the VBO in
void DeallocateBuffer ( )
protected

Deallocates the buffer data

void Draw ( const unsigned int  glPrimitive,
IGlsStateManager stateManager,
const bool  texture,
const bool  color,
const bool  normal 
)

Draw this vertex array

Precondition
_setup == true
Postcondition
The VBO is drawn
Parameters
glPrimitiveThe OpenGL primitive type to draw (e.g. GL_LINE_LOOP)
stateManagerState manager for the OpenGL context to draw in
textureWhether or not to draw with texture
colorWhether or not to use per vertex colors
normalWhether or not to use per vertex normals
void Draw ( const unsigned int  glPrimitive,
const unsigned int  offset,
const unsigned int  count,
GlsIndexArray indexBuffer,
IGlsStateManager stateManager,
const bool  texture,
const bool  color,
const bool  normal 
)

Draw this vertex array

Precondition
_setup == true
Postcondition
The VBO is drawn
Parameters
glPrimitiveThe OpenGL primitive type to draw (e.g. GL_LINE_LOOP)
offsetIndex of the first vertex to draw
countNumber of primitives to draw
indexBufferIndex buffer to use
stateManagerState manager for the OpenGL context to draw in
textureWhether or not to draw with texture
colorWhether or not to use per vertex colors
normalWhether or not to use per vertex normals
void MultiDraw ( const unsigned int  glPrimitive,
const unsigned int  offset,
const unsigned int  count,
const unsigned int  primitiveSize,
GlsIndexArray indexBuffer,
IGlsStateManager stateManager,
const bool  texture,
const bool  color,
const bool  normal 
)

Draw this vertex array

Precondition
_setup == true
Postcondition
The VBO is drawn
Parameters
glPrimitiveThe OpenGL primitive type to draw (e.g. GL_LINE_LOOP)
offsetIndex of the first vertex to draw
countNumber of primitives to draw
primitiveSizeNumber of vertices per primitive
indexBufferIndex buffer to use
stateManagerState manager for the OpenGL context to draw in
textureWhether or not to draw with texture
colorWhether or not to use per vertex colors
normalWhether or not to use per vertex normals
void SetColors ( const Vertex  verts[])

Sets the Colors of the array. Note: This takes an array of Vertex for compatibility with DisplayObject. It gets the colors from the color component of the vertices.

Precondition
(_setup && _hasC)
Parameters
vertsAn array of colors to populate this object with. verts[] must have at least _nVerts elements
void SetNormals ( const Vector  verts[])

Sets the Normals of the array

Precondition
(_setup && _hasN)
Parameters
vertsAn array of normals to populate this object with. verts[] must have at least _nVerts elements
void SetTexCoord ( const unsigned int  index,
const Vector v 
)

Sets a single texture coordinate

Precondition
_setup && (index < _nVerts) && _hasT
Parameters
indexThe index of the texture coordinate to set
vThe texture coordinate to set
void SetTexCoords ( const Vector  verts[])

Sets the texture coordinates of the array

Precondition
(_setup && _hasT)
Parameters
vertsAn array of texture coords to populate this object with. verts[] must have at least _nVerts elements
void Setup ( const int  nVerts,
const bool  hasT,
const bool  hasC,
const bool  hasN 
)

Prepare the vertex buffer to be populated. Allocates vertex buffer, sets up component offsets.

Parameters
nVertsNumber of vertices in the array
hasTTrue if array has texture coords
hasCTrue if array has colors
hasNTrue if array has normas
void SetVertex ( const unsigned int  index,
const Vector v 
)

Sets a single vertex

Precondition
_setup && (index < _nVerts)
Parameters
indexThe index of the vertex to set
vThe vertex to set
void SetVertices ( const Vertex  verts[])

Sets the vertices of the array

Precondition
_setup == true
Parameters
vertsAn array of vertices to populate this object with. verts[] must have at least _nVerts elements

Member Data Documentation

unsigned int _bufferSize
protected

Size of data pointed to by _vertexData

unsigned int _colorOffset
protected

Offset of the color from the beginning of a component, in bytes

unsigned int _componentSize
protected

Size of one element of this array (total size of all components) in bytes

bool _hasC
protected

True if this object has colors

bool _hasN
protected

True if this object has normals

bool _hasT
protected

True if this object has texture coordinates

unsigned int _normalOffset
protected

Offset of the normals from the beginning of a component, in bytes

unsigned int _nVerts
protected

Number of vertices in this object

bool _setup
protected

True if this object has been setup and can be downloaded to a VBO

unsigned int _texOffset
protected

Offset of the texture coords from the beginning of a component, in bytes

unsigned int _vboHandle
protected

OpenGL VBO handle

unsigned char* _vertexData
protected

Contains the dynamically allocated, interleaved vertex data that gets sent to the VBO

const GLuint VERT_SIZE = sizeof( GL_FLOAT ) * 3
static

Constant sizes of the primitive vertex attributes


The documentation for this class was generated from the following file: