Switch to using GL_DYNAMIC_DRAW.

This commit is contained in:
James Gregory 2013-04-08 22:08:44 -07:00
parent 809b77d632
commit 6c828bbe4f
1 changed files with 16 additions and 4 deletions

View File

@ -93,9 +93,15 @@ void CCObject::setGLBufferData(void *buf, GLuint bufSize, int slot)
} }
glGenBuffers(1, &(m_bufferObject[slot])); glGenBuffers(1, &(m_bufferObject[slot]));
m_bufferSize[slot] = bufSize; m_bufferSize[slot] = bufSize;
}
glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]); glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]);
glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW);
}
else
{
glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]);
glBufferSubData(GL_ARRAY_BUFFER, 0, bufSize, buf);
}
} }
void CCObject::setGLIndexData(void *buf, GLuint bufSize, int slot) void CCObject::setGLIndexData(void *buf, GLuint bufSize, int slot)
{ {
@ -108,9 +114,15 @@ void CCObject::setGLIndexData(void *buf, GLuint bufSize, int slot)
} }
glGenBuffers(1, &(m_indexBufferObject[slot])); glGenBuffers(1, &(m_indexBufferObject[slot]));
m_indexBufferSize[slot] = bufSize; m_indexBufferSize[slot] = bufSize;
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferObject[slot]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferObject[slot]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW);
}
else
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferObject[slot]);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, bufSize, buf);
}
} }
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
CCObject* CCObject::copy() CCObject* CCObject::copy()