[D3D9] Updating vertex buffer regions?

Started by
1 comment, last by Melanikus 12 years, 4 months ago
EDIT: Ok, apparently I don't need to use the discard flag at all, so I'll just overwrite the region, is there a way to do that though?

Hey,

I'm working on a D3D 9 project and I am making a render list by packing state updates in an array of render elements, those RenderElements have an offset and a length that relate to a region in an index buffer, so you loop through each RenderElement change states as needed and draw the indexed meshes based on the region described by offset/length.

My problem is: How do I update those regions? I want to, after creating the index/vertex buffer, update regions based on that same offset/length pair. Direct3D 10 has some method called "[font="Consolas, Courier, monospace"]UpdateSubresource" [/font][font="Arial"]that seems to do just that but D3D9 doesn't, when you lock a vertex/index buffer for update the last parameter, "flags" must be D3DLOCK_DISCARD in my case, but the documentation states that: [/font]

"The application discards all memory within the locked region. For vertex and index buffers, the entire buffer will be discarded. This option is only valid when the resource is created with dynamic usage"

So the solution would be to write to an array and in the end copy the entire array to my vertex buffer? I can't write to specific portions of an index/vertex buffer?

Thanks in advance.
Advertisement
Yes, you can.

Use a simple 0 flag in Lock function call and write your regions.

Yes, you can.

Use a simple 0 flag in Lock function call and write your regions.


Yeah, I edited cause I realized that, I don't know why I was thinking I HAD to use discard ¬¬ =D

This topic is closed to new replies.

Advertisement