Jump to content
  • Advertisement
Sign in to follow this  
Melanikus

[D3D9] Updating vertex buffer regions?

This topic is 2554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. Edited by Melanikus

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!