BufferData or BufferSubData? [VBO]

I have a programm, wich drawing quad into screen; it use VBO. My programm work good, but I have a question.

Tell me please if I wood use in place of:
[Delphi code][/b]
glBufferData(GL_ARRAY_BUFFER, sizeof(GLFLoat)3Count, @VertexBuffer[0], GL_STATIC_DRAW);
this code:
var Size:Integer;

Size := sizeof(GLFLoat)3Count;
glBufferData(GL_ARRAY_BUFFER, Size, nil, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, Size, @VertexBuffer[0]);

The performance don’t lower??? Fact is that I creating classes for simple using VBO. This is a reason, that I want to have max flexibility.

P.S. Use the simple english words, please.

Summary:

  • glBufferData = alloc and load data (if non-NULL pointer provided)
  • glBufferSubData = load data only

Think of glBufferData as:

delete [] ptr
ptr = malloc( size )
if ( data param != 0 )
 memcpy( ptr, data param, size );

and think of glBufferSubData as:

memcpy( ptr, data param, size );

So you need to do at least one glBufferData to allocate the buffer space, but from then on it is possibly more efficient to use glBufferSubData to change the contents. That is one reason that glBufferData is often provided a NULL pointer – all loading is then deferred to another buffer command such as glBufferSubData.

I say “possibly” because it depends on the driver, and calling BufferData with NULL isn’t strictly a deallocation and reallocation, but is something more subtle called orphaning (which you probably don’t care about yet).

That said, there are more efficient ways to load VBOs than glBufferSubData, when you’re ready for them. With your draw pass being a single quad, you don’t care yet – that is so little work it would be pointless to prefer one technique over another. But when you get into shoveling lots of data down the graphics pipe, it can make a big difference.