I am rendering text which is updated every frame. The text is a series of quads with texture coordinates that correspond to each character in a texture atlas. I need to orphan the vertex buffer object (VBO) every frame before sending the updated vertex and texture data to it. However, using glInvalidateBufferData() nor glBufferData() with a null pointer and the same size as the previous data doesn’t works. Theses are the calls I make every frame:
Perhaps you misunderstand the idea of invalidation.
See, when the wiki talks about using glBufferData with NULL, it’s done on the assumption that you will be uploading the actual data at a later time with glBufferSubData. By calling glBufferData to upload new data, you’re also allocating new memory for that data. In effect, you’re telling the driver to reallocate the storage again, even though you told it to reallocate the storage already.
That isn’t a recipe for performance.
The key thing about invalidation is that the size of the buffer should remain the same. That’s another reason why you shouldn’t use glBufferData to upload the contents of the buffer; that makes it possible to change the size of the buffer.
That being said:
However, using glInvalidateBufferData() nor glBufferData() with a null pointer and the same size as the previous data works.
Perhaps you’re missing a negative there. Because my read of that is that what you’ve done seems to work. Which it should. The problem is that its inefficient, since you’re reallocating twice.
That clears up a lot and that was typo. I meant to say it doesn’t work. I edited the original post to correct that. However, I need to change the size of the buffer depending on whether the string I am rendering gets larger or smaller. What is the best way to go about this then?