Fast memcpy for openGL VBO

Started by
1 comment, last by Gorax 13 years, 5 months ago
Hi everyone,
I'm trying to transfer data to vbo. However, with the current setup, it is slower than reinitializing the vbo with new data.

m_vertexBuffer is a std::vector<float> container, and I'm working on win32 platform.

glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);GLfloat* vertexPtr = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);if(vertexPtr){	memcpy(vertexPtr, &m_renderingData[0], sizeof(float)*m_renderingData.size());	glUnmapBuffer(GL_ARRAY_BUFFER);}glBindBuffer(GL_ARRAY_BUFFER, 0);


Perhaps anyone had faced this problem and has a solution? Google had failed me this time.
Advertisement
perhaps with glBufferSubData or glBufferData?
Quote:Original post by Juanxo
perhaps with glBufferSubData or glBufferData?


I'm going to have to agree with this approach. I've never been able to get the (un)map functions to work quite right (probably my fault more than anything), but the buffer functions work well. Textures get updated the exact same way, so I'm not entirely sure why they have the (un)map functions. Seems like overkill to me.

This topic is closed to new replies.

Advertisement