#include "rendering/VertexBuffer.h" VertexBuffer::VertexBuffer() : vertexArray(GL::genVertexArray()), vertexBuffer(GL::genBuffer()), size(0) { } VertexBuffer::~VertexBuffer() { GL::deleteBuffer(vertexBuffer); GL::deleteVertexArray(vertexArray); } void VertexBuffer::bindArray() const { GL::bindVertexArray(vertexArray); } void VertexBuffer::bindBuffer() const { GL::bindBuffer(vertexBuffer); } void VertexBuffer::setAttributes(const Attributes& attributes) { bindArray(); bindBuffer(); attributes.set(); } void VertexBuffer::setStaticData(int size, const void* data) { VertexBuffer::size = size; bindBuffer(); GL::bufferDataStatic(size, data); } void VertexBuffer::setStreamData(int size, const void* data) { VertexBuffer::size = size; bindBuffer(); GL::bufferDataStream(size, data); } void VertexBuffer::setDynamicData(int size, const void* data) { VertexBuffer::size = size; bindBuffer(); GL::bufferDataDynamic(size, data); } void VertexBuffer::updateData(int offset, int size, const void* data) { bindBuffer(); GL::bufferSubData(offset, size, data); } void VertexBuffer::draw(int vertices, int offset) { bindArray(); GL::drawTriangles(offset, vertices); } void VertexBuffer::drawStrip(int vertices, int offset) { bindArray(); GL::drawTriangleStrip(offset, vertices); } void VertexBuffer::drawPoints(int vertices, int offset) { bindArray(); GL::drawPoints(offset, vertices); } int VertexBuffer::getSize() const { return size; }