How to modify VBO data

I am learning LWJGL so i can start working on my game. In order to learn LWJGL I got the idea to implement the map builder so I can get comfortable with graphics programming. Now, for the map creation tool I need to draw new elements or draw the old one's with different coordinates.

Let me explain this:

My game will be a 2D scroller. The map will be consisting of multiple rectangles ( 2 strip triangles). When I click my left-mouse button i want to start the rectangle and when I release it I want to stop the rectangle bottom-right at that position.

As I want to use VBOs I want to know how to modify data inside the VBO based on user input. Should i have a copy of a vertex array and then add the whole array to the VBO at each user input? How is usually implemented the VBO update?

• Check out: glBufferSubData. Though, it's probably easier to just make the buffer again. – MichaelHouse Jul 1 '13 at 17:22

• Note that you should use glInvalidateBufferData as appropriate, or for older GL, use the trick of calling glBufferData first with a NULL address and 0 length. This will allow the GPU to intelligently handle your data updates without stalling in the event you are updating the buffer while the GPU is still drawing from it. – Sean Middleditch Jul 1 '13 at 18:17