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
Manage VBO for multiple objects
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.
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.
Could you provide more details on how to use glBufferSubData?
how do I keep track of which subset corresponds to each object
how do I keep track of which subset corresponds to each object
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'.
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'.
I think Im still confused...
since probably most of my vertex data will change why I dont just refill the buffer with new data each frame?
since probably most of my vertex data will change why I dont just refill the buffer with new data each frame?
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
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
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
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
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement