Hi everyone!
I have some problem in drawing multiple objects. If i load and draw only one model, it draws correctly, but if i add more objects, some of them draw partially, and i have warning ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL].
If i draw only one model, i don't have this warning.
For each model in render function i do following actions:
deviceContext->PSSetSamplers(0, 1, &m_samplerState);
deviceContext->IASetInputLayout(m_layout);
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
deviceContext->DrawIndexed(indexDrawAmount, indexStart, 0);
unsigned int stride;
unsigned int offset;
stride = sizeof(VertexType);
offset = 0;
deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, offset);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->PSSetSamplers(0, 0, NULL);
deviceContext->IASetInputLayout(NULL);
deviceContext->VSSetShader(NULL, NULL, 0);
deviceContext->PSSetShader(NULL, NULL, 0);
Each model has it's own vertex and index buffers, which being initialized when i load .obj file.
Each index is unsigned int.
When i'm trying to use Graphics Debugger in Visual Studio, i catch unhandled exception in line
deviceContext->DrawIndexed(indexDrawAmount, indexStart, 0);