NGL  6.5
The NCCA Graphics Library
ngl::SimpleIndexVAO Class Reference

Simple indexed vao using one buffer and float data see https://github.com/NCCA/VertexArrayObject/tree/master/SimpleIndexVAOFactory for examples of use. More...

#include <SimpleIndexVAO.h>

+ Inheritance diagram for ngl::SimpleIndexVAO:
+ Collaboration diagram for ngl::SimpleIndexVAO:

Classes

class  VertexData
 

Public Member Functions

virtual void draw () const
 draw the VAO using glDrawArrays More...
 
virtual ~SimpleIndexVAO ()
 dtor don't do anything as the remove clears things More...
 
virtual void removeVAO ()
 remove the VAO and buffers created More...
 
virtual void setData (const AbstractVAO::VertexData &_data)
 , this method sets the data for the VAO if data has already been set it will remove the existing data and then re-set with the new data. More...
 
GLuint getBufferID (unsigned int)
 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...
 
- Public Member Functions inherited from ngl::AbstractVAO
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...
 
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...
 
GLenum getMode () const
 get the draw mode More...
 
void setMode (const GLenum &_mode)
 set the draw mode More...
 

Static Public Member Functions

static AbstractVAOcreate (GLenum _mode=GL_TRIANGLES)
 creator method for the factory More...
 

Protected Member Functions

 SimpleIndexVAO (GLenum _mode)
 ctor calles parent ctor to allocate vao; More...
 
- Protected Member Functions inherited from ngl::AbstractVAO
 AbstractVAO (GLenum _mode=GL_TRIANGLES)
 

Private Attributes

GLuint m_buffer =0
 the id of the buffer for the VAO More...
 
GLenum m_indexType
 data type of the index data (e.g. GL_UNSIGNED_INT) More...
 

Additional Inherited Members

- Protected Attributes inherited from ngl::AbstractVAO
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...
 

Detailed Description

Simple indexed vao using one buffer and float data see https://github.com/NCCA/VertexArrayObject/tree/master/SimpleIndexVAOFactory for examples of use.

Author
Jonathan Macey
Version
1.0
Date
6/4/16

Definition at line 34 of file SimpleIndexVAO.h.

Constructor & Destructor Documentation

ngl::SimpleIndexVAO::~SimpleIndexVAO ( )
virtual

dtor don't do anything as the remove clears things

Definition at line 5 of file SimpleIndexVAO.cpp.

References removeVAO().

+ Here is the call graph for this function:

ngl::SimpleIndexVAO::SimpleIndexVAO ( GLenum  _mode)
inlineprotected

ctor calles parent ctor to allocate vao;

Definition at line 93 of file SimpleIndexVAO.h.

Member Function Documentation

static AbstractVAO* ngl::SimpleIndexVAO::create ( GLenum  _mode = GL_TRIANGLES)
inlinestatic

creator method for the factory

Parameters
_modethe mode to draw with.
Returns
a new AbstractVAO * object

Definition at line 55 of file SimpleIndexVAO.h.

+ Here is the caller graph for this function:

void ngl::SimpleIndexVAO::draw ( ) const
virtual

draw the VAO using glDrawArrays

Implements ngl::AbstractVAO.

Definition at line 10 of file SimpleIndexVAO.cpp.

References glDrawElements(), ngl::AbstractVAO::m_allocated, ngl::AbstractVAO::m_bound, m_indexType, ngl::AbstractVAO::m_indicesCount, and ngl::AbstractVAO::m_mode.

+ Here is the call graph for this function:

GLuint ngl::SimpleIndexVAO::getBufferID ( unsigned int  )
inlinevirtual

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

Parameters
_bufferindex (default to 0 for single buffer VAO's)

Implements ngl::AbstractVAO.

Definition at line 87 of file SimpleIndexVAO.h.

void ngl::SimpleIndexVAO::removeVAO ( )
virtual

remove the VAO and buffers created

Implements ngl::AbstractVAO.

Definition at line 23 of file SimpleIndexVAO.cpp.

References glDeleteBuffers, glDeleteVertexArrays, ngl::AbstractVAO::m_allocated, ngl::AbstractVAO::m_bound, m_buffer, ngl::AbstractVAO::m_id, and ngl::AbstractVAO::unbind().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ngl::SimpleIndexVAO::setData ( const AbstractVAO::VertexData _data)
virtual

, this method sets the data for the VAO if data has already been set it will remove the existing data and then re-set with the new data.

Parameters
_sizethe size of the raw data passed
_datathe actual data to set for the VOA
_indexSizethe size of the index array passed
_indexDatathe actual data to set for the VOA indexes (only GLubyte data at present need to write more methods but usually only use this
_indexTypethe type of the values in the indices buffer. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.
_modethe draw mode hint used by GL

Implements ngl::AbstractVAO.

Definition at line 39 of file SimpleIndexVAO.cpp.

References GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, GL_UNSIGNED_SHORT, glBindBuffer, glBufferData, glGenBuffers, ngl::AbstractVAO::m_allocated, ngl::AbstractVAO::m_bound, ngl::AbstractVAO::VertexData::m_data, ngl::SimpleIndexVAO::VertexData::m_indexData, ngl::SimpleIndexVAO::VertexData::m_indexSize, ngl::SimpleIndexVAO::VertexData::m_indexType, m_indexType, ngl::AbstractVAO::VertexData::m_mode, and ngl::AbstractVAO::VertexData::m_size.

Member Data Documentation

GLuint ngl::SimpleIndexVAO::m_buffer =0
private

the id of the buffer for the VAO

Definition at line 102 of file SimpleIndexVAO.h.

GLenum ngl::SimpleIndexVAO::m_indexType
private

data type of the index data (e.g. GL_UNSIGNED_INT)

Definition at line 106 of file SimpleIndexVAO.h.


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