BARE2D
VAO.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <GL/glew.h>
4 
5 namespace BARE2D {
6 
7  /**
8  * @class VAO
9  * @brief A wrapper class for OpenGL's VAO, as well as its associated VBO and attributes
10  */
11  class VAO
12  {
13  public:
14  VAO();
15  ~VAO();
16 
17  /**
18  * @brief Initializes the necessary components, combining the VBO and VAO
19  */
20  void init();
21 
22  /**
23  * @brief Releases necessary memory.
24  */
25  void destroy();
26 
27  /**
28  * @brief Binds this vertex array object.
29  */
30  void bind();
31 
32  /**
33  * @brief Binds the VAO's VBO
34  */
35  void bindVBO();
36 
37  /**
38  * @brief Unbinds the vao.
39  */
40  void unbind();
41 
42  /**
43  * @brief Unbinds this VAO's VBO
44  */
45  void unbindVBO();
46 
47  /**
48  * @brief Wrapper for glVertexAttribPointer - Adds an attribute to the VBO - each vertex data slot will gain some attribute.
49  * @param size Number of components per attribute (1-4)
50  * @param type Type of data - GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, etc. See docs
51  * @param normalized Should the data be normalized or converted directly? (GL_TRUE/GL_FALSE)
52  * @param stride Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0.
53  * @param data Specifies a offset of the first component of the first generic vertex attribute in the array in the data store of the buffer currently bound to the GL_ARRAY_BUFFER target. The initial value is 0.
54  */
55  void addVertexAttribute(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* data);
56 
57  private:
58  unsigned int m_numAttributes; // How many attributes we've added so far.
59 
60  GLuint m_vaoHandle; // The GL-provided handle for the VAO
61  GLuint m_vboHandle; // The GL-provided handle for the VBO (Yes, there's only one. Each 'vertex' in the vertex buffer object combines all the data)
62 
63  };
64 
65 }
66 
BARE2D::VAO::m_vboHandle
GLuint m_vboHandle
Definition: VAO.hpp:61
BARE2D::VAO::destroy
void destroy()
Releases necessary memory.
Definition: VAO.cpp:33
BARE2D::VAO::m_vaoHandle
GLuint m_vaoHandle
Definition: VAO.hpp:60
BARE2D
Definition: App.cpp:13
BARE2D::VAO::unbind
void unbind()
Unbinds the vao.
Definition: VAO.cpp:53
BARE2D::VAO::init
void init()
Initializes the necessary components, combining the VBO and VAO.
Definition: VAO.cpp:14
BARE2D::VAO::~VAO
~VAO()
Definition: VAO.cpp:10
BARE2D::VAO::bind
void bind()
Binds this vertex array object.
Definition: VAO.cpp:48
BARE2D::VAO::unbindVBO
void unbindVBO()
Unbinds this VAO's VBO.
Definition: VAO.cpp:62
BARE2D::VAO::m_numAttributes
unsigned int m_numAttributes
Definition: VAO.hpp:58
BARE2D::VAO::bindVBO
void bindVBO()
Binds the VAO's VBO.
Definition: VAO.cpp:57
BARE2D::VAO
A wrapper class for OpenGL's VAO, as well as its associated VBO and attributes.
Definition: VAO.hpp:11
BARE2D::VAO::addVertexAttribute
void addVertexAttribute(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *data)
Wrapper for glVertexAttribPointer - Adds an attribute to the VBO - each vertex data slot will gain so...
Definition: VAO.cpp:66
BARE2D::VAO::VAO
VAO()
Definition: VAO.cpp:5