Ogre Version: 14 from github.
Operating System: Debian GNU/Linux
Render System: OpenGL Rendering Subsystem
After creating a mesh using "MeshManager::getSingleton().createManual", I have populate it like this:
Code: Select all
mesh->createVertexData();
mesh->sharedVertexData->vertexCount = vertexEntriesPerPoint();
auto* decl = mesh->sharedVertexData->vertexDeclaration;
auto* bind = mesh->sharedVertexData->vertexBufferBinding;
size_t offset = 0;
offset += decl->addElement(0, offset, VET_FLOAT3, VES_POSITION).getSize();
auto vbuf =
HardwareBufferManager::getSingleton().createVertexBuffer(
offset, vertex.size()/vertexEntriesPerPoint(), HBU_GPU_ONLY);
vbuf->writeData(0, vbuf->getSizeInBytes(), vertex.data(), true);
bind->setBinding(0, vbuf);
auto ibuf =
HardwareBufferManager::getSingleton().createIndexBuffer(
HardwareIndexBuffer::IT_16BIT, indexes.size(), HBU_GPU_ONLY);
ibuf->writeData(0, ibuf->getSizeInBytes(), indexes.data(), true);
SubMesh* sub = mesh->createSubMesh();
sub->operationType = RenderOperation::OT_LINE_STRIP;
// sub->useSharedVertices = true;
sub->indexData->indexBuffer = ibuf;
sub->indexData->indexStart = 0;
sub->indexData->indexCount = indexes.size();
Everything works. Now, I want to use the same mesh object, but I want to change the mesh. I suspect I have the options of:
- Doing everything again, from scratch: recreate the VertexData, recreate the buffers and repopulate them.
- Re-use buffers and change the data.
How do I do number 1 properly?
And how do I do number 2?
Also... any recommendations?