SimpleGL  1.1.0
A framework for platform independent rendering
vertex_array_object.cpp
Go to the documentation of this file.
1 
9 
11 
12 namespace sgl {
13  VertexArray* VertexArray::current = nullptr;
14 
16  glGenVertexArrays(1, &handle);
17  }
18 
20  glDeleteVertexArrays(1, &handle);
21 
22  /* Set current to nullptr if this was the bound vertex array object */
23  if (VertexArray::current == this) {
24  VertexArray::current = nullptr;
25  }
26  }
27 
29  return handle;
30  }
31 
33  /* If already bound return immediately */
34  if (VertexArray::current == this) {
35  return;
36  }
37 
38  /* Bind vertex array object */
39  glBindVertexArray(handle);
40  VertexArray::current = this;
41  }
42 
43  void VertexArray::enableAttribute(unsigned int index) {
44  glEnableVertexAttribArray(index);
45  }
46 
47  void VertexArray::disableAttribute(unsigned int index) {
48  glDisableVertexAttribArray(index);
49  }
50 
51  void VertexArray::pointAttribute(unsigned int index, int size, ValueType type, bool normalized, int stride, long offset) {
52  void* pointer = (void*) (long(NULL) + offset);
53  glVertexAttribPointer(index, size, to_GLenum(type), normalized, stride, pointer);
54  }
55 }
void disableAttribute(unsigned int index)
Disables a vertex attribute.
void bind()
Binds the vertex array object.
GLenum to_GLenum(E e)
Gets the GLenum value from an enum class.
Definition: backend_gl.tcc:22
void pointAttribute(unsigned int index, int size, ValueType type, bool normalized, int stride, long offset)
Sets the vertex attribute pointer.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
ValueType
This enum wraps the vertex array object's value types.
GLuint getHandle()
Returns the handle of the vertex array object.
void enableAttribute(unsigned int index)
Enables a vertex attribute.
~VertexArray(void)
Deletes the vertex array object.
VertexArray(void)
Generates a new vertex array object.