From 6c828bbe4f5aaabc0e272c4943ddbad74f7c8e01 Mon Sep 17 00:00:00 2001 From: James Gregory Date: Mon, 8 Apr 2013 22:08:44 -0700 Subject: [PATCH] Switch to using GL_DYNAMIC_DRAW. --- cocos2dx/cocoa/CCObject.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index c9022d3503..0799a02547 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -93,9 +93,15 @@ void CCObject::setGLBufferData(void *buf, GLuint bufSize, int slot) } glGenBuffers(1, &(m_bufferObject[slot])); m_bufferSize[slot] = bufSize; + + glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]); + glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW); + } + else + { + glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]); + glBufferSubData(GL_ARRAY_BUFFER, 0, bufSize, buf); } - glBindBuffer(GL_ARRAY_BUFFER, m_bufferObject[slot]); - glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW); } 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])); m_indexBufferSize[slot] = bufSize; + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferObject[slot]); + 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); } - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferObject[slot]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW); } #endif // EMSCRIPTEN CCObject* CCObject::copy()