Jump to content
  • Advertisement

DX11 Drawing multiple objects

Recommended Posts

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->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->PSSetSamplers(0, 0, 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);


dx11 2018-10-05 18-44-58-83.bmp

Share this post

Link to post
Share on other sites

Well, warning is self explanatory - there is something wrong with your index buffer.

Do both models work if you load and draw only one of them?

Do both models work if you load both of them but draw only one of them?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!