Mesh.cpp 574 B

1234567891011121314151617181920212223242526
  1. #include "client/rendering/Mesh.h"
  2. Mesh::Mesh() {
  3. vertexBuffer.bind();
  4. vertexBuffer.setFloatAttribute(0, 3, 0, 8);
  5. vertexBuffer.setFloatAttribute(1, 2, 3, 8);
  6. vertexBuffer.setFloatAttribute(2, 3, 5, 8);
  7. }
  8. void Mesh::add(const Triangle& data) {
  9. buffer.add(data);
  10. }
  11. void Mesh::clear() {
  12. buffer.clear();
  13. }
  14. void Mesh::build() {
  15. vertexBuffer.bindBuffer();
  16. vertexBuffer.setData(sizeof (Triangle) * buffer.getLength(), buffer.getData());
  17. }
  18. void Mesh::draw() const {
  19. vertexBuffer.bindArray();
  20. vertexBuffer.draw(buffer.getLength() * 3);
  21. }