Sign in to follow this  

Append data to dynamic VBOs

This topic is 2494 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.
[size="2"]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?

[/size]

Share this post


Link to post
Share on other sites
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?

[quote name='karwosts' timestamp='1298006218' post='4775708']
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.
[/quote]

Share this post


Link to post
Share on other sites
[quote]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
[quote name='c0der_' timestamp='1298005454' post='4775706']
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?
[/quote]
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 [i]maybe[/i] can perform some optimizations. glBufferDataARB [i]always[/i] completely overwrites the VBO with the new data (and resizes it to the size of the new data).

[quote name='c0der_' timestamp='1298005454' post='4775706']
Or perhaps I just need to store the data, append the data, and pass it into glbufferdata again with the new data, any thoughts?
[/quote]
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 [url="http://www.spec.org/gwpg/gpc.static/vbo_whitepaper.html"]here[/url] for a good overview of what each hint means.


God

Share this post


Link to post
Share on other sites

This topic is 2494 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.

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