Showing the changes to interface/src/renderer/ProgramObject.cpp (1 of 13 files). Show all
Unified · Split
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | // |
| 11 | 11 | |
| 12 | 12 | #include "ProgramObject.h" |
| 13 | +#include <glm/gtc/type_ptr.hpp> | |
| 13 | 14 | |
| 14 | 15 | ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) { |
| 15 | 16 | } |
| @@ -22,3 +23,17 @@ void ProgramObject::setUniform(const char* name, const glm::vec3& value) { · 6 unmodified lines | ||
| 22 | 23 | setUniformValue(name, value.x, value.y, value.z); |
| 23 | 24 | } |
| 24 | 25 | |
| 26 | +void ProgramObject::setUniformArray(const char* name, const glm::vec3* values, int count) { | |
| 27 | + GLfloat* floatVal = new GLfloat[count*3]; | |
| 28 | + int index = 0; | |
| 29 | + for(int i = 0; i < count; i++) { | |
| 30 | + assert(index < count*3); | |
| 31 | + const float* valPtr = glm::value_ptr(values[i]); | |
| 32 | + floatVal[index++] = valPtr[0]; | |
| 33 | + floatVal[index++] = valPtr[1]; | |
| 34 | + floatVal[index++] = valPtr[2]; | |
| 35 | + } | |
| 36 | + | |
| 37 | + setUniformValueArray(name, floatVal, count, 3); | |
| 38 | + delete[] floatVal; | |
| 39 | +} | |