Using Vertex Arrays or VBO's
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
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.
Thanks for the replies guys. Since I'm trying to get my engine running as fast as possible I'll try the VBO option.
Thanks
Thanks
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.
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.
In my experience, even better is to just use BufferSubData for buffer updates. It can be used to update contiguous regions of a buffer most efficiently.
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.
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.
Why do you think BufferSubData would require an extra copy? To my knowledge, neither require extra copies, and BufferSubData offers extra asynchronization opportunities.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement