21 , m_bufferType(bufferType)
24 Eegeo_ASSERT(initialCapacity > 0,
"initial capacity must be greater than zero");
25 m_bufferData.reserve(initialCapacity);
34 void GenerateBuffers()
37 Eegeo_ASSERT(m_glBuffer == 0);
38 Eegeo_GL(glGenBuffers(1, &m_glBuffer));
39 Eegeo_GL(glBindBuffer(m_bufferType, m_glBuffer));
40 Eegeo_GL(glBufferData(m_bufferType, BufferCapacityBytes(), m_bufferData.data(), GL_DYNAMIC_DRAW));
41 Eegeo_BUFFER_MEMORY_ADD(m_glBuffer, BufferCapacityBytes());
43 Eegeo_GL(glBindBuffer (m_bufferType, 0));
48 Eegeo_BUFFER_MEMORY_REMOVE(m_glBuffer);
49 Eegeo_GL(glDeleteBuffers(1, &m_glBuffer));
59 void AddElement(
const T& element)
61 size_t prevCapacity = m_bufferData.capacity();
63 m_bufferData.push_back(element);
65 if (prevCapacity != m_bufferData.capacity())
72 int CurrentElementCount()
const {
return static_cast<int>(m_bufferData.size()); }
73 int BufferCapacity()
const {
return m_bufferData.capacity(); }
74 size_t BufferCapacityBytes()
const {
return m_bufferData.capacity() *
sizeof(T); }
75 size_t BufferDataBytes()
const {
return m_bufferData.size() *
sizeof(T); }
77 const std::vector<T>& GetBufferData()
const {
return m_bufferData; }
79 u32 GetGLBuffer() {
return m_glBuffer; }
84 std::vector<T> m_bufferData;