Original Post
Hey all, So I'm planning on moving into the game industry and I figured the best way to get started would be to build a game. Toward that end I am teaching myself OpenGL out of the "OpenGL Super Bible(3rd edition)" and I just got through the chapter on buffer objects. It sets up a vertex array of 30,000 random(each frame) vertices in a sphere and draws them as points. It allows you to run it using regular vertex arrays or as a buffer object and it records the frames per second so you can see how much faster using a buffer object is. But it isn't. It's about 2% slower every time. Can anyone think of a good reason why? Here's the code:
// Switch between buffer objects and plain old vertex arrays
void SetRenderingMethod(void)
{
if (useBufferObject)
{
glBindBuffer(GL_ARRAY_BUFFER, bufferID);
// No stride, no offset
glNormalPointer(GL_FLOAT, 0, 0);
glVertexPointer(3, GL_FLOAT, 0, 0);
if (!mapBufferObject)
{
if (animating)
{
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) *
numSphereVertices * 3, sphereVertexArray);
}
else
{
// If not animating, this gets called once
// to establish new static buffer object
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) *
numSphereVertices * 3, sphereVertexArray,
GL_STATIC_DRAW);
}
}
}
else
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
glNormalPointer(GL_FLOAT, 0, sphereVertexArray);
glVertexPointer(3, GL_FLOAT, 0, sphereVertexArray);
}
}
By the way, if mapBufferObject is turned on then the buffer object is, well, mapped already and we don't have to copy it over.