Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
1  
Check out: glBufferSubData. Though, it's probably easier to just make the buffer again. –  Byte56 Jul 1 '13 at 17:22

1 Answer 1

up vote 3 down vote accepted

For small data like this, you want glBufferSubData, sweet and simple :)

Later on you probably should look into glMapBuffer though, as it is how you work with data larger than a few kilobytes quickly.

share|improve this answer
2  
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
    
to supplement sean's recommendations, also investigate glMapBufferRange and amd's pinned memory –  MickLH Jul 1 '13 at 18:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.