c++directxdirectx-11index-buffer

Using Index buffers in DirectX 11; how does it know?


Let's say I create two vertex buffers, for two different meshes.

     (I'm assuming creating separate buffers for separate meshes is how it's usually done)

Now, let's say I want to draw one of the meshes using an index buffer. Looking at the book Practical Rendering and Computation with Direct3D 11 it doesnt seem like the creation of an index buffer in any way references a vertex buffer, so how does the index buffer know (during input assembly) what vertex buffer to act on?

I've done some googling without answers, which leads me to assume there's something obvious about it that I'm missing.


Solution

  • You are right, index buffers do not reference specific vertex buffers. During DrawIndexed active index buffer is used to supply indices into active vertex buffers (the ones you set using SetIndexBuffer/SetVertexBuffers).