NGL
6.5
The NCCA Graphics Library
|
base class for all VAO from the VAOFactory this defines the base class type with simple draw / bind behaviour, the user must allocate the data and do any more complex setup. See SimpleVAO for examples as well as the other ngl examples More...
#include <AbstractVAO.h>
Classes | |
class | VertexData |
Public Member Functions | |
virtual | ~AbstractVAO ()=default |
dtor usually this will not be called More... | |
void | bind () |
bind the VAO so it can be used. More... | |
void | unbind () |
unbind the VAO by binding default 0 More... | |
virtual void | draw () const =0 |
this is the draw method for the VAO the user must implement this per VAO data, usually this will be a call to glDrawArrays type function, VAO must be bound before calling this More... | |
virtual void | setData (const VertexData &_data)=0 |
this method is used to set the data in the VAO, we have a base data type of VertexData above, but the user can extend this to create custom data types More... | |
virtual void | removeVAO ()=0 |
this will clean up the VAO and associated data, it is the users responsibility to do this usually this will be a call to the various delete buffers gl routines More... | |
void | setVertexAttributePointer (GLuint _id, GLint _size, GLenum _type, GLsizei _stride, unsigned int _dataOffset, bool _normalise=false) |
set the generic vertex attribute pointer data usually this method will do however the user may occasionally need to override this method. More... | |
void | setNumIndices (size_t _s) |
the number of indices to draw in the array. It may be that the draw routine can overide this at another time. More... | |
virtual GLuint | getBufferID (unsigned int _id=0)=0 |
return the id of the buffer, if there is only 1 buffer just return this if we have the more than one buffer the sub class manages the id's More... | |
GLenum | getMode () const |
get the draw mode More... | |
void | setMode (const GLenum &_mode) |
set the draw mode More... | |
Protected Member Functions | |
AbstractVAO (GLenum _mode=GL_TRIANGLES) | |
Protected Attributes | |
GLenum | m_mode =GL_TRIANGLES |
the draw mode More... | |
GLuint | m_id =0 |
the id of the VAO allocated from OpenGL More... | |
bool | m_bound =false |
debug flag to indicate if the vao is bound. More... | |
bool | m_allocated =false |
debug flag to indicate if data has been set for the VAO More... | |
size_t | m_indicesCount =0 |
the number of indices stored in the VAO. More... | |
base class for all VAO from the VAOFactory this defines the base class type with simple draw / bind behaviour, the user must allocate the data and do any more complex setup. See SimpleVAO for examples as well as the other ngl examples
Definition at line 34 of file AbstractVAO.h.
|
virtualdefault |
dtor usually this will not be called
|
protected |
ctor to build the VAO
_mode | the mode to draw with. |
Definition at line 5 of file AbstractVAO.cpp.
References glGenVertexArrays, m_id, and m_mode.
void ngl::AbstractVAO::bind | ( | ) |
bind the VAO so it can be used.
Definition at line 23 of file AbstractVAO.cpp.
References glBindVertexArray, m_bound, and m_id.
|
pure virtual |
this is the draw method for the VAO the user must implement this per VAO data, usually this will be a call to glDrawArrays type function, VAO must be bound before calling this
Implemented in ngl::SimpleIndexVAO, ngl::MultiBufferVAO, and ngl::SimpleVAO.
return the id of the buffer, if there is only 1 buffer just return this if we have the more than one buffer the sub class manages the id's
_buffer | index (default to 0 for single buffer VAO's) |
Implemented in ngl::SimpleIndexVAO, ngl::MultiBufferVAO, and ngl::SimpleVAO.
GLenum ngl::AbstractVAO::getMode | ( | ) | const |
|
pure virtual |
this will clean up the VAO and associated data, it is the users responsibility to do this usually this will be a call to the various delete buffers gl routines
Implemented in ngl::SimpleIndexVAO, ngl::MultiBufferVAO, and ngl::SimpleVAO.
|
pure virtual |
this method is used to set the data in the VAO, we have a base data type of VertexData above, but the user can extend this to create custom data types
Implemented in ngl::SimpleIndexVAO, ngl::MultiBufferVAO, and ngl::SimpleVAO.
set the draw mode
_mode | (GL_TRIANGLES etc) |
Definition at line 17 of file AbstractVAO.cpp.
References m_mode.
|
inline |
the number of indices to draw in the array. It may be that the draw routine can overide this at another time.
_s | the number of indices to draw (from 0) |
Definition at line 91 of file AbstractVAO.h.
References GL_TRIANGLES.
void ngl::AbstractVAO::setVertexAttributePointer | ( | GLuint | _id, |
GLint | _size, | ||
GLenum | _type, | ||
GLsizei | _stride, | ||
unsigned int | _dataOffset, | ||
bool | _normalise = false |
||
) |
set the generic vertex attribute pointer data usually this method will do however the user may occasionally need to override this method.
_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) 0 means tightly packed / contiguous |
_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 static_cast<Real *>(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 36 of file AbstractVAO.cpp.
References glEnableVertexAttribArray, glVertexAttribPointer, and m_bound.
void ngl::AbstractVAO::unbind | ( | ) |
unbind the VAO by binding default 0
Definition at line 29 of file AbstractVAO.cpp.
References glBindVertexArray, and m_bound.
|
protected |
debug flag to indicate if data has been set for the VAO
Definition at line 129 of file AbstractVAO.h.
|
protected |
debug flag to indicate if the vao is bound.
Definition at line 125 of file AbstractVAO.h.
|
protected |
the id of the VAO allocated from OpenGL
Definition at line 121 of file AbstractVAO.h.
|
protected |
the number of indices stored in the VAO.
Definition at line 133 of file AbstractVAO.h.
|
protected |
the draw mode
Definition at line 117 of file AbstractVAO.h.