Jump to content
  • Advertisement
Sign in to follow this  
fathom88

VBO Question

This topic is 4725 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've been trying to implement VBO's but I can't seem to get it to work. I've gone over the tutorials and can't see what's wrong. To initialize the VBO, I do the following glGenBuffersARB(1, &mVertsBuf); glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVertsBuf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, (MAX_VERTS) * sizeof(float), mVertices, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); I also have a color array and an indicies array. I do basically the same thing for the color array. I don't bother setting the indicies array to the VBO beacause it's fairly trivial. I draw by doing the following. glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); FillData();// fills the member arrays with data to draw glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVertsBuf); glVertexPointer(2, GL_FLOAT, 0, NULL); glBindBufferARB(GL_ARRAY_BUFFER_ARB, mColors); glColorPointer(3, GL_UNSIGNED_BYTE, 0, NULL ); glDrawElements( GL_TRIANGLE_STRIP, DrawVertices, GL_UNSIGNED_SHORT, mIndicies); //indicies not in VBO I don't see what's wrong. I check to make sure my video card supports VBO, and it does. I know the basic drawing routine is OK because when I disable VBO and replace glVertexPointer with member arrays names instead of NULL, it draws fine. Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
More specifically, after you fill in the data, you need to re-bind the VBO, and call glBufferDataARB() again, to update the VBO with the newly filled in data.

Share this post


Link to post
Share on other sites
It worked when I added the glBufferDataARB after the filling the vertices array. However, I found it to be slower as I expected. The over-head of constantly sending the vertices to my video card slowed the whole process down. It was 3x quicker when I simply left the data local and called glVertexPointer with my member arrays as params. Thanks for all the help. I should have noticed it before.

Share this post


Link to post
Share on other sites
You might want to try changing the usage from GL_STATIC_DRAW to GL_DYNAMIC_DRAW. The former tells the driver that you won't be updating the VBO frequently, so it'll optimize accordingly. Your usage model is consistent with the latter.

Share this post


Link to post
Share on other sites
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (MAX_VERTS) * sizeof(float), mVertices, GL_STATIC_DRAW_ARB);

if its a vert than shouldnt this be three floats?
something like MAX_VERTS*(sizeof(float)*3)

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!