1234567891011121314151617181920212223242526272829303132333435 |
- #include <GL/glew.h>
- #include "wrapper/Attributes.h"
- Attributes& Attributes::addFloat(int count) {
- attributes.add({count, sizeof (float), GL_FLOAT, false});
- return *this;
- }
- Attributes& Attributes::addColor4() {
- attributes.add({4, sizeof (unsigned char), GL_UNSIGNED_BYTE, true});
- return *this;
- }
- Attributes& Attributes::addSpacer() {
- attributes.add({0, 0, -1, false});
- return *this;
- }
- void Attributes::set() const {
- int size = 0;
- for(const Attribute& a : attributes) {
- size += a.count * a.size;
- }
- int index = 0;
- int offset = 0;
- for(const Attribute& a : attributes) {
- if(a.type != -1) {
- glVertexAttribPointer(index, a.count, a.type, a.normalized, size, static_cast<char*> (0) + offset);
- glEnableVertexAttribArray(index);
- }
- offset += a.count * a.size;
- index++;
- }
- }
|