Skip to content

Commit

Permalink
Use object oriented buffer when generating a quad
Browse files Browse the repository at this point in the history
  • Loading branch information
massile committed Nov 15, 2016
1 parent 901e4f6 commit a61a064
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/factories/MeshFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<glm::vec3>(POSITION);
buffer.setAttribute<uint>(COLOR, 4, true);
buffer.setAttribute<glm::vec2>(UV);
buffer.setAttribute<glm::vec2>(MASK_UV);
buffer.setAttribute<float>(TID);
buffer.setAttribute<float>(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;
}
Expand Down

0 comments on commit a61a064

Please sign in to comment.