Say, for example, I have a list of enemies. Each enemy is a textured quad which is the stored in a singular shared VertexBuffer and IndexBuffer with the buffer usage set to BufferUsage.WriteOnly (static buffers essentially). Then only one call to DrawIndexedPrimitives would be needed to draw all enemies. The problem is enemies have to move around at some point. It is quite easy to change the BasicEffect Matrixes to get the desired result of enemy movement.

My question is how can I change the BasicEffect Matrixes after each Quad using only one static VertexBuffer and IndexBuffer?

Changing the Matrixes for movement is normal, right?

I thought about using a DynamicVertexBuffer instead, is this more effcient for my case?

What about 4.0 streaming? Would a call to GraphicsDevice.SetVertexBuffers(array); (where array is whatever you send it that frame) be a better idea?

I know this question may seem silly for quads considering SpriteBatch is pretty good at doing this already for sprites. But, I am going to add in my own dazzling effects and want to draw textured quads this way. Plus, I'm also OCD and want this to be organized and efficient.

Any help on the matter is appreciated.


2 Answers 2


You should draw each unit in different draw calls. VertexBuffer is meant only for static geometry which doesn't move. You shouldn't use DynamicVertexBuffer either since you are not actually changing any vertices or indices. So, draw every unit ( = quad ) in seperate draw call. You could do some instancing to draw more efficiently, you can find plenty of information about that by googling.

EDIT: I have to note that if your units move rarely, it may be more efficient to build VertexBuffer every time they move. For example if you were making chess game where there may be minutes between turns. However, I wouldn't use VertexBuffer in that case either since I doubt I'd run into any performance problems because of that, and for me faster development is more important than minor performance boost.


You should use for each object a different world matrix. You simply set the world used for an object to the BasicEffect before it gets drawn. If you want to change the position of an object you set a new vector to the associated matrix's translation.

Do not change the VertexBuffer. Mention that any Vertex will pass a calculation step anyway where world, view and projection are involved. Changing the world will only upload one matrix to the GPU, every thing else will use the same amount of time. To create and fill a new VertexBuffer will need to upload all the new vertices.

As you want to use only one Vertex- and IndexBuffer you need to store the range of indices used by each object somewhere and pass them to the drawing method as startIndex and primitivesCount (used indices/3 for TriangleList), after you set the associated world matrix to the BasicEffect.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .