This is how i initialized the D3D11_BUFFER_DESC for my indices. When i go to bound it to the deviceContext i get this error.

D3D11 ERROR: ID3D11DeviceContext::IASetIndexBuffer: The Buffer trying to be bound as an IndexBuffer did not have the appropriate bind flag set at creation time to allow the Buffer to be bound as an IndexBuffer. [ STATE_SETTING ERROR #241: IASETINDEXBUFFER_INVALIDBUFFER]

And is kinda of strange becouse i setted the bindFlags to "D3D11_BIND_INDEX_BUFFER"

   D3D11_BUFFER_DESC buffDescIndices;

    ZeroMemory(&buffDescIndices, sizeof(D3D11_BUFFER_DESC));
    buffDescIndices.MiscFlags = 0;
    bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    buffDescIndices.Usage = D3D11_USAGE_DEFAULT;
    buffDescIndices.ByteWidth = sizeof(UINT) * ARRAYSIZE(indices);
    buffDescIndices.StructureByteStride = 0;
    buffDescIndices.CPUAccessFlags = 0;

    D3D11_SUBRESOURCE_DATA subResData2;
    subResData2.pSysMem = indices;
    HRESULT hr=device->CreateBuffer(&buffDescIndices, &subResData2, &mBoxIB);

And this is the deviceContext call

    deviceContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);

Yes i am totally the stupidest person on this planet i setted

bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;

Instead of

 buffDescIndices.BindFlags = D3D11_BIND_INDEX_BUFFER;


  • 1
    \$\begingroup\$ The Debug device usually provides excellent hints for silly mistakes like that. \$\endgroup\$ – Chuck Walbourn Jan 27 '17 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.