Commit de76f718 authored by Anakin's avatar Anakin

still trying to fix the problem

parent 04d8c453
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment