Fix the rendering bug on yosemite: due to the attribute channel number assigned by the compiler which colllides with the fixed pipeline vertex attrib channels, forced the attribute bind location after 3

This commit is contained in:
Sam Gateau 2014-10-28 18:22:06 -07:00
parent 825482499a
commit da70ec4c89

View file

@ -122,21 +122,36 @@ void Model::setOffset(const glm::vec3& offset) {
void Model::initProgram(ProgramObject& program, Model::Locations& locations, int specularTextureUnit) {
program.bind();
locations.tangent = program.attributeLocation("tangent");
locations.alphaThreshold = program.uniformLocation("alphaThreshold");
program.setUniformValue("diffuseMap", 0);
program.setUniformValue("normalMap", 1);
program.setUniformValue("specularMap", specularTextureUnit);
program.release();
}
void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations, int specularTextureUnit) {
initProgram(program, locations, specularTextureUnit);
program.bind();
locations.clusterMatrices = program.uniformLocation("clusterMatrices");
locations.clusterIndices = program.attributeLocation("clusterIndices");
locations.clusterWeights = program.attributeLocation("clusterWeights");
#ifdef Q_OS_MAC
// HACK: Assign explicitely the attribute channel to avoid a bug on Yosemite
glBindAttribLocation(program.programId(), 4, "tangent");
glLinkProgram(program.programId());
#endif
locations.tangent = program.attributeLocation("tangent");
locations.alphaThreshold = program.uniformLocation("alphaThreshold");
program.setUniformValue("diffuseMap", 0);
program.setUniformValue("normalMap", 1);
program.setUniformValue("specularMap", specularTextureUnit);
program.release();
}
void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations, int specularTextureUnit) {
initProgram(program, locations, specularTextureUnit);
#ifdef Q_OS_MAC
// HACK: Assign explicitely the attribute channel to avoid a bug on Yosemite
glBindAttribLocation(program.programId(), 5, "clusterIndices");
glBindAttribLocation(program.programId(), 6, "clusterWeights");
glLinkProgram(program.programId());
#endif
program.bind();
locations.clusterMatrices = program.uniformLocation("clusterMatrices");
locations.clusterIndices = program.attributeLocation("clusterIndices");
locations.clusterWeights = program.attributeLocation("clusterWeights");
program.release();
}