Question

I get the error in the title in the following code:

  std::vector<short> GetIndicesFromID3DXMesh(ID3DXMesh* model)
{
    //LPVOID * ppData;
    DWORD stride = sizeof(short);
    BYTE* ibptr = NULL;

    short* indices = new short[model->GetNumFaces() * 3];

    std::vector<short> copy;

    model->LockIndexBuffer(0, (LPVOID*)&indices);

    for(size_t i = 0; i < model->GetNumFaces() * 3; i++)
    {
        copy.push_back(indices[i]);
    }

    model->UnlockIndexBuffer();

    delete []indices;
    return copy;
}

At the line delete[]indices

I don't know why I get it, I don't know how I get it, can i not get it?

Was it helpful?

Solution

Don't allocate the space for your indices. DirectX does the allocation and then frees it when you call unlock.

short* indices = NULL;
model->LockIndexBuffer(0, (LPVOID*)&indices);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top