// calculate the number of bytes of data size = m_sizeVertex*m_numVertices; HRESULT hr = d3ddev->CreateVertexBuffer(size, D3DUSAGE_DYNAMIC, 0, // DON'T pass the FVF code we using vertex decleration D3DPOOL_DEFAULT, &m_buffer, NULL);
I add data to my buffer in this way:
writeData(unsigned int offset, unsigned int length, void* data)
{
// store the length of actual data length
m_length = length;
// determine required buffer size in bytes
unsigned int size = length*m_sizeVertex;
// lock v_buffer and load the vertices into it
void* vertices = 0;
HRESULT hr = m_buffer->Lock(offset, size, &vertices, D3DLOCK_DISCARD);
if (FAILED(hr)){
throw exception("Could not lock buffer!");
}
memcpy(vertices, data, size);
hr = m_buffer->Unlock();
if (FAILED(hr)){
throw exception("Could not unlock buffer!");
}
}
Everything is working fine until I try to reuse the buffer, which has rendered other data before. In that case I got fragments of the old render data as garbage between new render data. If I everytime create a new buffer on data switch anything is working fine. It looks to me that the discard flag is ignored.
Thanks for any help.













