View Full Version : The best way for swap data between 2 VBO's

06-20-2011, 07:07 AM
I'm trying to use a rain effect with geometry shader. Basically it should work like this:

1 - Draw VBO1 (only GL_POINTS)
2 - In vertex shader make animation (based on wind, position..)
3 - Store the new position via feedback transform to VBO2
4 - In geometry shader create from 1 point a billboard with 4 vertices
5 - In fragment shader render the billboard with a texture on in
6 - swap VBO2 to VBO1

The question is: what is the best way to swap data between 2 VBO's? So far only options came up to my mind:
- for loop (this just does not sound correct)
- 'rebind' the buffers - this does not sound very much correct either

any comments more than appreciated

06-20-2011, 07:19 AM
Please clarify your question as I don't really understand what a for loop or rebinding the buffers has to do with swapping the VBOs.

If I understand it correctly, you want to use VBO2 (generated using transform feedback) as the initial VBO in the next round. To do this, you only have to exchange the values of the variables that store the buffer object name. What is exactly the problem with this?

06-20-2011, 12:00 PM
Yes, my question is that what is the best way to exchange/swap the values between the 2 vbo buffers.

Ilian Dinev
06-20-2011, 12:24 PM
GLuint temp;
temp = vbo1;
vbo1 = vbo2;
vbo2 = temp;

I swear I saw it somewhere in the documentation :) .