Sign in to follow this  
AndyEsser

Using Vertex Arrays or VBO's

Recommended Posts

AndyEsser    394
Hey Guys, I've got all my vertex data, organised as Face indices and stored within my Object Structure. Now I'm trying to implement destructible scenery, basically wanting impacts on objects to remove vertices from the vertex list. Now obviously using Display Lists for this won't work. Can anyone suggest which would be easier for me to implement Vertex Arrays or VBO's? Thanks

Share this post


Link to post
Share on other sites
songho    268
Quote:
Original post by AndyEsser
Can anyone suggest which would be easier for me to implement Vertex Arrays or VBO's?

Vertex array and VBO are almost same except where the vertex arrays are stored; system memory (Vertex array) or video memory (VBO).

VBO borrows all drawing functions, such as glDrawArrays(), glDrawElements(), from Vertex Array. Therefore, if you know Vertex Array, then converting from VA to VBO is very easy. And VBO is much faster than VA.

Share this post


Link to post
Share on other sites
nmi    978
Just a hint:
If you are using VBOs, part of the video memory is mapped to your process address space. This allows to directly write data to the graphics cards memory (while vertex arrays require an intermediate copy operation), but that mapped memory usually is not cached. So avoid something like read-modify-write on that memory region. Fastest would probably be generating a vertex stream and then just writing that stream to the mapped memory.

Share this post


Link to post
Share on other sites
RichardS    298
How much data will you be changing? If you're going to be poking a relatively small amount of data, then BufferSubData is the way to go. If you're uploading large quantities of new vertex data, I suggest the streaming VBO route.

BufferSubData requires an extra copy of your vertex data to be done on the CPU, which will hurt if you're generating lots of new geometry. For small quantities, the extra work does not really matter. It is also sometimes found to be faster because that copy can be done immediatly, rather than waiting for outstanding rendering on the buffer object to complete.

For MapBuffer, follow the pattern in Listing 8-3. The advice is solid on all platforms. The key is calling BufferData(NULL) before MapBuffer(WRITE_ONLY). That informs the OpenGL implementation that the old contents of the buffer do not have to be maintained, avoiding that synchronization. It also avoides BufferSubData's extra copy.

Share this post


Link to post
Share on other sites
oggialli    217
Why do you think BufferSubData would require an extra copy? To my knowledge, neither require extra copies, and BufferSubData offers extra asynchronization opportunities.

Share this post


Link to post
Share on other sites
AndyEsser    394
All I'm going to be doing is removing vertices in objects which have reached a certain threshold (ie, been shot too much) and then when the surrounding vertices are rendered then the missing vertex won't be and it _should_ look like there's been a chip taken out of like a wall or something.

I've been reading up on Vertex Arrays so I'll try and implement those and then maybe transfer to VBO's. I'm trying to keep this as hardware independant as possible.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this