Sign in to follow this  

Manage VBO for multiple objects

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

I want to render an undefined amount of objects on my scene

if I create one large VBO to hold all the data how do I deal with geometry changes that may occur to some of those objects

I was thinking of having many vbo's but Ive been told that would cause problems


please help

Share this post


Link to post
Share on other sites
[quote]if I create one large VBO to hold all the data how do I deal with geometry changes that may occur to some of those objects[/quote]

I'm not sure what you mean by geometry changes, if you mean actually changing the vertices of an individual object that can be done by replacing the vertices with glBufferSubData. If you mean just moving objects around in space then you'll just draw a subset of the VBO each time you change the transformation.


[quote]
I was thinking of having many vbo's but Ive been told that would cause problems
[/quote]

I think you've either been told incorrectly or misunderstood.

Share this post


Link to post
Share on other sites
For usage specifics, see http://www.opengl.org/sdk/docs/man/xhtml/glBufferSubData.xml

Where different objects start and end is up to you to keep track of. You could just store values called 'start' and 'end' inside your object class, and a pointer to a opengl buffer. Then when you draw a particular object you just render the VBO from 'start' to 'end'.

Share this post


Link to post
Share on other sites
You can either do double buffering, which means having 2 VBOs. This does improve performance.
The other way is to call glBufferData with a NULL pointer. This tells the driver you prefer to have a newly allocated VBO. Then call glBufferSubData to refresh the entire VBO.
http://www.opengl.org/wiki/VBO_-_more#Dynamic_VBO

Share this post


Link to post
Share on other sites
I still havent made a decision on how to handle the rendering of my objects..

I was thinking of doing this

- send the following data to the vertex shader

vec2 translation_vector
float rotation_degrees
vec3 vertex[4]
vec4 color

(send as uniforms the projection and the current camera matrices)


this way I can just create my matrices at the vertex shader and transform the quads instead of calculating/creating matrices at the CPU

to avoid keeping tabs on where each quad is stored in the buffer I will just refill the current buffer with fresh data each frame.

comments?

thank you guys

Share this post


Link to post
Share on other sites
For my animated models I just have a dynamic vbo which I map each frame and fill with the updated data. I have one VBO per model. I guess I could have a big one for many but as I wasn't sure the number of models was gonna be constant I firstly implemented it this way. For my old video card, the bottleneck is in texturing more than in transfering.

Share this post


Link to post
Share on other sites
[quote name='EvilNando' timestamp='1307761135' post='4821963']
oh well that sounds MUCH more simpler

so where u handle the transformations? at the cpu or at the shader
[/quote]

I don't have shaders on this card so I'm currently relying on the good old matrixes.

Share this post


Link to post
Share on other sites

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