From da70ec4c893dbd7d9018c838f6cfc079784969ee Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 28 Oct 2014 18:22:06 -0700 Subject: [PATCH] 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 --- interface/src/renderer/Model.cpp | 43 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index e949e9a811..a7cbfebdd6 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -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(); }