Advertisement

Using Vertex Arrays & Vertex Buffers

Started by June 19, 2004 05:05 AM
2 comments, last by SyncOrSwim 20 years, 5 months ago
Hey, I'm having problems using the ARB vertex buffer extensions. I can get vertex arrays to work on their own, and i can get vertex buffers to work seperatly also. What i want however is to be able to use vertex buffers for static geometry, but still retian vertex array functionality for dynamic mesh data. Surely this must be possible? I'm probably doing something really stupid somewhere, and if that is the case i do apologise. As a side, is my thinking here about using both a good idea? From my rudimentary knowledge of vertex arrays/buffers, i can see where the speed benifits of both lie. I'm assuming that the cost involved at constantly re-creating vertex buffers in VRAM for constantly changing geometry would negate all the benifits - hence the two fold approach. Like i said, it seems like such an obvious concept, i'm positive the solution is just as simple but i just can't seeme to work it out. Any help, or pointers to info on the topic would be greatly appreciated, Cheers, Ben
There are different types of vertex buffer for different usage requirements. You probably want to be using vertex buffers with usage type GL_STREAM_DRAW_ARB for the constantly changing data and GL_STATIC_DRAW_ARB for the static data. You can use glBufferSubDataARB or glMapBufferARB to update the dynamic buffer. I've never used VBOs for dynamic data, so I can't be absolutely sure, but I would imagine that pure VBO, if done properly, would be better than VBO/VA.

Enigma
Advertisement
If you can get VA and VBO working individualy then the problem is porbably switchibe between them. Do you disable VBO after you are done using it? (glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ))

I you post a bit of code or better yet, tell us how it works, we might help you better.

You could use VBOs for all geometry (even dynamic), but don't create new buffers every frame. Just change geometry in the old one.
You should never let your fears become the boundaries of your dreams.
First off, thanks for such speedy replies.

_DarkWIng_: You were spot on, i simply wan't disabling the VBO extension after i had finished using it. A stupid error, and one that has left me feeling just a little bit stupid.

Enigma: I wasn't aware of the stream buffer functionality, i'll do some looking into it and see if it works out better for my needs (which like you, i'm guessing it might).

Cheers again for your help, much appreciated.

Ben

This topic is closed to new replies.

Advertisement