still trying to fix the problem

This commit is contained in:
Anakin 2016-11-07 16:00:57 +01:00
parent 04d8c453f3
commit de76f7182a
1 changed files with 16 additions and 7 deletions

View File

@ -113,9 +113,6 @@ void OpenGLController::processInit()
glVertexAttribDivisor(4, 1);
glVertexAttribDivisor(5, 1);
// set buffer size
glBufferData(GL_ARRAY_BUFFER, MAX_MODEL_COUNT * sizeof(glm::mat4), NULL, GL_STREAM_DRAW);
// get the painter ready
try
{
@ -382,14 +379,26 @@ void OpenGLController::loadMsh(const char * path)
tempBufferData.data(),
GL_STATIC_DRAW
);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//TODO: limit to max model count
// set instance buffer data
std::vector<glm::mat4> 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);
glBindBuffer(GL_ARRAY_BUFFER, gluiInstanceBufferID);
glBufferData(
GL_ARRAY_BUFFER,
vModels.size() > MAX_MODEL_COUNT? MAX_MODEL_COUNT * sizeof(glm::mat4) : vModels.size() * sizeof(glm::mat4),
tempMVPs.data(),
GL_STREAM_DRAW
);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//glBindBuffer(GL_UNIFORM_BUFFER, gluiInstanceBufferID);
//glBufferSubData(GL_UNIFORM_BUFFER, sizeof(glm::mat4) * vModels.size(), NULL, tempMVPs.data());
//glBindBuffer(GL_UNIFORM_BUFFER, 0);
}