I've a class that creates a cube using VertexPositionColor and these vertices are stored in a VertexBuffer. Now i would like to dynamically change the color of my vertices. In my class i have a reference to a VertexPositionColor array wich contain all my vertices. I've wrote a SetColor function wich accept a Color in parameter and update each Color property of my vertices. But when i call it, it doesn't work. This is normal because vertices are stored in VertexBuffer and is not updated.
So, how can i update vertices property and keep using VertexBuffer?
SetData(vertices)
on the vertex buffer after you have modified the data. It's best to do this only once a frame, IF the data has been modified. \$\endgroup\$DynamicVertexBuffer
- you shouldn't be using a regularVertexBuffer
for dynamic data. \$\endgroup\$