0
votes

I have a basic question about directx (im using d3d9), after looking at some tutorials I want to create a basic 3d program and I don't seem to get 1 thing.

Do I need to copy the vertices/indices every time I want to draw a model into 1 vertex buffer? Or can I load multiple models into 1 vertex/indices buffer? Or do I need to make multiple vertex/indices buffers, each for every model?

1

1 Answers

0
votes

You are free to do as you want, if you look at IDirect3DDevice9::DrawIndexedPrimitive, you will find BaseVertexIndex and StartIndex, it allows you to offset into the vertex and index buffer, so yes, you can pack several geometries in the same buffer, this is useful to reduce the amount of call to SetIndices and SetStreamSource. If your vertex stride change, you still have to call the later with a byte offset and the new stride.

Unless you deal with dynamic geometry, you usually copy the data once to your buffers and reuse them across frame too.