Recently I have tried adding rendering with multiple meshes in my program. This did not go too well. The attempt I currently have goes like this
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(VERTEX)* nVertices.at(i);
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
bd.MiscFlags = 0;
bd.StructureByteStride = 0;
vertexData.pSysMem = vertices.at(i);
vertexData.SysMemPitch = 0;
vertexData.SysMemSlicePitch = 0;
dev->CreateBuffer(&bd, &vertexData, &pVBuffer);
looping through the meshes and doing like wise for the index buffer. Similar to this, the render code loops through the mesh data as well:
UINT stride = sizeof(VERTEX);
UINT offset = 0;
devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
devcon->IASetIndexBuffer(pIBuffer, DXGI_FORMAT_R32_UINT, 0);
devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
devcon->DrawIndexed(nIndices.at(i), 0, 0);
But all of this only ends up rendering one of the meshes. Does anyone know what I need to change to fix this or whether I need to have a completely different approach? Thanks in advance!
pVBufferobject, you'll only have access to one for drawing. What does the code between your two posted segments look like? \$\endgroup\$