Original Post
I get an access violation when trying to lock the vertex buffer. I have wrapped the original function, bah look here:
/Sandman
[edited by - Saandman on October 4, 2002 8:49:27 PM]
// I call this function:
D3DCreateVertexBuffer(g_pVertexBuffer, yadayada, ...);
// and now i want to lock it and copy some shit into it
D3DFillVertexBuffer(g_pVertexBuffer, &Verts);
// And here's the function
/////////////////////////////////////////////////
bool D3DFillVertexBuffer(IDirect3DVertexBuffer8 *vBuffer, void *vertices)
{
BYTE *memPtr; // pointer to memory in vertex buffer
// lock vertex buffer
if (FAILED(vBuffer->Lock(0, 0, (BYTE **)&memPtr, 0)))
return false;
// copy memory
memcpy(memPtr, vertices, sizeof(vertices));
// unlock vertex buffer
if (FAILED(vBuffer->Unlock()))
return false;
return true;
}
Problem is, as I said, I get an access error reading memory location.. looking at debug values, it says memPtr is a bad pointer.. why, how can it be? has this anything to do with the error? i have the feeling i have missed something..another thing, the vertexbuffer object is still NULL (0x000000000whatever) after creating it in the first function.. ?!?!?!
Thanks..Help..