Reputation: 1747
I use VertexBuffers in XNA. My question is can they be reused? What I mean is: 1. I put some data in VertexBuffer 2. After some time data becomes obsolete 3. I put new data to sam VertexBuffer (without disposing)
In code it would look like this
var verts = new ...
VertexBuffer vb = new ...
vb.SetData(verts);
...SOME TIME PASSES vb BECOMES OBSOLETE...
var verts2 = new ...
vb.SetData(verts2);
Upvotes: 1
Views: 298
Reputation: 1353
Yes... although you'll want to declare your vertex buffer as type DynamicVertexBuffer (instead of just plain old VertexBuffer) and subscribe to the ContentLost event to repopulate the buffer in case it's lost (due to memory pressure on the graphics card for example).
Upvotes: 2