Reusing index and vertex buffer generates artefacts

When I reuse index buffer and fill it with new data that is smaller that previous data in that buffer, the rest of “dirty” data in index buffer is also used for rendering.
And because of that I get strange artefact’s.

I solve it by filling the buffer with zeros and then once again with my new data.

Shouldn’t it work that SetData sets also length of the data in buffer that should be used for rendering so I can declare much bigger buffers than data I will fill it which and reused it as often I want?

The length of the buffer used is determined in the drawPrimitives function. If want to only draw the first 6 triangles you do it there, the length of the buffer doesn’t matter

Sorry on mobile can’t post exact code

1 Like

You’re absolutely right. Thank you very much.