• Advertisement

Archived

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

Proper use of Vertex Buffers

This topic is 5831 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
Advertisement
I think you''re right, look at these steps :

INITIALIZATION
- 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)

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

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

SHUTDOWN
- Destroy the vertex buffer

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

Cya



/* 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.

bye,
-- 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