NGL  6.5
The NCCA Graphics Library
ngl::AbstractVAO Class Referenceabstract

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>

+ Inheritance diagram for ngl::AbstractVAO:
+ Collaboration diagram for ngl::AbstractVAO:

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...
 

Detailed Description

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

Author
Jonathan Macey
Version
1.0
Date
6/4/16

Definition at line 34 of file AbstractVAO.h.

Constructor & Destructor Documentation

virtual ngl::AbstractVAO::~AbstractVAO ( )
virtualdefault

dtor usually this will not be called

ngl::AbstractVAO::AbstractVAO ( GLenum  _mode = GL_TRIANGLES)
protected

ctor to build the VAO

Parameters
_modethe mode to draw with.

Definition at line 5 of file AbstractVAO.cpp.

References glGenVertexArrays, m_id, and m_mode.

Member Function Documentation

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.

+ Here is the caller graph for this function:

virtual void ngl::AbstractVAO::draw ( ) const
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.

+ Here is the caller graph for this function:

virtual GLuint ngl::AbstractVAO::getBufferID ( unsigned int  _id = 0)
pure virtual

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)

Implemented in ngl::SimpleIndexVAO, ngl::MultiBufferVAO, and ngl::SimpleVAO.

GLenum ngl::AbstractVAO::getMode ( ) const

get the draw mode

Definition at line 12 of file AbstractVAO.cpp.

References m_mode.

virtual void ngl::AbstractVAO::removeVAO ( )
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.

+ Here is the caller graph for this function:

virtual void ngl::AbstractVAO::setData ( const VertexData _data)
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.

+ Here is the caller graph for this function:

void ngl::AbstractVAO::setMode ( const GLenum _mode)

set the draw mode

Parameters
_mode(GL_TRIANGLES etc)

Definition at line 17 of file AbstractVAO.cpp.

References m_mode.

+ Here is the caller graph for this function:

void ngl::AbstractVAO::setNumIndices ( size_t  _s)
inline

the number of indices to draw in the array. It may be that the draw routine can overide this at another time.

Parameters
_sthe number of indices to draw (from 0)

Definition at line 91 of file AbstractVAO.h.

References GL_TRIANGLES.

+ Here is the caller graph for this function:

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.

Parameters
_sizethe size of the raw data passed (not counting sizeof(GL_FLOAT))
_typethe data type of the Pointer (eg GL_FLOAT)
_stridethe step between data values (need *sizeof _type) e.g. 10*sizeof(GLfloat) 0 means tightly packed / contiguous
_dataOffsetSpecifies 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
_normalisespecifies 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.

+ Here is the caller graph for this function:

void ngl::AbstractVAO::unbind ( )

unbind the VAO by binding default 0

Definition at line 29 of file AbstractVAO.cpp.

References glBindVertexArray, and m_bound.

+ Here is the caller graph for this function:

Member Data Documentation

bool ngl::AbstractVAO::m_allocated =false
protected

debug flag to indicate if data has been set for the VAO

Definition at line 129 of file AbstractVAO.h.

bool ngl::AbstractVAO::m_bound =false
protected

debug flag to indicate if the vao is bound.

Definition at line 125 of file AbstractVAO.h.

GLuint ngl::AbstractVAO::m_id =0
protected

the id of the VAO allocated from OpenGL

Definition at line 121 of file AbstractVAO.h.

size_t ngl::AbstractVAO::m_indicesCount =0
protected

the number of indices stored in the VAO.

Definition at line 133 of file AbstractVAO.h.

GLenum ngl::AbstractVAO::m_mode =GL_TRIANGLES
protected

the draw mode

Definition at line 117 of file AbstractVAO.h.


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