I’ve got some ofBufferObjects that I’ve filled with a vector of glm::vec3s. At intervals, I want to upload new data into each. Sometimes there will be more data, sometimes there will be less data, but it’ll be a different amount each time I upload.
each time I want to refresh with new data, but it doesn’t seem to be refreshing with the new values. There’s also ofBufferObject::updateData, but that doesn’t seem to increase the size of the buffer if there was fewer items to start with.
So (for future reference) what I’m now doing is the following-
allocate a buffer to the maximum feasible size that I might use, once when the program starts with ofBufferObject::allocate(emptyVectorOfMaximumSize, GL_DYNAMIC_DRAW)
each time I want to update, call ofBufferObject::updateData(0, dataToBeUsed) to upload the new data
This works, but I’m still curious about clearing data.
ofBufferObject does not offer this functionality but you can use the OpenGL API instead; glClearBufferData is what you’re looking for. Below is an example where I specify a clear color but you can also use NULL which sets all buffer data to zero.