Jump to content
  • Advertisement
Sign in to follow this  
jmgunn87

adding and removing vertices from vertexbuffer

This topic is 3163 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

just a quick question, its been niggling me for a while, Which is the best way to go about adding and removing vertices from a directx vertex buffer? thanks.

Share this post


Link to post
Share on other sites
Advertisement
You don't. The size of a vertex buffer is fixed once it's created, and you can't resize it.

What you should do instead is simply keep track of how many vertices you have copied into a vertex buffer at any given time, that way you can specify the appropriate information when you make a Draw call.

Share this post


Link to post
Share on other sites
so, i want to remove a vertex from a buffer. if i cant resize or remove vertices i have to create either a new vertex buffer or use multiple vertex buffers? Is there not a more efficient way to manage this? i can imagine lots of creation and destruction of objects doing that, let alone the device state switches.

Share this post


Link to post
Share on other sites
Quote:

so, i want to remove a vertex from a buffer. if i cant resize or remove vertices i have to create either a new vertex buffer or use multiple vertex buffers? Is there not a more efficient way to manage this? i can imagine lots of creation and destruction of objects doing that, let alone the device state switches.

It is not possible. It would be just as inefficient to resize the buffer directly as it would be for you to recreate it (within some reasonable, but negligible, margin of error).

Instead, as MJP said, you want to simply write to only a portion of the buffer, and keep track of what you have written so you specify only that many vertices should be used when drawing.

Share this post


Link to post
Share on other sites
hmmm...

In your opinion(s) would using a single vertex buffer( created with a large size ) to store all vertices in a scene be a good idea or should i choose to create individual buffers for each object? Which is optimal?

I'm in the process at the moment of implementing batch rendering and need to weigh up the options here.

Any advice would be very much appreciated!

Share this post


Link to post
Share on other sites
One more thing bugging me now,

How do i tell the device which vertices to draw in an ID3DXMesh object?
Thats all wrapped up with DrawSubset().

Share this post


Link to post
Share on other sites
This only way you can add/remove vertex at will is to use DrawPrimitiveUP/DrawIndexdPrimitiveUP. BUT !! your vertex array will NOT be located in video memory.

Share this post


Link to post
Share on other sites
damn, i dont want to use that! lol

or i can just use drawindexedprimitive using D3DPT_TRIANGLELIST which is what D3DXMESH uses for drawsubset() as i have just found out. hmmmm maybe i am overcomplicating this.

Share this post


Link to post
Share on other sites
As soon as you will change your vertex/index buffer you will lose performance.

Now you can only modify your index buffer to add/remove index in order to change the mesh topology.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!