No more Magic numbers and fixing the code path for linux

This commit is contained in:
Sam Gateau 2015-01-16 10:26:51 -08:00
parent 8634d86167
commit 6b55b4ff82
3 changed files with 15 additions and 3 deletions

View file

@ -498,9 +498,12 @@ void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) {
// NOT working so we ll stick to the uniform float array until we move to core profile
// GLuint bo = getBufferID(*uniformBuffer);
//glUniformBufferEXT(_shader._program, slot, bo);
#else
#elif defined(Q_OS_WIN)
GLuint bo = getBufferID(*uniformBuffer);
glBindBufferRange(GL_UNIFORM_BUFFER, slot, bo, rangeStart, rangeSize);
#else
GLfloat* data = (GLfloat*) (uniformBuffer->getData() + rangeStart);
glUniform4fv(slot, rangeSize / sizeof(GLfloat[4]), data);
#endif
CHECK_GL_ERROR();
}

View file

@ -54,6 +54,8 @@ public:
glm::vec3 L21 ; float spare7;
glm::vec3 L22 ; float spare8;
static const int NUM_COEFFICIENTS = 9;
void assignPreset(int p) {
switch (p) {
case DeferredLightingEffect::OLD_TOWN_SQUARE: {
@ -387,7 +389,7 @@ void DeferredLightingEffect::render() {
sh.assignPreset(0);
}
for (int i =0; i <9; i++) {
for (int i =0; i <SphericalHarmonics::NUM_COEFFICIENTS; i++) {
program->setUniformValue(locations->ambientSphere + i, *(((QVector4D*) &sh) + i));
}
}

View file

@ -206,7 +206,7 @@ void Model::initProgram(ProgramObject& program, Model::Locations& locations, boo
} else {
locations.materialBufferUnit = -1;
}
#else
#elif defined(Q_OS_WIN)
loc = glGetUniformBlockIndex(program.programId(), "materialBuffer");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, 1);
@ -214,6 +214,13 @@ void Model::initProgram(ProgramObject& program, Model::Locations& locations, boo
} else {
locations.materialBufferUnit = -1;
}
#else
loc = program.uniformLocation("materialBuffer");
if (loc >= 0) {
locations.materialBufferUnit = loc;
} else {
locations.materialBufferUnit = -1;
}
#endif
if (!program.isLinked()) {