views:

252

answers:

1

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?

+2  A: 

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);
Goz
Ah yup, I knew it would be something stupid like that.
meds