Archived

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

GekkoCube

multiple vertex buffer question(s)

Recommended Posts

GekkoCube    116
I have a terrain mesh that i tried to draw with one great big vertex buffer. Obviously, that did not work very well. So now im deciding to use multiple vertex buffers - each having maybe 1,000 vertices (or is it polygons?). Question: The vertex buffer is defined something like this....
  
LPD3DVERTEXBUFFER vb; // or something to that effect.

  
is this a pointer? if i want multiple vertex buffers, should i define it like the following?
  
LPD3DVERTEXBUFFER *vb;
// or

LPD3DVERTEXBUFFER **vb;
  
thanks.

Share this post


Link to post
Share on other sites
flaXen    122
LPD3DVERTEXBUFFER is a pointer (indicated by "LP" at the beginning). If you want to create an array of vertex buffers, use LPD3DVERTEXBUFFER *vb.

Share this post


Link to post
Share on other sites
steg    390
You could if you like also use:

LPD3DVERTEXBUFFER vb[AMOUNT_BUFFERS];

Although this would take in the fact that you would know how many buffers you are creating which isn''t always the case.

Share this post


Link to post
Share on other sites
GekkoCube    116
Thank you all for the quick replies.
Now i have one more question, maybe two...about vertex buffers.

What would be the best size for VB''s (1000 vertices)?

Is it quite normal to render multiple VB''s for a single object, such as a terrain mesh?

Is it OK to lock, fill, and unlock the VB(s) at every frame?
(I might need to do this on my VB''s for my constantly changing terrain mesh).

Thanks.

Share this post


Link to post
Share on other sites
GekkoCube    116
My set of vertices never change, but the quads that I use are because Im using a CLOD algorithm.
So far, it works fine with very good detail.

Again, the set of vertices I use each frame changes, so i need to fill my VB at every frame. Right now im not using VB''s, im just rendering the vertices that I know must be drawn!

I get about 60fps...but then again, im using a 2.0ghz pentium 4.

Share this post


Link to post
Share on other sites
masonium    118
Are you using index buffers? I''m pretty sure it''s a lot faster to change the indices than to cahnge the vertex data every frame. If you''re not using index buffers, you might want to switch to them. If not, then make sure your vertex bfufers are using the D3DUSAGE_DYNAMIC and D3DUSAGE_WRITEONLY flags during creation. You can''t have a managed vertex buffer while using those flags, though. also, use D3DLOCK_DISCARD when you lock.

Share this post


Link to post
Share on other sites