#include "MyBatch.h" void MyBatch::setup_element_buffers() { glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]); // TODO: Maybe make the next line use a typedef instead of MyShaderProgram::ColorType glBufferData(GL_ARRAY_BUFFER, m_elements.size() * sizeof(MyBatchTestShaderProgram::ColorType), NULL, GL_STREAM_DRAW); } void MyBatch::setup_vao() { glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, NULL); glVertexAttribDivisor(0, 0); // Only need to send the mesh data once glVertexAttribDivisor(1, 1); // Send the color data for each instance drawn } void MyBatch::update_element_buffers() { // TODO: There are probably better ways to do this. Should check with the old engine to see what I did there. glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]); glBufferData(GL_ARRAY_BUFFER, m_elements.size() * sizeof(MyBatchTestShaderProgram::ColorType), NULL, GL_STREAM_DRAW); glBufferSubData(GL_ARRAY_BUFFER, 0, m_elements.size() * sizeof(MyBatchTestShaderProgram::ColorType), m_elements.data()); }