|
@@ -1,5 +1,36 @@
|
|
|
#include "rendering/VertexBuffer.h"
|
|
|
|
|
|
+VertexBuffer::Attributes& VertexBuffer::Attributes::addFloat(int count) {
|
|
|
+ attributes.add(GL::Attribute::newFloat(count));
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
+VertexBuffer::Attributes& VertexBuffer::Attributes::addColor4() {
|
|
|
+ attributes.add(GL::Attribute::newColor(4));
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
+VertexBuffer::Attributes& VertexBuffer::Attributes::addSpacer() {
|
|
|
+ attributes.add(GL::Attribute::newDummy());
|
|
|
+ return *this;
|
|
|
+}
|
|
|
+
|
|
|
+void VertexBuffer::Attributes::set() const {
|
|
|
+ int size = 0;
|
|
|
+ for(const GL::Attribute& a : attributes) {
|
|
|
+ size += a.getSize();
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ int offset = 0;
|
|
|
+ for(const GL::Attribute& a : attributes) {
|
|
|
+ if(!a.isDummy()) {
|
|
|
+ GL::vertexAttribPointer(index, a, size, offset);
|
|
|
+ }
|
|
|
+ offset += a.getSize();
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
VertexBuffer::VertexBuffer() : vertexArray(0), vertexBuffer(0), size(0) {
|
|
|
}
|
|
|
|