#### Archived

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

# multiple vertex buffer question(s)

## Recommended Posts

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 on other sites
LPD3DVERTEXBUFFER is a pointer (indicated by "LP" at the beginning). If you want to create an array of vertex buffers, use LPD3DVERTEXBUFFER *vb.

##### Share on other sites
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 on other sites
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 on other sites
Not the expert here, but why is your terrain mesh changing every frame?

##### Share on other sites
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 on other sites
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.

• ### Forum Statistics

• Total Topics
628312
• Total Posts
2981999

• 9
• 9
• 13
• 11
• 13