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

Vertex Buffer deletion speed problem?

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

This is really an irritation, and I suspect it''s got more to do with using Visual Basic than with actual vertex buffers. What''s happening is this: I am creating a large array of vertex buffers (two dimensional, each vertex buffer corresponds to a 1x1 map unit). So, I create an array of 200x200 and can then draw any terrain unit by saying, for example, setstreamsource= map(x,y).VertexBuffer This all loads up and runs quite fine. The map loading takes about 4 seconds on a 200x200 map and the thing renders with plenty speed to spare. My problem is that exiting the application takes up to a minute, and if I try and re-load a map (over-writing the existing Vertex buffer array) it takes a similar time (I assume because it has to destroy the VB and then re-create it... and the destruction slowdown is the same as when the app exits). I have taken a look at what''s happening and this problem is definitely being caused by the destruction of the VB''s (if I run a loop that manually destroys them before terminating the program, the loop takes about a minute to run, and then the app exits in seconds so... this means it''s the VB''s that are slowing it down). I don''t know if this is a problem with Visual Basic not handling the memory efficiently, or if it''s a problem with VB''s in general in DX8. I note the Max Payne has a ''Please wait while quiting game'' period... my game waits for about the same amount of time so maybe it''s a common prob. Anyway, if anyone could tell me either how to fix the problem or that I must just accept it because that''s the way things are, I would appreciate it.

Share this post

Link to post
Share on other sites
Use one vertex buffer only. Each unit of terrain (assuming it's a quad) consists of 2 triangles.
Then you can locate any terrain unit you want to render.

Width of each row of terrain units : wWidth
Triangle number in each row : wWidth * 2
Vertex number in each row : wWidth * 2 * 3 = wWidth * 6

For Terrain Unit (x,y)
wVertexOffset = (x + (y * wWidth)) * 6; (don't take this formula for granted. I make stupid makes sometimes)

Rendering : You can create a dynamic buffer (Default Pool) and then refill it each frame
Use an index buffer to define the tris you want to render

Edited by - Coder on November 14, 2001 6:58:08 AM

Share this post

Link to post
Share on other sites