1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include "rendering/VertexBuffer.h"
- VertexBuffer::VertexBuffer()
- : vertexArray(GL::genVertexArray()), vertexBuffer(GL::genBuffer()) {
- }
- 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) {
- bindBuffer();
- GL::bufferDataStatic(size, data);
- }
- void VertexBuffer::setStreamData(int size, const void* data) {
- bindBuffer();
- GL::bufferDataStream(size, data);
- }
- void VertexBuffer::setDynamicData(int size, const void* data) {
- 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);
- }
|