Skip to main content
gamedev.net
🔒 Locked

multiple vertex buffer question(s)

Started by GekkoCube 5 replies 500+ views
Original Post
GekkoCube
GekkoCube
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.
flaXen
flaXen
LPD3DVERTEXBUFFER is a pointer (indicated by "LP" at the beginning). If you want to create an array of vertex buffers, use LPD3DVERTEXBUFFER *vb.
steg
steg
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.
If it isn't working, take a bath, have a think and try again...
GekkoCube
GekkoCube
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.
Illumini
Illumini
Not the expert here, but why is your terrain mesh changing every frame?
GekkoCube
GekkoCube
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.
masonium
masonium
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.