NGL
6.5
The NCCA Graphics Library
|
a class to encapsulate an OpenGL VAO More...
#include <VertexArrayObject.h>
Public Member Functions | |
void | bind () |
bind this VOA to make it active More... | |
void | unbind () |
unbind the VOA and set 0 to be the active VOA More... | |
void | removeVOA () |
delete the VOA (using OpenGL calls to clear data etc) More... | |
GLuint | getID () const |
accesor for the VOA id More... | |
bool | isBound () const |
accesor to see if VOA is bound More... | |
bool | isAllocated () const |
accesor to see if VOA has allocated data More... | |
void | setData (size_t _size, const GLfloat &_data, GLenum _mode=GL_STATIC_DRAW) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details More... | |
void | setIndexedData (size_t _size, const GLfloat &_data, unsigned int _indexSize, const GLvoid *_indexData, GLenum _indexType, GLenum _mode=GL_STATIC_DRAW) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details This value uses an index array to point to series of data to store More... | |
void | setRawIndexedData (size_t _size, const GLvoid *_data, unsigned int _indexSize, const GLvoid *_indexData, GLenum _indexType, GLenum _mode=GL_STATIC_DRAW) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details This value uses an index array to point to series of data to store More... | |
void | updateIndexedData (size_t _size, const GLfloat &_data, GLenum _mode=GL_STREAM_DRAW) |
allow to update the vertex data of the VBO when declared as dynamic (with GL_STREAM_DRAW) More... | |
void | updateIndexedData (GLuint _vboidx, size_t _size, const GLfloat &_data, GLenum _mode=GL_STREAM_DRAW) |
void | updateData (unsigned int _size, const GLfloat &_data, GLenum _mode=GL_STREAM_DRAW) |
allow to update the vertex data of the VBO when declared as dynamic (with GL_STREAM_DRAW) More... | |
void | updateData (GLuint _vboidx, unsigned int _size, const GLfloat &_data, GLenum _mode=GL_STREAM_DRAW) |
void | setVertexAttributePointer (GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset, bool _normalise=GL_FALSE) |
set the generic vertex attribute pointer data More... | |
void | setVertexAttributeIPointer (GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset) |
set the vertex attribute pointer as an Integer this will not be normalised etc More... | |
GLuint | getVBOid (unsigned int _index) |
get the VBO id for the data mapped at index _index basically this will be the vbo for the setData called, so if it has been called 3 times 0 would be first call 1, 2nd etc. More... | |
void | draw () const |
draw the VOA More... | |
void | draw (GLenum _mode) const |
draw the VOA More... | |
void | draw (unsigned int _startIndex, unsigned int _numVerts, GLenum _mode=GL_TRIANGLES) const |
draw the VOA More... | |
void | drawInstanced (GLenum _n) const |
draw the VOA _n times using instanced methods from GL (use transform feedback) More... | |
void | setNumIndices (size_t _n) |
set the number of faces to draw More... | |
unsigned int | getNumIndices () const |
get the number of indices in the vao More... | |
Real * | getDataPointer (unsigned int _vbo, GLenum _accessMode=GL_READ_WRITE) |
grab a pointer to the first block of the data More... | |
void | freeDataPointer () |
unmap the data pointer More... | |
int | getSize () const |
get the size in bytes of the VAO More... | |
~VertexArrayObject () | |
dtor doesn't do anything use the removeVAO method instead More... | |
Static Public Member Functions | |
static VertexArrayObject * | createVOA (GLenum _mode) |
method to return a newVOA object More... | |
Protected Member Functions | |
VertexArrayObject () | |
hide the ctor as we want to create static factory only More... | |
VertexArrayObject (GLenum _mode) | |
hide the ctor as we want to create static factory only More... | |
VertexArrayObject (const VertexArrayObject &_v) | |
hide the copy ctor as we want to create static factory only More... | |
Protected Attributes | |
GLenum | m_drawMode |
the draw mode of the VAO e.g. GL_TRIANGLES More... | |
GLuint | m_indicesCount |
the number of faces to draw More... | |
GLuint | m_id |
the id of the VAO allocated by OpenGL More... | |
bool | m_allocated |
flag to indicate if we have allocated the data to the VAO More... | |
bool | m_indexed |
flag to indicate if we have an index or non index vao to draw More... | |
GLenum | m_indexType |
Specifies the type of the values in the indices buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. More... | |
GLuint | m_iboID |
the id of the index bufffer object More... | |
bool | m_bound |
flag to indicate if we are bound More... | |
std::vector< GLuint > | m_vboIDs |
an array of VBO associated with this VAO More... | |
a class to encapsulate an OpenGL VAO
Definition at line 50 of file VertexArrayObject.h.
|
inline |
dtor doesn't do anything use the removeVAO method instead
Definition at line 223 of file VertexArrayObject.h.
|
inlineprotected |
hide the ctor as we want to create static factory only
Definition at line 266 of file VertexArrayObject.h.
|
protected |
hide the ctor as we want to create static factory only
Definition at line 27 of file VertexArrayObject.cpp.
References GL_UNSIGNED_BYTE, glGenVertexArrays, m_allocated, m_bound, m_drawMode, m_iboID, m_id, m_indexed, m_indexType, and m_indicesCount.
|
protected |
hide the copy ctor as we want to create static factory only
void ngl::VertexArrayObject::bind | ( | ) |
bind this VOA to make it active
Definition at line 41 of file VertexArrayObject.cpp.
References glBindVertexArray, m_bound, and m_id.
|
inlinestatic |
method to return a newVOA object
Definition at line 58 of file VertexArrayObject.h.
void ngl::VertexArrayObject::draw | ( | ) | const |
draw the VOA
Definition at line 269 of file VertexArrayObject.cpp.
References glDrawArrays(), glDrawElements(), m_allocated, m_bound, m_drawMode, m_indexed, m_indexType, and m_indicesCount.
draw the VOA
[in] | _mode | the mode to draw with |
Definition at line 304 of file VertexArrayObject.cpp.
References glDrawArrays(), glDrawElements(), m_allocated, m_bound, m_indexed, m_indexType, and m_indicesCount.
void ngl::VertexArrayObject::draw | ( | unsigned int | _startIndex, |
unsigned int | _numVerts, | ||
GLenum | _mode = GL_TRIANGLES |
||
) | const |
draw the VOA
[in] | _start | start Index |
[in] | _numVerts | the number to draw |
[in] | _mode | the mode to draw with |
Definition at line 291 of file VertexArrayObject.cpp.
References glDrawArrays(), m_allocated, and m_bound.
draw the VOA _n times using instanced methods from GL (use transform feedback)
[in] | _n | number of instances to draw |
Definition at line 325 of file VertexArrayObject.cpp.
References glDrawArraysInstanced, glDrawElementsInstanced, m_allocated, m_bound, m_drawMode, m_indexed, m_indexType, and m_indicesCount.
void ngl::VertexArrayObject::freeDataPointer | ( | ) |
unmap the data pointer
Definition at line 366 of file VertexArrayObject.cpp.
References GL_ARRAY_BUFFER, and glUnmapBuffer.
Real * ngl::VertexArrayObject::getDataPointer | ( | unsigned int | _vbo, |
GLenum | _accessMode = GL_READ_WRITE |
||
) |
grab a pointer to the first block of the data
[in] | _vbo | the vbo number of the block you wish to grab the data for |
[in] | _accessMode | the mode to access the data, this is default to GL_READ_WRITE but we could change this to GL_READ to make access quicker for just reading the values or GL_WRITE for just writing values etc. |
Definition at line 348 of file VertexArrayObject.cpp.
References bind(), GL_ARRAY_BUFFER, glBindBuffer, glMapBuffer, and m_vboIDs.
|
inline |
|
inline |
get the number of indices in the vao
Definition at line 198 of file VertexArrayObject.h.
References GL_READ_WRITE.
int ngl::VertexArrayObject::getSize | ( | ) | const |
get the size in bytes of the VAO
Definition at line 371 of file VertexArrayObject.cpp.
References GL_ARRAY_BUFFER, GL_BUFFER_SIZE, glGetBufferParameteriv, and m_bound.
get the VBO id for the data mapped at index _index basically this will be the vbo for the setData called, so if it has been called 3 times 0 would be first call 1, 2nd etc.
[in] | _index | the index to get the id for |
_index >=0 && picked up by g++4.3 so removed from below
Definition at line 231 of file VertexArrayObject.cpp.
References m_vboIDs.
|
inline |
accesor to see if VOA has allocated data
returns the allocated state (true for allocated)
Definition at line 88 of file VertexArrayObject.h.
References GL_FALSE, GL_STATIC_DRAW, GL_STREAM_DRAW, and GL_TRIANGLES.
|
inline |
accesor to see if VOA is bound
returns the bind state (true for bound)
Definition at line 83 of file VertexArrayObject.h.
void ngl::VertexArrayObject::removeVOA | ( | ) |
delete the VOA (using OpenGL calls to clear data etc)
Definition at line 53 of file VertexArrayObject.cpp.
References glDeleteBuffers, glDeleteVertexArrays, m_allocated, m_bound, m_id, m_vboIDs, and unbind().
void ngl::VertexArrayObject::setData | ( | size_t | _size, |
const GLfloat & | _data, | ||
GLenum | _mode = GL_STATIC_DRAW |
||
) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details
_size | the size of the raw data passed (this will be *sizeof(Real) to convert (this could cause potential bugs!) |
_data | the actual data to set for the VOA |
_mode | the draw mode hint used by GL |
Definition at line 70 of file VertexArrayObject.cpp.
References GL_ARRAY_BUFFER, glBindBuffer, glBufferData, glGenBuffers, m_allocated, m_bound, and m_vboIDs.
void ngl::VertexArrayObject::setIndexedData | ( | size_t | _size, |
const GLfloat & | _data, | ||
unsigned int | _indexSize, | ||
const GLvoid * | _indexData, | ||
GLenum | _indexType, | ||
GLenum | _mode = GL_STATIC_DRAW |
||
) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details This value uses an index array to point to series of data to store
_size | the size of the raw data passed |
_data | the actual data to set for the VOA |
_indexSize | the size of the index array passed |
_indexData | the actual data to set for the VOA indexes (only GLubyte data at present need to write more methods but usually only use this |
_indexType | the type of the values in the indices buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. |
_mode | the draw mode hint used by GL |
Definition at line 87 of file VertexArrayObject.cpp.
References GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, GL_UNSIGNED_SHORT, glBindBuffer, glBufferData, glGenBuffers, m_allocated, m_bound, m_iboID, m_indexed, m_indexType, and m_vboIDs.
|
inline |
set the number of faces to draw
_n | the number of indices to draw in glDrawArray (param 3 count) |
Definition at line 193 of file VertexArrayObject.h.
void ngl::VertexArrayObject::setRawIndexedData | ( | size_t | _size, |
const GLvoid * | _data, | ||
unsigned int | _indexSize, | ||
const GLvoid * | _indexData, | ||
GLenum | _indexType, | ||
GLenum | _mode = GL_STATIC_DRAW |
||
) |
allocate our data using raw face values (for example tri's) data, attributes must be bound to match at a different level of code (usually in the client as part of the shader loading, see VAO examples for more details This value uses an index array to point to series of data to store
_size | the size of the raw data passed |
_data | the actual data to set for the VOA |
_indexSize | the size of the index array passed |
_indexData | the actual data to set for the VOA indexes (only GLubyte data at present need to write more methods but usually only use this |
_indexType | the type of the values in the indices buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. |
_mode | the draw mode hint used by GL |
Definition at line 126 of file VertexArrayObject.cpp.
References GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, GL_UNSIGNED_SHORT, glBindBuffer, glBufferData, glGenBuffers, m_allocated, m_bound, m_iboID, m_indexed, m_indexType, and m_vboIDs.
void ngl::VertexArrayObject::setVertexAttributeIPointer | ( | GLuint | _id, |
GLint | _size, | ||
GLenum | _type, | ||
GLsizei | _stride, | ||
unsigned int | _dataOffset | ||
) |
set the vertex attribute pointer as an Integer this will not be normalised etc
_size | the size of the raw data passed (not counting sizeof(GL_FLOAT)) |
_type | the data type of the Pointer (eg GL_FLOAT) |
_stride | the step between data values (need *sizeof _type) e.g. 10*sizeof(GLfloat) |
_dataOffset | Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0. and is calculated as ((float *)NULL + (_dataOffset)) |
Definition at line 255 of file VertexArrayObject.cpp.
References glEnableVertexAttribArray, glVertexAttribIPointer, and m_bound.
void ngl::VertexArrayObject::setVertexAttributePointer | ( | GLuint | _id, |
GLint | _size, | ||
GLenum | _type, | ||
GLsizei | _stride, | ||
unsigned int | _dataOffset, | ||
bool | _normalise = GL_FALSE |
||
) |
set the generic vertex attribute pointer data
_size | the size of the raw data passed (not counting sizeof(GL_FLOAT)) |
_type | the data type of the Pointer (eg GL_FLOAT) |
_stride | the step between data values (need *sizeof _type) e.g. 10*sizeof(GLfloat) |
_dataOffset | Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0. and is calculated as ((float *)NULL + (_dataOffset)) |
_normalise | specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed. |
Definition at line 243 of file VertexArrayObject.cpp.
References glEnableVertexAttribArray, glVertexAttribPointer, and m_bound.
void ngl::VertexArrayObject::unbind | ( | ) |
unbind the VOA and set 0 to be the active VOA
Definition at line 47 of file VertexArrayObject.cpp.
References glBindVertexArray, and m_bound.
void ngl::VertexArrayObject::updateData | ( | unsigned int | _size, |
const GLfloat & | _data, | ||
GLenum | _mode = GL_STREAM_DRAW |
||
) |
allow to update the vertex data of the VBO when declared as dynamic (with GL_STREAM_DRAW)
_size | the size of the raw data passed |
_data | the actual data to set for the VOA |
_mode | the draw mode hint used by GL (choose GL_STREAM_DRAW by default, recommended mode for dynamic VBO's) |
Definition at line 199 of file VertexArrayObject.cpp.
References getVBOid(), GL_ARRAY_BUFFER, glBindBuffer, glBufferData, m_allocated, and m_bound.
void ngl::VertexArrayObject::updateData | ( | GLuint | _vboidx, |
unsigned int | _size, | ||
const GLfloat & | _data, | ||
GLenum | _mode = GL_STREAM_DRAW |
||
) |
Definition at line 215 of file VertexArrayObject.cpp.
References getVBOid(), GL_ARRAY_BUFFER, glBindBuffer, glBufferData, m_allocated, and m_bound.
void ngl::VertexArrayObject::updateIndexedData | ( | size_t | _size, |
const GLfloat & | _data, | ||
GLenum | _mode = GL_STREAM_DRAW |
||
) |
allow to update the vertex data of the VBO when declared as dynamic (with GL_STREAM_DRAW)
_size | the size of the raw data passed |
_data | the actual data to set for the VOA |
_mode | the draw mode hint used by GL (choose GL_STREAM_DRAW by default, recommended mode for dynamic VBO's) |
Definition at line 167 of file VertexArrayObject.cpp.
References getVBOid(), GL_ARRAY_BUFFER, glBindBuffer, glBufferData, m_allocated, m_bound, and m_indexed.
void ngl::VertexArrayObject::updateIndexedData | ( | GLuint | _vboidx, |
size_t | _size, | ||
const GLfloat & | _data, | ||
GLenum | _mode = GL_STREAM_DRAW |
||
) |
Definition at line 183 of file VertexArrayObject.cpp.
References getVBOid(), GL_ARRAY_BUFFER, glBindBuffer, glBufferData, m_allocated, m_bound, and m_indexed.
|
protected |
flag to indicate if we have allocated the data to the VAO
Definition at line 241 of file VertexArrayObject.h.
|
protected |
flag to indicate if we are bound
Definition at line 258 of file VertexArrayObject.h.
|
protected |
the draw mode of the VAO e.g. GL_TRIANGLES
Definition at line 229 of file VertexArrayObject.h.
|
protected |
the id of the index bufffer object
Definition at line 254 of file VertexArrayObject.h.
|
protected |
the id of the VAO allocated by OpenGL
Definition at line 237 of file VertexArrayObject.h.
|
protected |
flag to indicate if we have an index or non index vao to draw
Definition at line 245 of file VertexArrayObject.h.
|
protected |
Specifies the type of the values in the indices buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.
Definition at line 250 of file VertexArrayObject.h.
|
protected |
the number of faces to draw
Definition at line 233 of file VertexArrayObject.h.
|
protected |
an array of VBO associated with this VAO
Definition at line 262 of file VertexArrayObject.h.