diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index cbd1b6a..393f8bc 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -277,9 +277,6 @@ void OpenGLController::updateScene() for (unsigned int modelIndex = 0; modelIndex < vModels.size(); modelIndex++) { // give the MVPs to the shader - glBindBuffer(GL_UNIFORM_BUFFER, gluiInstanceBufferID); - glBufferSubData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), NULL, &getMVPMatrix(0)); - glBindBuffer(GL_UNIFORM_BUFFER, 0); //glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]); @@ -385,4 +382,14 @@ void OpenGLController::loadMsh(const char * path) tempBufferData.data(), GL_STATIC_DRAW ); + + //TODO: limit to max model count + std::vector tempMVPs; + + for (int i = 0; i < vModels.size(); i++) + tempMVPs.push_back(getMVPMatrix(i)); + + glBindBuffer(GL_UNIFORM_BUFFER, gluiInstanceBufferID); + glBufferSubData(GL_UNIFORM_BUFFER, sizeof(glm::mat4) * vModels.size(), NULL, tempMVPs.data()); + glBindBuffer(GL_UNIFORM_BUFFER, 0); }