Search code examples
c++3ddirect3dvertex-buffer

Multiple meshes in one vertex buffer?


Do I need to use one vertex buffer per mesh, or can I store multiple meshes in one vertex buffer? If so, should I do it, and how would I do it?


Solution

  • You can store multiple meshes in one vertex buffer. You may gain some performance by putting several small meshes in in one buffer. For really large meshes you should use seperate buffers. SetStreamSource lets you specify the vertex buffer offset for your current mesh.

    pRawDevice->SetStreamSource( 0, m_VertexBuffer->GetBuffer(), m_VertexBuffer->GetOffset(), m_VertexBuffer->GetStride() );