diff --git a/src/factories/MeshFactory.cpp b/src/factories/MeshFactory.cpp index 6fd465f..eec68b2 100644 --- a/src/factories/MeshFactory.cpp +++ b/src/factories/MeshFactory.cpp @@ -19,20 +19,17 @@ namespace FlowEngine { namespace Graphics { quad[3].position = {x, y + height, 0.0f}; quad[3].uv = {0.0f, 0.0f}; - uint bufferID = API::createBuffer(); - VertexArray* vertexArray = new VertexArray; - - vertexArray->bind(); - API::bindBuffer(GL_ARRAY_BUFFER, bufferID); - API::setBufferData(GL_ARRAY_BUFFER, Renderer2D::SPRITE_BYTE_SIZE, quad, GL_STATIC_DRAW); + VertexBuffer buffer(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW); + buffer.setData(Renderer2D::SPRITE_BYTE_SIZE, quad); + buffer.setAttribute(POSITION); + buffer.setAttribute(COLOR, 4, true); + buffer.setAttribute(UV); + buffer.setAttribute(MASK_UV); + buffer.setAttribute(TID); + buffer.setAttribute(MID); - API::enableVertexAttribute(POSITION); - API::enableVertexAttribute(UV); - - API::setVertexAttributePointer(POSITION, 3, GL_FLOAT, false, Renderer2D::VERTEX_BYTE_SIZE, offsetof(VertexData, position)); - API::setVertexAttributePointer(UV, 2, GL_FLOAT, false, Renderer2D::VERTEX_BYTE_SIZE, offsetof(VertexData, uv)); - API::unbindBuffers(GL_ARRAY_BUFFER); - vertexArray->unbind(); + VertexArray* vertexArray = new VertexArray; + vertexArray->addBuffer(&buffer); return vertexArray; }