Jump to content
  • Advertisement
Sign in to follow this  
c0der_

Append data to dynamic VBOs

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

How do you append data to dynamic VBOS during rendering? I don't want to render the buffer if there are too little vertices.
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_pDynamicBuffers[m_nDynamicBufferIndex].nBufferSize, pVertices, GL_DYNAMIC_COPY);

Does GL_DYNAMIC_COPY append the data or overwrite? Or perhaps I just need to store the data, append the data, and pass it into glbufferdata again with the new data, any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
Use glBufferSubData, doesn't require you to overwrite the whole buffer. You can't make a buffer any larger, but you can overwrite parts of it. If you need to resize it you call glBufferData again.

Share this post


Link to post
Share on other sites
so I just create the buffer with the initial vertices and overwrite parts of it in each render call? isn't it better to just create separate static buffers rather than overwriting parts of a dynamic buffer?


Use glBufferSubData, doesn't require you to overwrite the whole buffer. You can't make a buffer any larger, but you can overwrite parts of it. If you need to resize it you call glBufferData again.

Share this post


Link to post
Share on other sites
isn't it better to just create separate static buffers rather than overwriting parts of a dynamic buffer?[/quote]

All depends what you're trying to do.

Share this post


Link to post
Share on other sites
Guest God Almighty

How do you append data to dynamic VBOS during rendering? I don't want to render the buffer if there are too little vertices.
glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_pDynamicBuffers[m_nDynamicBufferIndex].nBufferSize, pVertices, GL_DYNAMIC_COPY);

Does GL_DYNAMIC_COPY append the data or overwrite?

GL_DYNAMIC_COPY is just a hint to the driver about what you are going to do with the data in the VBO, so it maybe can perform some optimizations. glBufferDataARB always completely overwrites the VBO with the new data (and resizes it to the size of the new data).


Or perhaps I just need to store the data, append the data, and pass it into glbufferdata again with the new data, any thoughts?

This seems like the best course of action. Collect the dynamic data you want to render in a memory buffer, and before rendering use glBufferDataARB to upload it to the GPU (graphics card).

Also, you should use GL_STREAM_DRAW as the usage hint. See here for a good overview of what each hint means.


God

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!