Working with index buffers
Index buffers are a type of attribute. Unlike attributes, an index buffer is bound to GL_ELEMENT_ARRAY_BUFFER
and can be used to draw primitives. Because of this, you will implement index buffers in their own class, rather than reuse the Attribute
class.
The IndexBuffer class declaration
Create a new file, IndexBuffer.h
. You will be adding the declaration of the IndexBuffer
class to this new file. Like an Attribute
object, IndexBuffer
will contain an OpenGL handle and a count, with getter functions for both.
The copy constructor and assignment operator need to be disabled to avoid having multiple IndexBuffer
objects referencing the same OpenGL buffer. The Set
function takes an unsigned integer array and the length of the array, but there is a convenience overload that takes a vector as well:
class IndexBuffer { public: unsigned int mHandle; unsigned int mCount; private: IndexBuffer...