Code :generateElements(); //apparently this takes 8ms glBufferSubData(GL_ARRAY_BUFFER, 0, vertexBuffer.size() * sizeof(vertexBuffer), vertexBuffer.data()); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, elementBuffer.size() * sizeof(elementBuffer), elementBuffer.data()); glDrawElements(GL_TRIANGLES, vertexCount / 4 * 6, GL_UNSIGNED_INT, 0); vertexBuffer.clear(); elementBuffer.clear(); vertexCount = 0;
The function above normally takes < 2 ms to execute. However, it will jump to 8-30 ms about once every 2 seconds. I do not believe I have any poorly written code in the function, yet I cannot figure out why it is spiking. OpenGL 3.3 on Windows 8, Visual Studio 2013.