1234567891011121314151617181920212223242526272829 |
- #include "client/rendering/Lines.h"
- Lines::Lines() {
- vertexBuffer.bind();
- vertexBuffer.setFloatAttribute(0, 3, 0, 6);
- vertexBuffer.setFloatAttribute(1, 3, 3, 6);
- }
- void Lines::add(const Vector3& a, const Vector3& b, int color) {
- Vector3 c((color & 0xFF) / 255.0f, ((color >> 8) & 0xFF) / 255.0f, ((color >> 16) & 0xFF) / 255.0f);
- buffer.add(a);
- buffer.add(c);
- buffer.add(b);
- buffer.add(c);
- }
- void Lines::clear() {
- buffer.clear();
- }
- void Lines::build() {
- vertexBuffer.bindBuffer();
- vertexBuffer.setData(sizeof (Vector3) * buffer.getLength(), buffer.getData());
- }
- void Lines::draw() const {
- vertexBuffer.bindArray();
- vertexBuffer.drawLines(buffer.getLength() / 2);
- }
|