Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Proper use of Vertex Buffers

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

I understand the main concept of vertex buffer / index buffers but what is the best way to use them? The vertex buffer should be initialized only once, and it shouldn''t be too big or too small. (nvidia proposes a 4k vb) Lets say the scene will have about 10000 vertices. Creating a vb this size would be a little bit to big I think, so what I would do is create a vb with size 4000 and fill it each time before calling DrawIndexedPrimitive. Is this really that fast or am I doing something wrong? ALex

Share this post

Link to post
Share on other sites
I think you''re right, look at these steps :

- Create the vertex buffer with a big size
- Create te index buffer with a big size (could be static if your objects does not morph)

2 Options:
- Fill an array with transformed/untransformed vertices
- Lock the vertex buffer
- memcpy the array into the vertex buffer
- Unlock the vertex buffer

- Do step #1 once in INITIALIZATION
- Apply world transformations on vertices in the vertex buffer

- Destroy the vertex buffer

These are methods. Maybe there are others, but I think these are the most straightforward.


/* Bullmax */
Reality has many forms : good and evil, black and white, ying and yang.

Share this post

Link to post
Share on other sites
dont use 4000, use 4096 if you want 4k.
should better align to page/cache-line bounds.

besides i read an ati doc. that suggested 4MB(!) vertex buffer.
i think the VB should be quit big.
just dont fire all your polys at once.

one important thing if you use dynamic geometry (and hence dynamic index/vertex buffers) is to create them with the "dynamic" flag and fill them with "nooverwrite"/"discard" flags set appropriately.
read more on this in the SDK.

-- foobar

--- foobar
We push more polygons before breakfast than most people do in a day

Share this post

Link to post
Share on other sites

  • 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!