Lines.cpp 721 B

1234567891011121314151617181920212223242526272829
  1. #include "client/rendering/Lines.h"
  2. Lines::Lines() {
  3. vertexBuffer.bind();
  4. vertexBuffer.setFloatAttribute(0, 3, 0, 6);
  5. vertexBuffer.setFloatAttribute(1, 3, 3, 6);
  6. }
  7. void Lines::add(const Vector3& a, const Vector3& b, int color) {
  8. Vector3 c((color & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, ((color >> 16) & 0xFF) / 255.0f);
  9. buffer.add(a);
  10. buffer.add(c);
  11. buffer.add(b);
  12. buffer.add(c);
  13. }
  14. void Lines::clear() {
  15. buffer.clear();
  16. }
  17. void Lines::build() {
  18. vertexBuffer.bindBuffer();
  19. vertexBuffer.setData(sizeof (Vector3) * buffer.getLength(), buffer.getData());
  20. }
  21. void Lines::draw() const {
  22. vertexBuffer.bindArray();
  23. vertexBuffer.drawLines(buffer.getLength() / 2);
  24. }