History

Get rid of redundant GL calls for fog. Enable and disable fog during rendering stage of voxels. Moved the local light parameters to shader uniform arrays.

TonyPeng committed 12 years ago

Commit 56eadcb1 parent e212f9f13 files · +148 −63Browse files

Showing the changes to interface/src/renderer/ProgramObject.cpp (1 of 13 files). Show all

Unified · Split

interface/src/renderer/ProgramObject.cpp+15−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 //
1111
1212 #include "ProgramObject.h"
13+#include <glm/gtc/type_ptr.hpp>
1314
1415 ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) {
1516 }
@@ -22,3 +23,17 @@ void ProgramObject::setUniform(const char* name, const glm::vec3& value) { · 6 unmodified lines
2223 setUniformValue(name, value.x, value.y, value.z);
2324 }
2425
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+}