失火#1
I found 这里有一个答案 http://www.gamedev.net/topic/418056-memory-array-vs-dynamic-vbo-which-is-better/#这让我想到使用glSubBufferData
用于将数据停放在数组中,并使用glBufferData
仅用于初始分配。最终这不起作用(如果 vb 太大,则只会更新前 3 个元素),
So,
glBufferData( glBufferData(
GL_ARRAY_BUFFER, //Specifies the target buffer object.
rawDynamicData.size() * sizeof( VertexType ),
0, // NO INITIAL DATA
GL_DYNAMIC_DRAW // I plan to update the data every frame
) ; CHECK_GL ;
那么对于第一个and后续更新:
// Update the whole buffer
glBufferSubData(GL_ARRAY_BUFFER, 0,
rawDynamicData.size()*sizeof(VertexType), &rawDynamicData[0]) ;
这似乎有效。
看来。但事实并非如此。
我唯一能做的就是停止使用顶点缓冲区并使用客户端内存顶点数组.
这看起来如下:
// do all your vertex attrib/glVertexAttrib enable commands:
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPC), &debugPoints->data[0].pos.x) ;
CHECK_GL ;
glEnableVertexAttribArray(0); CHECK_GL ;
// ..do glVertexAttrib* for all attributes you have..
// then just flush your draw command
glDrawArrays(GL_POINTS, 0, debugPoints->data.size());
简而言之,我发现对动态数据使用顶点缓冲区是either具有挑战性的or不支持。